From 09857a9aad7bb32b7bde8e21c705ddde4464a042 Mon Sep 17 00:00:00 2001 From: glyn Date: Mon, 2 Nov 2009 19:32:10 +0000 Subject: [PATCH] 2.2.5 HEAD --- .gitignore | 2 + AUTHORS | 4 + COPYING | 12 + ChangeLog | 4069 +++ INSTALL | 1 + Makefile.am | 70 + Makefile.in | 913 + NEWS | 474 + README | 1 + README.euc_jp | 1 + TODO | Bin 0 -> 10178 bytes ac_func_accept_argtypes.m4 | 85 + aclocal.m4 | 7277 ++++++ child.c | 1860 ++ config.guess | 1532 ++ config.h.in | 246 + config.sub | 1640 ++ configure | 24051 +++++++++++++++++ configure.in | 185 + depcomp | 522 + doc/load_balance.odp | Bin 0 -> 14614 bytes doc/load_balance.png | Bin 0 -> 55370 bytes doc/pgpool-en.html | 2372 ++ doc/pgpool-ja.html | 3119 +++ doc/pgpool.css | 145 + doc/tutorial-en.html | 697 + doc/tutorial-ja.html | 422 + install-sh | 251 + ltmain.sh | 6997 +++++ main.c | 1937 ++ md5.c | 405 + md5.h | 27 + missing | 360 + mkinstalldirs | 40 + parser/Makefile.am | 13 + parser/Makefile.in | 478 + parser/copyfuncs.c | 2730 ++ parser/gram.c | 25739 +++++++++++++++++++ parser/gram.h | 873 + parser/gram.y | 9904 +++++++ parser/gramparse.h | 37 + parser/keywords.c | 479 + parser/keywords.h | 34 + parser/list.c | 1158 + parser/makefuncs.c | 365 + parser/makefuncs.h | 71 + parser/memnodes.h | 78 + parser/nodes.c | 28 + parser/nodes.h | 504 + parser/outfuncs.c | 5195 ++++ parser/parsenodes.h | 2069 ++ parser/parser.c | 187 + parser/parser.h | 25 + parser/pg_list.h | 325 + parser/pool_memory.c | 312 + parser/pool_memory.h | 75 + parser/pool_parser.h | 117 + parser/pool_string.c | 121 + parser/pool_string.h | 37 + parser/primnodes.h | 1100 + parser/scan.c | 3072 +++ parser/scan.l | 1058 + parser/scansup.h | 26 + parser/value.c | 78 + parser/value.h | 62 + pcp.conf.sample | 28 + pcp/Makefile.am | 33 + pcp/Makefile.in | 623 + pcp/md5.c | 405 + pcp/md5.h | 27 + pcp/pcp.c | 1299 + pcp/pcp.h | 75 + pcp/pcp_attach_node.c | 160 + pcp/pcp_detach_node.c | 160 + pcp/pcp_error.c | 87 + pcp/pcp_node_count.c | 148 + pcp/pcp_node_info.c | 169 + pcp/pcp_proc_count.c | 154 + pcp/pcp_proc_info.c | 179 + pcp/pcp_recovery_node.c | 160 + pcp/pcp_stop_pgpool.c | 169 + pcp/pcp_stream.c | 385 + pcp/pcp_stream.h | 52 + pcp/pcp_systemdb_info.c | 182 + pcp_child.c | 1074 + pg_md5.c | 145 + pgpool.8.in | 98 + pgpool.conf.sample | 208 + pgpool.spec | 194 + pool.h | 597 + pool_auth.c | 1133 + pool_config.c | 2906 +++ pool_config.l | 1368 + pool_connection_pool.c | 647 + pool_error.c | 178 + pool_hba.c | 1436 ++ pool_hba.conf.sample | 69 + pool_ip.c | 565 + pool_ip.h | 65 + pool_ipc.h | 38 + pool_params.c | 161 + pool_path.c | 193 + pool_path.h | 81 + pool_process_query.c | 4518 ++++ pool_proto_modules.c | 2417 ++ pool_proto_modules.h | 187 + pool_query_cache.c | 983 + pool_rewrite_outfuncs.c | 8928 +++++++ pool_rewrite_query.c | 655 + pool_rewrite_query.h | 183 + pool_sema.c | 161 + pool_shmem.c | 181 + pool_signal.c | 158 + pool_signal.h | 61 + pool_stream.c | 790 + pool_system.c | 658 + pool_type.h | 257 + ps_status.c | 386 + recovery.c | 337 + redhat/pgpool.init | 190 + redhat/pgpool.sysconfig | 6 + sample/dist_def_pgbench.sql | 73 + sample/pgpool.pam | 3 + sample/pgpool_recovery | 20 + sample/pgpool_recovery_pitr | 18 + sample/pgpool_remote_start | 13 + sample/replicate_def_pgbench.sql | 18 + sql/pgpool-recovery/Makefile | 20 + sql/pgpool-recovery/pgpool-recovery.c | 102 + sql/pgpool-recovery/pgpool-recovery.sql.in | 10 + sql/system_db.sql | 38 + strlcpy.c | 85 + test/jdbc/AutoCommitTest.java | 45 + test/jdbc/BatchTest.java | 55 + test/jdbc/ColumnTest.java | 60 + test/jdbc/CreateTempTableTest.java | 45 + test/jdbc/InsertTest.java | 34 + test/jdbc/LockTest.java | 36 + test/jdbc/PgpoolTest.java | 75 + test/jdbc/README.euc_jp | 73 + test/jdbc/RunTest.java | 83 + test/jdbc/SelectTest.java | 37 + test/jdbc/UpdateTest.java | 32 + test/jdbc/expected/autocommit | 10 + test/jdbc/expected/batch | 1 + test/jdbc/expected/column | 100 + test/jdbc/expected/insert | 1 + test/jdbc/expected/lock | 100 + test/jdbc/expected/select | 2 + test/jdbc/expected/update | 1 + test/jdbc/pgpool.properties | 7 + test/jdbc/prepare.sql | 54 + test/jdbc/run.sh | 6 + test/parser/.cvsignore | 6 + test/parser/Makefile | 70 + test/parser/README | 32 + test/parser/expected/copy.out | 15 + test/parser/expected/create.out | 64 + test/parser/expected/cursor.out | 37 + test/parser/expected/delete.out | 10 + test/parser/expected/drop.out | 12 + test/parser/expected/insert.out | 12 + test/parser/expected/misc.out | 28 + test/parser/expected/prepare.out | 4 + test/parser/expected/privileges.out | 31 + test/parser/expected/select.out | 88 + test/parser/expected/transaction.out | 38 + test/parser/expected/update.out | 11 + test/parser/expected/var.out | 22 + test/parser/input/alter.sql | 2 + test/parser/input/copy.sql | 15 + test/parser/input/create.sql | 64 + test/parser/input/cursor.sql | 37 + test/parser/input/delete.sql | 10 + test/parser/input/drop.sql | 12 + test/parser/input/insert.sql | 12 + test/parser/input/misc.sql | 28 + test/parser/input/prepare.sql | 4 + test/parser/input/privileges.sql | 31 + test/parser/input/select.sql | 88 + test/parser/input/transaction.sql | 38 + test/parser/input/update.sql | 11 + test/parser/input/var.sql | 22 + test/parser/main.c | 40 + test/parser/parse_schedule | 13 + test/parser/pool.h | 13 + test/parser/run-test | 69 + version.h | 1 + ylwrap | 223 + 189 files changed, 155244 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 README create mode 100644 README.euc_jp create mode 100644 TODO create mode 100644 ac_func_accept_argtypes.m4 create mode 100644 aclocal.m4 create mode 100644 child.c create mode 100755 config.guess create mode 100644 config.h.in create mode 100755 config.sub create mode 100755 configure create mode 100644 configure.in create mode 100755 depcomp create mode 100644 doc/load_balance.odp create mode 100644 doc/load_balance.png create mode 100644 doc/pgpool-en.html create mode 100644 doc/pgpool-ja.html create mode 100644 doc/pgpool.css create mode 100644 doc/tutorial-en.html create mode 100644 doc/tutorial-ja.html create mode 100755 install-sh create mode 100644 ltmain.sh create mode 100644 main.c create mode 100644 md5.c create mode 100644 md5.h create mode 100755 missing create mode 100755 mkinstalldirs create mode 100644 parser/Makefile.am create mode 100644 parser/Makefile.in create mode 100644 parser/copyfuncs.c create mode 100644 parser/gram.c create mode 100644 parser/gram.h create mode 100644 parser/gram.y create mode 100644 parser/gramparse.h create mode 100644 parser/keywords.c create mode 100644 parser/keywords.h create mode 100644 parser/list.c create mode 100644 parser/makefuncs.c create mode 100644 parser/makefuncs.h create mode 100644 parser/memnodes.h create mode 100644 parser/nodes.c create mode 100644 parser/nodes.h create mode 100644 parser/outfuncs.c create mode 100644 parser/parsenodes.h create mode 100644 parser/parser.c create mode 100644 parser/parser.h create mode 100644 parser/pg_list.h create mode 100644 parser/pool_memory.c create mode 100644 parser/pool_memory.h create mode 100644 parser/pool_parser.h create mode 100644 parser/pool_string.c create mode 100644 parser/pool_string.h create mode 100644 parser/primnodes.h create mode 100644 parser/scan.c create mode 100644 parser/scan.l create mode 100644 parser/scansup.h create mode 100644 parser/value.c create mode 100644 parser/value.h create mode 100644 pcp.conf.sample create mode 100644 pcp/Makefile.am create mode 100644 pcp/Makefile.in create mode 100644 pcp/md5.c create mode 100644 pcp/md5.h create mode 100644 pcp/pcp.c create mode 100644 pcp/pcp.h create mode 100644 pcp/pcp_attach_node.c create mode 100644 pcp/pcp_detach_node.c create mode 100644 pcp/pcp_error.c create mode 100644 pcp/pcp_node_count.c create mode 100644 pcp/pcp_node_info.c create mode 100644 pcp/pcp_proc_count.c create mode 100644 pcp/pcp_proc_info.c create mode 100644 pcp/pcp_recovery_node.c create mode 100644 pcp/pcp_stop_pgpool.c create mode 100644 pcp/pcp_stream.c create mode 100644 pcp/pcp_stream.h create mode 100644 pcp/pcp_systemdb_info.c create mode 100644 pcp_child.c create mode 100644 pg_md5.c create mode 100644 pgpool.8.in create mode 100644 pgpool.conf.sample create mode 100644 pgpool.spec create mode 100644 pool.h create mode 100644 pool_auth.c create mode 100644 pool_config.c create mode 100644 pool_config.l create mode 100644 pool_connection_pool.c create mode 100644 pool_error.c create mode 100644 pool_hba.c create mode 100644 pool_hba.conf.sample create mode 100644 pool_ip.c create mode 100644 pool_ip.h create mode 100644 pool_ipc.h create mode 100644 pool_params.c create mode 100644 pool_path.c create mode 100644 pool_path.h create mode 100644 pool_process_query.c create mode 100644 pool_proto_modules.c create mode 100644 pool_proto_modules.h create mode 100644 pool_query_cache.c create mode 100644 pool_rewrite_outfuncs.c create mode 100644 pool_rewrite_query.c create mode 100644 pool_rewrite_query.h create mode 100644 pool_sema.c create mode 100644 pool_shmem.c create mode 100644 pool_signal.c create mode 100644 pool_signal.h create mode 100644 pool_stream.c create mode 100644 pool_system.c create mode 100644 pool_type.h create mode 100644 ps_status.c create mode 100644 recovery.c create mode 100755 redhat/pgpool.init create mode 100644 redhat/pgpool.sysconfig create mode 100644 sample/dist_def_pgbench.sql create mode 100644 sample/pgpool.pam create mode 100644 sample/pgpool_recovery create mode 100644 sample/pgpool_recovery_pitr create mode 100644 sample/pgpool_remote_start create mode 100644 sample/replicate_def_pgbench.sql create mode 100644 sql/pgpool-recovery/Makefile create mode 100644 sql/pgpool-recovery/pgpool-recovery.c create mode 100644 sql/pgpool-recovery/pgpool-recovery.sql.in create mode 100644 sql/system_db.sql create mode 100644 strlcpy.c create mode 100644 test/jdbc/AutoCommitTest.java create mode 100644 test/jdbc/BatchTest.java create mode 100644 test/jdbc/ColumnTest.java create mode 100644 test/jdbc/CreateTempTableTest.java create mode 100644 test/jdbc/InsertTest.java create mode 100644 test/jdbc/LockTest.java create mode 100644 test/jdbc/PgpoolTest.java create mode 100644 test/jdbc/README.euc_jp create mode 100644 test/jdbc/RunTest.java create mode 100644 test/jdbc/SelectTest.java create mode 100644 test/jdbc/UpdateTest.java create mode 100644 test/jdbc/expected/autocommit create mode 100644 test/jdbc/expected/batch create mode 100644 test/jdbc/expected/column create mode 100644 test/jdbc/expected/insert create mode 100644 test/jdbc/expected/lock create mode 100644 test/jdbc/expected/select create mode 100644 test/jdbc/expected/update create mode 100644 test/jdbc/pgpool.properties create mode 100644 test/jdbc/prepare.sql create mode 100755 test/jdbc/run.sh create mode 100644 test/parser/.cvsignore create mode 100644 test/parser/Makefile create mode 100644 test/parser/README create mode 100644 test/parser/expected/copy.out create mode 100644 test/parser/expected/create.out create mode 100644 test/parser/expected/cursor.out create mode 100644 test/parser/expected/delete.out create mode 100644 test/parser/expected/drop.out create mode 100644 test/parser/expected/insert.out create mode 100644 test/parser/expected/misc.out create mode 100644 test/parser/expected/prepare.out create mode 100644 test/parser/expected/privileges.out create mode 100644 test/parser/expected/select.out create mode 100644 test/parser/expected/transaction.out create mode 100644 test/parser/expected/update.out create mode 100644 test/parser/expected/var.out create mode 100644 test/parser/input/alter.sql create mode 100644 test/parser/input/copy.sql create mode 100644 test/parser/input/create.sql create mode 100644 test/parser/input/cursor.sql create mode 100644 test/parser/input/delete.sql create mode 100644 test/parser/input/drop.sql create mode 100644 test/parser/input/insert.sql create mode 100644 test/parser/input/misc.sql create mode 100644 test/parser/input/prepare.sql create mode 100644 test/parser/input/privileges.sql create mode 100644 test/parser/input/select.sql create mode 100644 test/parser/input/transaction.sql create mode 100644 test/parser/input/update.sql create mode 100644 test/parser/input/var.sql create mode 100644 test/parser/main.c create mode 100644 test/parser/parse_schedule create mode 100644 test/parser/pool.h create mode 100755 test/parser/run-test create mode 100644 version.h create mode 100755 ylwrap diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fafff2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +Thumbs.db diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..ed5dbd3 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Authors of pgpool + +pgpool was originally written by Tatsuo Ishii, then was contributed to +pgpool Global Development Group. diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..c1e46bf --- /dev/null +++ b/COPYING @@ -0,0 +1,12 @@ +Copyright (c) 2003-2009 PgPool Global Development Group + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that copyright notice and this permission +notice appear in supporting documentation, and that the name of the +author not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. The author makes no representations about the +suitability of this software for any purpose. It is provided "as +is" without express or implied warranty. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..fcbc1f2 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,4069 @@ +2009-10-04 18:15 t-ishii + + * NEWS, configure.in, configure (V2_2_STABLE.[4,5,5]): Prepare + 2.2.5 + +2009-10-04 18:15 t-ishii + + * doc/pgpool-ja.html (V2_2_STABLE.8): Add release note for 2.2.5 + +2009-10-04 08:52 t-ishii + + * doc/tutorial-en.html (V2_2_STABLE.1): Add sample to use + rotatelogs + +2009-10-03 21:45 t-ishii + + * doc/tutorial-ja.html (V2_2_STABLE.1): Add sample to use + rotatelogs + +2009-10-03 21:39 t-ishii + + * sample/pgpool_recovery_pitr (V2_2_STABLE.1): Enhance online + recovery 2nd stage script to sync sequence value + +2009-10-03 20:55 t-ishii + + * pool_proto_modules.h (V2_2_STABLE.5): Remove unnecessary + declaration "allow_close_transaction" + +2009-10-02 16:56 t-ishii + + * pool_proto_modules.c (V2_2_STABLE.13): Fix Parse() to use + wait_for_query_response() instead of synchronize(). + +2009-10-02 16:53 t-ishii + + * pool_process_query.c (V2_2_STABLE.22): Fix comment + +2009-09-26 18:14 t-ishii + + * pool_proto_modules.c (V2_2_STABLE.12): Allow to print more + accurate query when Parse() detects kind mismatch errors. + +2009-09-26 16:36 t-ishii + + * pool_process_query.c (V2_2_STABLE.21): Fix reset_backend to deal + with DEALLOCATE error. In this case prepared objects are not removed + and reset_backend is infinitely called. + + Fix do_command to guard against the case that after execution of an + SQL command, the backend does not return either N, E or C. This + should not happen but there was a report that it actually happend in + certain cases(maybe caused by asynchronized backend data?) + + See: + + Subject: Re: [Pgpool-general] pgpool 2.2.4: DEALLOCATED children + From: Xavier Noguer Date: Fri, 25 Sep 2009 03:35:57 -0400 + + For more details. + + Patches by Xavier Noguer with minor tweak by Tatsuo Ishii. + +2009-09-25 23:36 t-ishii + + * pool_proto_modules.c (V2_2_STABLE.11): Make + allow_close_transaction to static and add comments. + + Let execute CREATAE TEMP TABLE on every nodes in master/slave mode. + If not, subsequent Parse or Bind to use the table will fail. At + this point this doen't work since MASTER_SLAVE set to 0 in + ProcessFrontendResponse. More analysis is needed... + +2009-09-25 16:35 t-ishii + + * main.c (V2_2_STABLE.6): Fix write_pid_file. It forgot to write + out NULL termination of pid. Pgpool occasionally won't stop because + of this bug. + +2009-09-23 20:39 t-ishii + + * pool_process_query.c (V2_2_STABLE.20): Remove error checks for + pool_write(frontend), pool_flush(frontend) in + SimpleForwardToFrontend. + + Check error for send_deallocate() in reset_backend. Otherwise + send_deallocate will be called infinitely. Per bug report from + Agustin Almonte Ferrada. See: + + Subject: Re: [Pgpool-general] pgpool 2.2.4: DEALLOCATED children + From: Agustin Almonte Ferrada To: Tatsuo Ishii + Cc: pgpool-general@pgfoundry.org Date: Wed, 23 + Sep 2009 01:55:54 -0400 + +2009-09-23 11:03 t-ishii + + * pool_auth.c (V2_2_STABLE.2): Fix pool_read_kind and pool_read_int + so that the error message for kind is shown in hexadecimal. Other + part of pgpool-II already does this. + +2009-09-17 20:17 t-ishii + + * pool_process_query.c, pool_proto_modules.c, pool_proto_modules.h + (V2_2_STABLE.[19,10,4]): Teach do_command() to use + wait_for_query_response(). insert_lock() calls do_command() to + issue LOCK TABLE to lock tables having SERIAL column when + insert_lock is true. Problem is, insert_lock() waits forever in + do_command() if the target table is locked by someone else. This + patch should give a way insert_lock() to espcape from the situation. + +2009-09-06 12:52 t-ishii + + * child.c, pool.h (V2_2_STABLE.[8,5]): Fix connection_count_down() + so that it does decrement too much in some corner cases. If failed + to read a start up packet, or receive cancel request etc., + connection_count_down() is called and goes back to the onnection + accept loop. Problem is, at the very beginning of the connection + accept loop, if we have received a signal, we call child_exit() + which calls connection_count_down() again. Problem report by + Ryoichi TANABE. See [pgpool-general-jp: 616] for more details. + + Also unneccesary public declarations for connection_count_up() and + connection_count_down() are removed. + +2009-08-24 13:58 t-ishii + + * ChangeLog (tags: V2_2_4) (V2_2_STABLE.4): Prepare 2.2.4 + +2009-08-24 13:55 t-ishii + + * NEWS, configure, doc/pgpool-ja.html (V2_2_STABLE.[3,4,7]) (utags: + V2_2_4): Prepare 2.2.4 + +2009-08-24 13:53 t-ishii + + * configure.in (tags: V2_2_4) (V2_2_STABLE.4): Prepare 2.2.4. + +2009-08-24 13:36 t-ishii + + * TODO (tags: V2_2_4) (V2_2_STABLE.1): Add a few items + +2009-08-22 13:19 t-ishii + + * child.c, main.c, md5.c, pcp_child.c, pg_md5.c, pool_auth.c, + pool_config.c, pool_connection_pool.c, pool_error.c, pool_hba.c, + pool_ip.c, pool_params.c, pool_path.c, pool_process_query.c, + pool_proto_modules.c, pool_query_cache.c, + pool_rewrite_outfuncs.c, pool_rewrite_query.c, pool_sema.c, + pool_shmem.c, pool_signal.c, pool_stream.c, pool_system.c, + ps_status.c, recovery.c, strlcpy.c, pcp/md5.c + (V2_2_STABLE.[7,5,1,1,1,1,1,3,1,1,1,1,1,18,9,1,5,1,2,2,1,2,1,1,1,1,1]) + (utags: V2_2_4): Remove unnecessary spaces and tabs at end of + line. Patch conributed by Jun Kuriyama. + +2009-08-20 15:26 t-ishii + + * pool_process_query.c (V2_2_STABLE.17): Fix possible bug + introduced in pgpool-II 2.2.2. Load balance control variables may + remain not be restored and subsequent DML/DDL call might sent to + only master node. + +2009-08-18 17:38 t-ishii + + * pool_process_query.c, pool_proto_modules.c, pool_proto_modules.h + (tags: V2_2_4) (V2_2_STABLE.[16,8,3]): Change + wait_for_query_response() so that it sends NOTICE message to + frontend periodically. It appears that pgpool-II 2.2.3 + unconditionaly sends param packet to client even it uses version 2 + protocol, which is apparentlt wrong. Also tweak checking period from + 1 second to 30 seconds since 1 second seems too aggressive. + +2009-08-18 17:30 t-ishii + + * child.c (V2_2_STABLE.6): Remove unneccessary call to + send_frontend_exit() in do_child(). + +2009-08-13 22:36 t-ishii + + * child.c (V2_2_STABLE.5): Remove unnessary call of + send_frontend_exits() in die(). + +2009-08-13 22:34 t-ishii + + * main.c (V2_2_STABLE.4): Block signals before forking children + rather after. Otherwise parent will be killed by failover signal if + it receives before establish signal handler. See [pgpool-general-jp: + 586] for more details. + +2009-08-11 22:53 t-ishii + + * ChangeLog (tags: V2_2_3) (V2_2_STABLE.3): Prepare 2.2.3. + +2009-08-11 22:52 t-ishii + + * configure.in, configure (V2_2_STABLE.[3,3]) (utags: V2_2_3): + Stamp 2.2.3. + +2009-08-11 22:48 t-ishii + + * doc/pgpool-ja.html (tags: V2_2_3) (V2_2_STABLE.6): Fix + description of parallel query. Add release note for 2.2.3. + +2009-08-11 22:23 t-ishii + + * pool_connection_pool.c (tags: V2_2_3) (V2_2_STABLE.2): Fix + new_connection() so that it does leave garbage in + POOL_CONNECTION_POOL->slot[i]. This caused segfault in child_exit(). + Bug report at [pgpool-general-jp: 586]. + +2009-08-07 14:27 y-mori + + * pool_process_query.c, pool_rewrite_outfuncs.c + (V2_2_STABLE.[15,4]) (utags: V2_2_3): FIX parallel query + + 1. Fix JOIN Expr + Subquery was used on larg or rarg. + Subquery was used on ON-Cluase. + Full OUTER JOIN was not optimized.   + 2. Fail_on_error=false was passed to the 3rd arguments of dblink. + +2009-08-06 16:55 t-ishii + + * pool_proto_modules.c (tags: V2_2_3) (V2_2_STABLE.7): Print last + query for kind mismatch error message even extended protocol is + used. Patch contributed by Akio Ishida. + +2009-08-06 16:38 t-ishii + + * pool_process_query.c (V2_2_STABLE.14): Fix buffer overrun error + which mangled kind mismatch error message in + pool_send_error_message(). Bug rpeort by Takahiro Itagaki at + [pgsql-jp: 39950]. Fix suggested by Akio Ishida at [pgsql-jp: + 39952]. + +2009-08-01 20:40 t-ishii + + * child.c (tags: V2_2_3) (V2_2_STABLE.4): Check + MASTER_CONNECTION(p)->sp) is non 0 before further referring to sp. + Current implementation may interrupt in the window, after setting p + and before setting sp. Per bug report from Jun Kuwamura. + +2009-08-01 20:34 t-ishii + + * pool_connection_pool.c (V2_2_STABLE.1): Fix pool_debug's mismatch + between data type and conversion specification for time_t. Check + MASTER_CONNECTION(p)->sp) is non 0 before further referring to sp. + Current implementation may interrupt in the window, after setting p + and before setting sp. + +2009-07-30 16:46 t-ishii + + * pool_process_query.c (V2_2_STABLE.13): Fix typo in comment + +2009-07-28 14:52 y-mori + + * doc/: pgpool-en.html (tags: V2_2_4, V2_2_3), pgpool-ja.html + (V2_2_STABLE.[3,5]): add restrictions for parallel mode + + -Natural Join + => not support + -USING CLAUSE at Join Expression + => auto convert to ON CLAUSE + +2009-07-26 18:04 t-ishii + + * pool_rewrite_outfuncs.c (V2_2_STABLE.3): Fix breakage by previous + commit. Patch by Guillaume Lelarge. + +2009-07-26 12:01 t-ishii + + * pool_process_query.c (V2_2_STABLE.12): Fix comment about load + balancing. + +2009-07-26 11:57 t-ishii + + * pool_sema.c (tags: V2_2_3) (V2_2_STABLE.1): Fix various + pool_error/log format errors. Patch provided by Akio Ishida. + +2009-07-24 21:30 y-mori + + * pool_rewrite_outfuncs.c (V2_2_STABLE.2): fix: Join statment in + parallel query + + sample) + Accouts table is defined by dist_def, + the below query is executed as loadbalance. + + SELECT a.aid + FROM + accounts as a + JOIN + accounts as b + ON a.aid=b.aid + WHERE a.aid =1 or a.aid=2; + +2009-07-22 17:46 t-ishii + + * child.c, main.c (tags: V2_2_3), pool.h (tags: V2_2_4, V2_2_3), + pool_process_query.c, pool_proto_modules.c, + pool_rewrite_outfuncs.c, pool_shmem.c (tags: V2_2_3) + (V2_2_STABLE.[3,3,4,11,6,1,1]): Fix various pool_error/log format + errors. Patch provided by Akio Ishida. + +2009-07-22 14:33 t-ishii + + * pool_process_query.c, pool_proto_modules.c, pool_proto_modules.h + (tags: V2_2_3) (V2_2_STABLE.[10,5,2]): Query cancel by statement + timeout does not generate "kind mismatch" error any more. How to + reproduce the test case: + + Directory connect to PostgreSQL. T1: BEGIN; T1: LOCK TABLE t1; + + T2: SET statement_timeout TO 5000; T2: UPDATE t1 SET ... + + UPDATE query aborts and error message comes out on T2: ERROR: + canceling statement due to statement timeout + + A side effect of this is, statement timeout works correctly (rather + than statement timeout value * # of node). + + Note that to initiate T1 by directory connecting to slave node will + not work (still results in kind mismatch error). But I don't think + this could happend in the real world. + + Also refactor error detecting modules (detect_deadlock_error and so + on). + +2009-07-21 18:48 t-ishii + + * main.c (V2_2_STABLE.2): Check read(2) error in health_check(). + This should detect case described in message below, i.e. postmaster + is blocked by SIGSTOP. + + Subject: [Pgpool-general] Healt Check issues From: Vctrjsn@gmail.com + To: pgpool-general@pgfoundry.org Date: Sun, 05 Jul 2009 18:01:18 + +0000 + +2009-07-21 12:59 t-ishii + + * ChangeLog (V2_2_STABLE.2): Update Change. We are getting closer + to 2.2.3. + +2009-07-21 10:36 t-ishii + + * pool.h, pool_proto_modules.c (V2_2_STABLE.[3,4]): Check frontend + connection while waiting for response from backend for extended + protocol (Execute()). Replace sychronize() with + wait_for_query_response(). Also tweak pool.h so that it includes + cancel packet's mazic proto number. + +2009-07-21 09:26 t-ishii + + * pool_process_query.c (V2_2_STABLE.9): Do not start transaction if + the command is CLUSTER with no argument + +2009-07-20 20:47 t-ishii + + * child.c, pool.h, pool_process_query.c, pool_proto_modules.c, + pool_proto_modules.h (V2_2_STABLE.[2,2,8,3,1]): Check frontend + connection while waiting for response from backend. This is done in + wait_for_query_response() by writing a dummy parameter status packet + to pgpool client every 1 second. If the write fails, a cancel packet + is sent to backend to free backend. This is usefull to prevent + pgpool child from waiting forever for backend response. Pgpool + client will diconnect to pgpool if the query takes too long. This is + typical use case for Web applications. + +2009-07-15 14:14 t-ishii + + * pool_process_query.c (V2_2_STABLE.7): Fix bug with prepared + statement deallocation: + + Subject: [Pgpool-general] Pgpool probelms From: Nimesh Satam + To: pgpool-general@pgfoundry.org Cc: Nimesh + Satam Date: Wed, 17 Jun 2009 11:31:37 +0530 + + This was caused a bug in reset_backend(). + + if (qcnt >= qn + prepared_list.cnt) { + reset_prepared_list(&prepared_list); + return 2; } send_deallocate(backend, &prepared_list, qcnt - qn); + return 1; + + Problem is, send_deallocate -> SimpleQuery("DEALLOCATE") calls + del_prepared_list, which will decrement prepared_list.cnt. In short, + incrementing of qcnt *and* decrementing of prepared_list.cnt happen + at the same time. So deallocate is only called 1/2 times than it + should be. + + Bug analysis and fix provided by Akio Ishida. + +2009-07-14 17:42 t-ishii + + * sql/pgpool-recovery/pgpool-recovery.c (tags: V2_2_4, V2_2_3) + (V2_2_STABLE.2): Update copyright year + +2009-07-14 17:39 t-ishii + + * sql/pgpool-recovery/pgpool-recovery.c (V2_2_STABLE.1): PostgreSQL + 8.4 needs to include utils/binutils.h + +2009-06-26 13:59 t-ishii + + * pool_process_query.c (V2_2_STABLE.6): Fix bug with + SimpleForwardToFrontend(). Clients using the extend protocol send + 'H'(Flush) after each command. Problem is, SimpleForwardToFrontend + does not immediately forward 'C'(Command Complete) packet to + frontend. So the client sends 'H' and wait for 'C'. On the other + hand backend receives 'H' but reply back nothing since Command + complete has nothing to be returned. Both side stuck. + + The fix is, forwarding 'C' packet immediately after receiving it + from backend. To prevent similar bugs happen in the future, I put + pool_flush(frontend) after calling SimpleForwardToFrontend in + pool_process_query() (other places already do this). + + The extra pool_flush() might harm performance. So I did some tests + using pgbench -S, and found nothing has been changed regarding + performance after patching. + + Bug report from Gavin Sherry along with patches for + SimpleForwardToFrontend(). + +2009-05-27 11:01 t-ishii + + * pool.h, pool_process_query.c (V2_2_STABLE.[1,5]): Add + pool_set_timeout() to control pool_check_fd()'s behavior. This can + be used for various places. The first user is reset_backend() to + fix following scenario: Do COPY_FROM(for example pgbench -i) Cancel + pgbench pgpool waits for response from backend while sending reset + queries and hang. Backend waits for data coming from pgpool + forever. + + BTW, I don't think PostgreSQL's befaviro for COPY_FROM is quite + correct since the doc stats:"Receipt of any other non-copy message + type constitutes an error that will abort the copy-in state as + described above" If my understanding correct, COPY_FROM should abort + copy-in state if it receives ABORT (issued in reset_backend). It + seems PostgreSQL is not implemented as stated in the doc... + +2009-05-24 22:56 t-ishii + + * sql/pgpool-recovery/Makefile (tags: V2_2_4, V2_2_3) + (V2_2_STABLE.1): Support pre 8.0 PostgreSQL which does not have + pg_config --pgxs option. Patch provided by Enrico Pirozzi with + slight modification by Tatsuo Ishii + +2009-05-12 10:01 t-ishii + + * doc/pgpool-en.html (V2_2_STABLE.2): Fix description of + client_idle_limit + +2009-05-05 11:07 t-ishii + + * configure.in, configure, NEWS (tags: V2_2_3) + (V2_2_STABLE.[2,2,2]) (utags: V2_2_2): prepare 2.2.2 + +2009-05-05 11:04 t-ishii + + * doc/pgpool-ja.html (tags: V2_2_2) (V2_2_STABLE.4): Add 2.2.2 + release note + +2009-05-02 17:48 t-ishii + + * pool_process_query.c (tags: V2_2_2) (V2_2_STABLE.4): Fix + is_select_query() to test "sql" parameter is NULL. As of 2.2, + pgpool sets Portal->sql_string to NULL for SQL command PREPARE. + Usually this is ok, since in most cases SQL command EXECUTE follows + anyway. Problem is, some applications mix PREPARE with extended + protocol command "EXECUTE" and so on. Execute() seems to think this + never happens but it is not real. Someday we should extract actual + query string from PrepareStmt->query and set it to + Portal->sql_string. + +2009-05-02 17:45 t-ishii + + * pool_stream.c (tags: V2_2_3, V2_2_2) (V2_2_STABLE.1): Fix + pool_flush() so that it ignores error on frontend connection. This + is needed to continue processing with backend, otherwise we risk + data incositency. + +2009-05-02 17:41 t-ishii + + * child.c (tags: V2_2_2) (V2_2_STABLE.1): Call + pool_send_frontend_exits() before pool_discard_cp() when resetting + connection fails. This will avoid "unexpected EOF on client + connection" error on when pgpool client exits abnormaly + +2009-05-01 09:39 t-ishii + + * pool_proto_modules.c (tags: V2_2_2) (V2_2_STABLE.2): Add missing + patches for this: + + 2009-04-08 20:11 t-ishii + + * pool_proto_modules.c (V2_2_STABLE): In master slave mode, + sometimes DEALLOCATE fails. This is caused by that the first + PREPARE was not executed on the slave. Patch contributed by + Toshihiro Kitagawa. + +2009-04-25 16:20 t-ishii + + * ChangeLog (tags: V2_2_2, V2_2_1) (V2_2_STABLE.1): prepare for + 2.2.1 + +2009-04-25 16:16 t-ishii + + * configure.in, configure (V2_2_STABLE.[1,1]) (utags: V2_2_1): + prepare for 2.2.1 + +2009-04-25 16:12 t-ishii + + * doc/pgpool-ja.html (tags: V2_2_1) (V2_2_STABLE.3): Add 2.2.1 + release note + +2009-04-25 16:05 t-ishii + + * NEWS (tags: V2_2_1) (V2_2_STABLE.1): Prepare 2.2.1 + +2009-04-08 20:11 t-ishii + + * pool_proto_modules.c (tags: V2_2_1) (V2_2_STABLE.1): In master + slave mode, sometimes DEALLOCATE fails. This is caused by that the + first PREPARE was not executed on the slave. Patch contributed by + Toshihiro Kitagawa. + +2009-04-03 22:49 t-ishii + + * doc/: pgpool-en.html (tags: V2_2_2, V2_2_1), pgpool-ja.html + (V2_2_STABLE.[1,2]): Add documents about configuration reloading. + +2009-04-03 19:21 t-ishii + + * pgpool.spec, redhat/pgpool.conf.sample.patch, redhat/pgpool.init + (V2_2_STABLE.[1,1,1]) (utags: V2_2_1, V2_2_2, V2_2_3, V2_2_4): + Merge changes made on HEAD regarding RPM spec files + +2009-03-23 10:13 devrim + + * redhat/pgpool.conf.sample.patch (1.1): Add a patch which + configures sample conf file to match RPM and Red Hat defaults. + +2009-03-14 12:39 t-ishii + + * pool_process_query.c (tags: V2_2_1) (V2_2_STABLE.3): Fix + need_insert_lock so that it returns false if the protocol version is + 2. insert_lock has not been working for V2 protocol anyway, so this + is ok. + +2009-03-08 23:58 gleu + + * main.c, pgpool.8.in (tags: V2_2_4, V2_2_3) (V2_2_STABLE.[1,1]) + (utags: V2_2_1, V2_2_2): Update usage function and man page. + +2009-03-07 18:19 t-ishii + + * pool_process_query.c (V2_2_STABLE.2): Add a comment to + need_insert_lock() if the query being used to check if the table has + SERIAL column is valid for PostgreSQL 7.3 to 8.3. + +2009-03-07 08:54 t-ishii + + * pool_process_query.c (V2_2_STABLE.1): Make excessive message + level in read_kind_from_backend from LOG to DEBUG. + +2009-03-01 22:34 t-ishii + + * doc/pgpool-ja.html (V2_2_STABLE.1): Fix release note for 2.2 + +2009-02-28 15:33 t-ishii + + * Makefile.in (tags: V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0) + (V2_2_STABLE.1): Update Makefile.am + +2009-02-28 15:33 t-ishii + + * Makefile.am (tags: V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0) + (V2_2_STABLE.1): Add doc/load_balance.png, doc/load_balance.odp + +2009-02-28 13:45 t-ishii + + * ChangeLog (1.40), NEWS (1.28), TODO (1.18, V2_2_3, V2_2_2, + V2_2_1), configure (1.30) (utags: V2_2_0): Version 2.2 + +2009-02-28 13:40 t-ishii + + * configure.in (1.27, V2_2_0): Version 2.2 + +2009-02-24 11:20 t-ishii + + * pool_auth.c (1.15, V2_2_3, V2_2_2, V2_2_1), pool_process_query.c + (1.141) (utags: V2_2_0): Prpare for receiving parameter status + packets. + + If postgresql.conf was changed and reloaded, PostgreSQL sends + parameter status packets asynchronously even those changed + parameters are not one of session_authorization etc., which is + marked as GUC_REPORT in guc.c(GUC_REPORT means parameter status + packet is sent if its value is changed). + + After receiving those packets, they are discarded. I think this is + harmless since most of changes are not affected to the frontend + behavior. + +2009-02-21 19:00 t-ishii + + * TODO (1.17), configure (1.29), ChangeLog (1.39) (utags: + V2_2_0_RC2): pgpool-II 2.2 RC2 + +2009-02-21 18:56 t-ishii + + * configure.in (1.26, V2_2_0_RC2): pgpool 2.2 RC2 + +2009-02-21 18:52 t-ishii + + * doc/load_balance.png (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2): A load balance logic explanation figure + +2009-02-21 18:47 t-ishii + + * doc/: pgpool-en.html (1.35), pgpool-ja.html (1.59) (utags: + V2_2_0, V2_2_0_RC2): Add comment about rsync and autovacuum. + +2009-02-20 10:34 t-ishii + + * pool_process_query.c (1.140, V2_2_0_RC2): Fix + pool_send_frontend_exits() so that it checks the connection to + backend if it actually exists. This is needed, for example, in the + final stae of online recovery. pgpool child holds 1 connection to a + backend. After failback one more backend added but there's no + connection to the backend. + +2009-02-17 18:50 t-ishii + + * pool_process_query.c (1.139): Do not start internal transaction + if CREATE INDEX CONCURRENTLY + +2009-02-17 15:16 devrim + + * pgpool.spec (1.14, V2_2_0, V2_2_0_RC2): Update to 2.2 (Download + URL is broken, since we don't know yet the pgfoundry download URL + yet) + +2009-02-15 14:35 t-ishii + + * configure (1.28, V2_2_0_RC1): run autoconf + +2009-02-15 14:32 t-ishii + + * configure.in (1.25, V2_2_0_RC1): 2.2 RC1 + +2009-02-15 14:31 t-ishii + + * ChangeLog (1.38, V2_2_0_RC1): Update Changelog + +2009-02-15 14:29 t-ishii + + * TODO (1.16, V2_2_0_RC1): Mention that two items were resolved + +2009-02-15 14:26 t-ishii + + * pgpool.conf.sample (1.26, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2), doc/pgpool-en.html (1.34), doc/pgpool-ja.html (1.58) + (utags: V2_2_0_RC1): Reflect the fact that DISCARD ALL holds + exclusive lock on pg_listener, thus will degrade performance. + +2009-02-10 10:11 t-ishii + + * pool_process_query.c (1.138, V2_2_0_RC1): Fix + is_internal_transaction_needed() so that DROP DATABASE does not + start internal transaction + +2009-02-07 21:57 t-ishii + + * configure (1.27, V2_2_0_BETA2): Run autoconf + +2009-02-07 21:57 t-ishii + + * configure.in (1.24, V2_2_0_BETA2): Update version + +2009-02-07 21:52 t-ishii + + * NEWS (1.27, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2): Update NEWS + +2009-02-07 00:30 t-ishii + + * pool_process_query.c (1.137, V2_2_0_BETA2): Add pid_file_name to + show pool_status + +2009-02-05 17:24 t-ishii + + * doc/pgpool-ja.html (1.57, V2_2_0_BETA2): Fix typo + +2009-02-05 09:33 t-ishii + + * ChangeLog (1.37, V2_2_0_BETA2): Run cvs2cl.pl -t --fsf + +2009-02-05 09:30 t-ishii + + * doc/pgpool-ja.html (1.56): Add more fix to release info + +2009-02-05 09:26 t-ishii + + * recovery.c (1.12, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2): Fix online recovery to wait for + failback done before allowing to accept connections from clients. It + was supposed to work like this but actually was not since the day 0 + when online recovery was born. Without the fix there could be + potential data inconsistency among DB nodes. + +2009-02-05 09:24 t-ishii + + * main.c (1.45, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2): + Fix/add comments + +2009-02-01 19:13 t-ishii + + * NEWS (1.26): Add new item + +2009-02-01 19:11 t-ishii + + * pool_process_query.c (1.136): Start internal transaction if + necessary. Before we only started transaction INSERT, UPDATE, DELETE + and SELECT. Obviously we need to start transaction other than these, + for example CREATE TABLE. To avoid an overhead to look up large + number of statements (currently 70), we use bsearch() now. + +2009-01-31 22:17 t-ishii + + * doc/pgpool-ja.html (1.55): Update release note + +2009-01-30 17:15 t-ishii + + * test/jdbc/README.euc_jp (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2): Add comment how to + add CLASSPATH + +2009-01-30 09:06 y-mori + + * pool_rewrite_query.c (1.13), pool_rewrite_query.h (1.8, V2_2_4) + (utags: V2_2_0, V2_2_0_BETA2, V2_2_0_RC1, V2_2_0_RC2, V2_2_1, + V2_2_2, V2_2_3): Add comment + +2009-01-28 15:48 t-ishii + + * NEWS (1.25): Add more items + +2009-01-27 10:04 t-ishii + + * COPYING (1.4, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2): Update copyright year + +2009-01-25 20:13 t-ishii + + * NEWS (1.24), TODO (1.15, V2_2_0_BETA2), configure (1.26), + configure.in (1.23), version.h (1.5, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2), + doc/pgpool-en.html (1.33, V2_2_0_BETA2), doc/pgpool-ja.html + (1.54) (utags: V2_2_0_BETA1): Prepare 2.2 beta1 + +2009-01-25 19:13 t-ishii + + * main.c (1.44), pool.h (1.36, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2), pool_config.l (1.24, V2_2_4, V2_2_3, + V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2), + pgpool.conf.sample (1.25, V2_2_0_BETA2), pool_config.c (1.27, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2) (utags: V2_2_0_BETA1): Add pid_file_name directive + +2009-01-25 13:32 t-ishii + + * ChangeLog (1.36, V2_2_0_BETA1): ChangeLog is now generated by + using cvs2cl.pl -t --fsf + +2009-01-25 09:09 t-ishii + + * pool_rewrite_query.c (1.12, V2_2_0_BETA1): Remove unused static + function check_whereClause() Update Copyright year + +2009-01-24 20:34 t-ishii + + * pool.h (1.35): Include limit.h. This seems to be necessary Fedra + box. Update copyright year + +2009-01-22 18:29 y-mori + + * pool_stream.c (1.14, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1): Fix different function name was used + in the error message. + +2009-01-22 18:16 y-mori + + * pool_process_query.c (1.135, V2_2_0_BETA1), pool_proto_modules.c + (1.6, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1), pool_rewrite_query.c (1.11), pool_rewrite_query.h + (1.7, V2_2_0_BETA1): add the comment related to parallel query + +2009-01-22 09:50 t-ishii + + * child.c (1.26, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1): Remove unnecessary function + declaration for child_exit() + + Add comments to child_exit() which had no comments at all + + Modify child_exit() so that it sends terminate mesagges before + exiting. This will prevent backend process from being idle waiting + for TCP keepalive event occurs. This is not good since a backend + process may hold locking on certain tables. + +2009-01-22 09:45 t-ishii + + * pool_process_query.c (1.134): Modify pool_send_frontend_exits() + so that it change fd to non block while sending terminate message + (X) to backend. This should prevent pgpool from being blocked while + sending data to socket. + +2009-01-21 10:43 t-ishii + + * pool_process_query.c (1.133): Add debug code and message + +2009-01-18 22:54 t-ishii + + * ps_status.c (1.3, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1): Fix FreeBSD case. patch + provided by Jun Kuriyama. + +2009-01-14 23:54 t-ishii + + * pool_process_query.c (1.132): Fix excessive debug statement + +2009-01-07 22:33 t-ishii + + * pool_process_query.c (1.131): Add new argument to detect_error() + so that it can recognize the error class (E or N). per bug report + from Daniel: From: Daniel.Crespo@l-3com.com To: + Date: Tue, 6 Jan 2009 12:50:08 -0500 + + The bug was caused by detect_postmaster_down_error() not detecting + receive crash shutdown error. + + Enbug by: Subject: [Pgpool-committers] pgpool - pgpool-II: Fix + detect_error() so that it ignores NOTICE. From: + t-ishii@pgfoundry.org (User T-ishii) To: + pgpool-committers@pgfoundry.org Date: Tue, 30 Dec 2008 01:05:37 + +0000 (UTC) + +2009-01-07 22:27 t-ishii + + * pool_connection_pool.c (1.13, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1), pool_proto_modules.c + (1.5): Update copyright year + +2009-01-02 18:38 t-ishii + + * pool_process_query.c (1.130): Emit pool_error when detects kind + mismatch error. Before we only sent error messages to client, but + this will leave only on client, which may or may not be kept. + Leaving it on pgpool log should leave on pgpool side at least. + +2008-12-31 23:45 t-ishii + + * child.c (1.25), main.c (1.43): Fix typos in comments. Patch + contributed by Jun Kuriyama. + +2008-12-31 23:42 t-ishii + + * pool_sema.c (1.5, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1): Enhance error message when failed to + create semaphores. Patch contributed by Jun Kuriyama. + +2008-12-31 19:25 t-ishii + + * pcp/: pcp.c (1.8), pcp.h (1.4), pcp_attach_node.c (1.3), + pcp_detach_node.c (1.3), pcp_node_count.c (1.3), pcp_node_info.c + (1.3), pcp_proc_count.c (1.4), pcp_proc_info.c (1.3), + pcp_recovery_node.c (1.4), pcp_stop_pgpool.c (1.3), + pcp_systemdb_info.c (1.3) (utags: V2_2_0, V2_2_0_BETA1, + V2_2_0_BETA2, V2_2_0_RC1, V2_2_0_RC2, V2_2_1, V2_2_2, V2_2_3, + V2_2_4): Add -d (debug)option to pcp commands. patch contributed + by Jun Kuriyama + +2008-12-30 21:16 t-ishii + + * pool.h (1.34), pool_process_query.c (1.129), pool_proto_modules.c + (1.4): Enhance "kind mismatch" error message to include original + query. This would not work for extended query, though. + +2008-12-30 10:05 t-ishii + + * pool_process_query.c (1.128): Fix detect_error() so that it + ignores NOTICE. Without this following error occurs, for example: + + BEGIN; BEGIN; + + ERROR: kind mismatch among backends 0[N] 1[E] + +2008-12-30 09:59 t-ishii + + * child.c (1.24), main.c (1.42), pool.h (1.33), pool_auth.c (1.14, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1), pool_type.h + (1.9, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1): Fix bug with query + cancel. It seems this has not been working since pgpool-II was born. + + To fix this, now we have each connection's pid and cancel key in the + shared memory area. If a cancel packet is sent, the table is + searched by the pid and the cancel key. If found, the actual cancel + key is sent to each backend. + +2008-12-27 16:26 t-ishii + + * config.h.in (1.7, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1): Update + timestamp + +2008-12-23 21:26 t-ishii + + * pool_process_query.c (1.127): Fix unnessary code(maybe copy & + paste error?) Take out internal transction starting code from + insert_lock. + +2008-12-23 21:24 t-ishii + + * pool_proto_modules.c (1.3): Fix Query() so that it starts + transaction *before* checking insert lock is needed or not + +2008-12-23 21:21 t-ishii + + * child.c (1.23): Do not make a connection cache for postgres + database + +2008-12-21 21:57 t-ishii + + * pgpool.conf.sample (1.24): Change insert_lock's default value to + true. Since automatic SERIAL data type is implemented, always making + insert_lock to true is harmless. + +2008-12-21 08:02 t-ishii + + * pool.h (1.32), pool_config.c (1.26), pool_process_query.c + (1.126): If SERIAL data type is used(checked in system catalog) + and insert_lock is true(now default) then automatically lock the + table. + +2008-12-21 07:59 t-ishii + + * pool_config.l (1.23): Now insert_lock is defaulted to be true + +2008-12-20 20:21 t-ishii + + * pool_process_query.c (1.125): Fix need_insert_lock() so that it + runs a little bit faster with no INSERT case. + +2008-12-20 20:12 t-ishii + + * pool_proto_modules.c (1.2): Enhance and fix comments related to + Query() + +2008-12-13 20:25 t-ishii + + * parser/gram.c (1.10, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0), + Makefile.am (1.21), Makefile.in (1.25), parser/gram.h (1.9, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0) (utags: V2_2_0_BETA1, + V2_2_0_BETA2, V2_2_0_RC1, V2_2_0_RC2): Update generated files + +2008-12-13 20:23 t-ishii + + * pool_process_query.c (1.124), pool_proto_modules.c (1.1), + pool_proto_modules.h (1.1, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1): Refactor + pool_process_query.c. Now it is devided into pool_process_query.c + and pool_proto_modules.c. Also pool_proto_modules.h added which is + a companion header file. + +2008-12-13 20:21 t-ishii + + * main.c (1.41): Fix comment + +2008-12-13 17:20 t-ishii + + * pool_process_query.c (1.123): Fix Execute() to avoid kind + mismatch error caused by "SET TRANSACTION ISOLATION LEVEL must be + called before any query". + +2008-12-13 17:13 t-ishii + + * pool_process_query.c (1.122): Avoid kind mismatch error caused by + "SET TRANSACTION ISOLATION LEVEL must be called before any query". + This could happen in following scenario: + + * M:S1:BEGIN; + * S:S1:BEGIN; + * M:S1:SELECT 1; <-- only sent to MASTER + * M:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + * S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + * M: <-- error + * S: <-- ok since no previous SELECT is sent. kind mismatch error + occurs! + + Fix ReadyForQuery() by calling pool_unread if backend after + do_error_command executed not returns read for query packet. + + Fix comments + +2008-12-08 22:48 t-ishii + + * pool_process_query.c (1.121): Check serialization failure error + and abort all nodes if so. Otherwise we allow data inconsistency + among DB nodes. See following scenario: (M:master, S:slave) + + M:S1:BEGIN; M:S2:BEGIN; S:S1:BEGIN; S:S2:BEGIN; M:S1:SET TRANSACTION + ISOLATION LEVEL SERIALIZABLE; M:S2:SET TRANSACTION ISOLATION LEVEL + SERIALIZABLE; S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + S:S2:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; M:S1:UPDATE t1 + SET i = i + 1; S:S1:UPDATE t1 SET i = i + 1; M:S2:UPDATE t1 SET i = + i + 1; <-- blocked S:S1:COMMIT; M:S1:COMMIT; M:S2:ERROR: could not + serialize access due to concurrent update S:S2:UPDATE t1 SET i = i + + 1; <-- success in UPDATE and data becomes inconsistent! + +2008-12-08 21:38 t-ishii + + * pool_process_query.c (1.120): Forget to add free_string() + +2008-12-08 21:32 t-ishii + + * pool_process_query.c (1.119): Fix uninitialized variable in + read_kind_from_backend. Also refactor to make it more effective and + readable. Add lots of comments and enhance error message to display + eacho kinds. + +2008-12-05 23:38 t-ishii + + * pool_process_query.c (1.118): Fix client_idle_limit_in_recovery + handling not to hang when goes into 2nd stage. Also fix grammatical + errors in comments. + +2008-11-27 09:30 t-ishii + + * pool_auth.c (1.13): Fix thoughtless coding in MD5 case checking. + We should have considered raw mode case. Bug pointed out by Duco + Fijma. See discussions below for more details. Subject: + [Pgpool-general] MD5 authentication in "raw mode" From: Duco Fijma + To: pgpool-general@pgfoundry.org Date: Tue, 25 Nov + 2008 13:29:39 +0100 + +2008-11-15 16:10 t-ishii + + * pool_process_query.c (1.117): Fix pool_discard_packet. Missing + statement in the last commit. + +2008-11-15 15:15 t-ishii + + * pool_process_query.c (1.116): Fix do_error_command. If mistakely + assumed that after sending an error query, always ReadyForQuery came + right after that. If some debugging or logging verboseness is set, + PostgreSQL might sends NOTICE before ReadyForQuery. + +2008-11-12 22:42 t-ishii + + * pool_process_query.c (1.115): Fix do_command in case of notice + message sent right after Complete command response. See threads in + pgpool-general: + + Subject: Re: [Pgpool-general] Pgpool-II - replication problems From: + "nir osovsky" + + for more details. + +2008-11-10 09:58 t-ishii + + * pool_process_query.c (1.114): Enhance error message in do_command + +2008-11-07 18:20 t-ishii + + * ChangeLog (1.35), Makefile.in (1.24), aclocal.m4 (1.16, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1), configure (1.25), pgpool.conf.sample + (1.23), pool.h (1.31), pool_config.c (1.25), pool_config.l + (1.22), pool_process_query.c (1.113), pool_stream.c (1.13), + doc/pgpool-en.html (1.32), doc/pgpool-ja.html (1.53), + parser/Makefile.in (1.16, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1), + pcp/Makefile.in (1.15, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1): Add + client_idle_limit_in_recovery + +2008-10-31 14:21 t-ishii + + * doc/load_balance.odp (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1): Add + a flow chart which explains load balance/replication/send to master + only is decided. + +2008-10-31 10:31 t-ishii + + * doc/: pgpool-en.html (1.31), pgpool-ja.html (1.52): Fix wording + Fix description for replicate_select and "condition for load + balance" section. + +2008-10-31 10:28 t-ishii + + * pgpool.conf.sample (1.22): Fix incorrect comment for + recovery_timeout + +2008-09-05 13:25 t-ishii + + * main.c (1.40): Fix and enhance comments + +2008-08-29 14:17 t-ishii + + * pool_process_query.c (1.112): Allow to load balance DECLARE, + FETCH and CLOSE. Also fix comments. + +2008-08-29 11:54 t-ishii + + * main.c (1.39): Fix bug in fork_a_child which mistakely closed + pipe fds which are not created yet at the startup time + +2008-08-28 21:37 t-ishii + + * pool_process_query.c (1.111): Fix/enhance log messages and + comments + +2008-08-28 21:35 t-ishii + + * main.c (1.38): + - Close all file descriptors when running in daemon mode. Otherwise + we inherit socket from apache when it's started by pgpoolAdmin. + This results in that port 80 is occupied for example. Pach + provided by Akio Ishida. Also add chdir("/"). This always good for + daemon programs. + + - Always fail over and restart all children. Before we do not + restart if master has not been changed. This was wrong. If we have + trouble with network cable or something, TCP/IP stack keeps on + retrying for long time and the only way to prevent it is restarting + process. + +2008-07-23 17:50 y-asaba + + * NEWS (1.23), configure (1.24), configure.in (1.22), + doc/pgpool-ja.html (1.51) (utags: V2_1_0): Prepare for 2.1. + +2008-07-08 16:53 y-mori + + * ChangeLog (1.34, V2_1_0), NEWS (1.22) (utags: V2_1_0_RC1): + Prepare for pgpool-II 2.1 RC1. + -add comment to ChangeLog NEWS + +2008-07-08 16:41 y-mori + + * NEWS (1.21): FIX indent + +2008-07-08 16:37 y-mori + + * doc/pgpool-ja.html (1.50, V2_1_0_RC1): Update release note + parallel query bug fix comment + +2008-07-08 16:21 y-asaba + + * Makefile.in (1.23, V2_1_0), aclocal.m4 (1.15, V2_1_0), configure + (1.23), configure.in (1.21), parser/Makefile.in (1.15, V2_1_0), + pcp/Makefile.in (1.14, V2_1_0) (utags: V2_1_0_RC1): Prepare for + pgpool-II 2.1 RC1. + +2008-07-04 22:00 y-mori + + * pool_rewrite_outfuncs.c (1.15, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1): FIX: query rewrite of DISTINCT ON + +2008-07-04 14:27 y-mori + + * pool.h (1.30, V2_1_0, V2_1_0_RC1), pool_process_query.c (1.110, + V2_1_0, V2_1_0_RC1), pool_rewrite_outfuncs.c (1.14), + pool_rewrite_query.c (1.10, V2_1_0, V2_1_0_RC1), pool_stream.c + (1.12, V2_1_0, V2_1_0_RC1): FIX: join partitioned tables + + Delete: pool_read_parallel + +2008-07-01 21:26 y-mori + + * pool_rewrite_outfuncs.c (1.13): fix: Converting JOIN expression + from USING to ON in query rewriting at parallel mode + +2008-06-30 16:05 y-mori + + * pool_process_query.c (1.109): Fix Hung up when two or more insert + statment was executed in parallel mode + +2008-05-30 16:18 y-asaba + + * pool_process_query.c (1.108): Fixed segfault if client protocol + was V2. + +2008-05-22 23:36 y-asaba + + * main.c (1.37, V2_1_0, V2_1_0_RC1): If a backend raised FATAL + error while health checking, do not send a Terminate message. + Because sending the message fails with EPIPE. + +2008-05-08 12:02 y-asaba + + * child.c (1.22, V2_1_0, V2_1_0_RC1): Fix segfault if all weight + values are zero and master node is down. Perf report by Michael + SALOMON. + +2008-05-04 14:04 y-asaba + + * sql/pgpool-recovery/pgpool-recovery.c (1.6, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1): Use snprintf(). + +2008-04-12 03:09 devrim + + * pgpool.spec (1.13, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1): Sync with community spec file. Fix + Requires: problem. + +2008-04-09 16:45 y-asaba + + * redhat/pgpool.init (1.4, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1): + * Remove non-ascii character. + * Fix the daemon stdio redirection. + + Per report by kabe-san. + +2008-04-09 16:03 y-asaba + + * sample/replicate_def_pgbench.sql (1.2, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1): Fix SQL error. + +2008-04-09 16:01 y-asaba + + * sql/system_db.sql (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1): Drop replicate_def table if exists. + +2008-04-09 15:26 devrim + + * redhat/pgpool.init (1.3): + - Honor /etc/sysconfig/pgpool settings. Previously we could never + customize PGPOOLPID=/var/run/pgpool.pid et al. + - Remaining hardcoded paths replaced by customizable variables + such as $PGPOOLCONF . + +2008-04-09 15:22 y-asaba + + * Makefile.am (1.20, V2_1_0, V2_1_0_RC1), Makefile.in (1.22): Add + sample/replicate_def_pgbench.sql into a release tar ball. + +2008-04-07 01:49 devrim + + * pgpool.spec (1.12): Update to 2.1 beta2 + +2008-04-04 13:32 y-asaba + + * NEWS (1.20), doc/pgpool-ja.html (1.49) (utags: V2_1_0_BETA2): + Update 2.1 release note. + +2008-04-03 22:10 y-asaba + + * pool_process_query.c (1.107, V2_1_0_BETA2): Fix hang up in + Execute. + + We sended a syntax error query to abort a transaction if + replicate_select was true. However, the query was sended over Query + message. In extended query mode, we *must* send the query over + Execute message. Because postgres discards messages until a Sync is + reached when an error is detected. + +2008-04-03 14:44 y-asaba + + * ChangeLog (1.33, V2_1_0_BETA2): Add. + +2008-04-03 14:30 y-asaba + + * pool_process_query.c (1.106): Do not close a internal transaction + when Sync message is received after receiving Parse message. This + hack is for PHP-PDO. + +2008-04-02 11:48 y-asaba + + * NEWS (1.19), doc/pgpool-ja.html (1.48): Update release note. + +2008-04-01 17:31 y-asaba + + * configure (1.22), configure.in (1.20) (utags: V2_1_0_BETA2): + Prepare for 2.1 beta2. + +2008-04-01 10:12 y-asaba + + * pool_rewrite_outfuncs.c (1.12, V2_1_0_BETA2): Fix "AS" handling + in FROM clause. Patch contributed by sho-san. + +2008-03-31 17:27 y-asaba + + * pgpool.8.in (1.4, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2): Enhance manpage. + patch contributed by kabe-san. + - no hypenation, no justify for better greppability + - have explicit subsection for [noargs], stop, switch for + readability + - some phrases rewritten to suit manpages + - add "-v" option + +2008-03-31 17:07 y-asaba + + * ChangeLog (1.32): Add items. + +2008-03-31 13:19 t-ishii + + * TODO (1.14, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2): Add Docs section + and add an item (writelibpcp docs) + +2008-03-31 11:56 y-asaba + + * NEWS (1.18), doc/pgpool-ja.html (1.47): Add a item into 2.1 + release note. + +2008-03-28 01:06 y-asaba + + * child.c (1.21), pool_hba.c (1.5, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1) (utags: V2_1_0_BETA2): Use child_exit() instead of + exit(). + +2008-03-28 01:04 y-asaba + + * pcp_child.c (1.11, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2), recovery.c (1.11) (utags: V2_1_0, + V2_1_0_BETA2, V2_1_0_RC1, V2_2_0_BETA1): Fix a race condition + between SIGUSR2 signal and pause(). + +2008-03-28 01:01 y-asaba + + * pool_connection_pool.c (1.12, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2): + Fix core dump with the following scenario. + 1. detach a node. + 2. create connection pool + 3. attach the node. + 4. reuse the connection pool + +2008-03-27 17:26 y-asaba + + * doc/pgpool-ja.html (1.46): Remove a wrong restriction. + +2008-03-27 16:54 y-asaba + + * doc/: pgpool-en.html (1.30, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2), + pgpool-ja.html (1.45), pgpool.css (1.6, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2), tutorial-en.html + (1.6, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2), tutorial-ja.html (1.5, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2): Add copyright. + +2008-03-27 16:24 y-asaba + + * doc/: tutorial-en.html (1.5), tutorial-ja.html (1.4): Add an + example to rotate pgpool log files. + +2008-03-27 11:53 y-asaba + + * pool_process_query.c (1.105): Improve network I/O routine. + +2008-03-27 11:51 t-ishii + + * doc/pgpool-en.html (1.29): Add description about the timing of + recovery command invocation + +2008-03-27 11:49 t-ishii + + * TODO (1.13): Add TODO items + +2008-03-26 18:18 t-ishii + + * doc/pgpool-ja.html (1.44): Add description about the timing of + recovery command invocation + +2008-03-25 14:15 t-ishii + + * TODO (1.12): Add more TODO + +2008-03-25 10:00 t-ishii + + * TODO (1.11): Translate into English + +2008-03-20 17:33 t-ishii + + * doc/: pgpool-en.html (1.28), pgpool-ja.html (1.43): Enhance + reset_query_list description. + +2008-03-20 16:33 t-ishii + + * doc/: pgpool-en.html (1.27), pgpool-ja.html (1.42): Add info + about pgpool-II download page. + +2008-03-18 17:39 y-asaba + + * pgpool.conf.sample (1.21, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2): + Remove ";" in recovery_timeout. + +2008-03-14 16:09 y-asaba + + * doc/: pgpool-en.html (1.26), pgpool-ja.html (1.41) (utags: + V2_1_0_BETA1): + * Changed title from README to user manual. + * Emphasized load balancing note. + +2008-03-14 16:06 y-asaba + + * doc/pgpool.css (1.5, V2_1_0_BETA1): Add

style. + +2008-03-14 15:57 y-asaba + + * NEWS (1.17, V2_1_0_BETA1): Reviewed. + +2008-03-14 15:53 y-asaba + + * doc/pgpool-en.html (1.25): Updated English documentation. + +2008-03-14 15:30 y-asaba + + * doc/pgpool-ja.html (1.40): Add recovery_timeout description. + +2008-03-14 14:45 y-asaba + + * NEWS (1.16): Added 2.1 beta release note. I hope to review it. + +2008-03-14 11:43 y-asaba + + * doc/pgpool-ja.html (1.39): Added 2.1 release note. + +2008-03-14 11:00 y-asaba + + * pgpool.conf.sample (1.20, V2_1_0_BETA1): Add comment for '%M' + format. + +2008-03-14 10:35 y-asaba + + * ChangeLog (1.31, V2_1_0_BETA1): Add entries. + +2008-03-13 22:11 y-asaba + + * pool_process_query.c (1.104, V2_1_0_BETA1): + * Fixed kind mismatch error in master slave mode with following + scenario. This bug was introduced in pgpool-II v2.0. + + BEGIN; + SET client_encoding TO SJIS; + + * Fixed load balancing in master slave mode. This bug was introduced + in pgpool-II v2.0. + +2008-03-13 16:01 y-asaba + + * pg_md5.c (1.3, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1): Fix compile error on FreeBSD. Per + report by ISHIDA Akio. + +2008-03-13 12:46 y-asaba + + * ylwrap (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1): Add ylwrap generated by automake + 1.10. + +2008-03-13 03:22 devrim + + * pgpool.spec (1.11, V2_1_0_BETA2, V2_1_0_BETA1): Update to 2.1 + beta1 + +2008-03-12 21:33 y-asaba + + * configure (1.21), configure.in (1.19) (utags: V2_1_0_BETA1): + Stamp beta1. + +2008-03-12 18:33 t-ishii + + * pgpool.conf.sample (1.19): Fix comments for load_balance_mode + which were no longer true. + +2008-03-12 18:32 y-asaba + + * pool_config.c (1.24, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1): Run flex v2.5.33 + +2008-03-12 18:32 y-asaba + + * version.h (1.4, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1): + Change version string. + +2008-03-12 18:31 y-asaba + + * child.c (1.20, V2_1_0_BETA1), pool_process_query.c (1.103): If + load_balance_mode is false, then pgpool does not calculate load + balancing node. + +2008-03-12 14:06 y-asaba + + * main.c (1.36, V2_1_0_BETA2, V2_1_0_BETA1): health_check_timeout + did not work correctly. Report and patch by Kenichi Sawada. + +2008-03-12 14:00 y-asaba + + * main.c (1.35): Improve bind(2) and unlink(2) error message. + Patch contributed by Jun Kuriyama. + +2008-03-12 13:53 y-asaba + + * pcp/pcp_recovery_node.c (1.3, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1): Fix typos in pcp_recovery_node.c usage. Patch + contributed by Jun Kuriyama. + +2008-03-12 13:51 y-asaba + + * Makefile.in (1.21, V2_1_0_BETA2, V2_1_0_BETA1), aclocal.m4 (1.14, + V2_1_0_BETA2, V2_1_0_BETA1), config.h.in (1.6, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), configure (1.20), + configure.in (1.18), parser/Makefile.in (1.14, V2_1_0_BETA2, + V2_1_0_BETA1), pcp/Makefile.in (1.13, V2_1_0_BETA2, + V2_1_0_BETA1): Support set_ps_display on FreeBSD. Patch + contributed by ISHIDA Akio. + +2008-03-12 12:54 t-ishii + + * pool_auth.c (1.12, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1): Add detailed error messages when auth phase fail. + Current messages: + + pool_read_message_length: message length (8 ) in slot 1 does not + match with slot 0(12) + + is confusing and does very little help. + +2008-03-12 11:01 y-asaba + + * pool_process_query.c (1.102): Fixed DEALLOCATE ALL processing. + +2008-03-11 12:04 y-asaba + + * ChangeLog (1.30): Added entries. + +2008-03-11 11:54 y-asaba + + * main.c (1.34), doc/pgpool-en.html (1.24), doc/pgpool-ja.html + (1.38): + * Add '%M'format to obtain old master node ID into failover_command + and failback_command. + + * When master node was down, killed all children process during + executing failover_command. + + * Fixed SIGSEGV if backend0 was undefined. + +2008-03-11 11:49 y-asaba + + * pool_process_query.c (1.101): Fixed hang up if a node was + executed immediate shutdown. + +2008-03-11 00:08 t-ishii + + * pool_auth.c (1.11): Fix using uninialized varible in + pool_read_message_length() + +2008-03-10 13:37 t-ishii + + * pool_process_query.c (1.100): [no log message] + +2008-03-04 16:58 y-asaba + + * ChangeLog (1.29): Add entries. + +2008-03-03 12:39 y-asaba + + * pool_process_query.c (1.99): Fix hang up after processing "show + pool_status". Per report by ISHIDA Akio. + +2008-02-29 13:49 yamaguti + + * ChangeLog (1.28): added entry for the change in pg_md5.c + +2008-02-29 13:40 yamaguti + + * pg_md5.c (1.2): + * implement password prompt with option "-p" (patch contributed by + Volkan Yazici) + + * disable ECHO while reading password from stdin + +2008-02-26 18:55 y-asaba + + * main.c (1.33): + - Add comment. + - Add -v option, which prints version info. + +2008-02-25 20:22 y-asaba + + * recovery.c (1.10, V2_1_0_BETA1): Improve error message. + +2008-02-25 11:58 y-asaba + + * pool_process_query.c (1.98): Fix asynchronous query handling. + + When ReadyForQuery message was received, pgpool set off + loadbalancing flag, internal transaction flag and so on. If client + sended a Query message before receiving the ReadyForQuery message, + pgpool reported error message. + + So, we block the Query message while backend nodes process a query. + +2008-02-20 19:12 y-asaba + + * pool_process_query.c (1.97): Return TRUE in is_select_query() if + a query is "COPY TO STDOUT". kind mismatching error was caused by + pg_dump or pg_dumpall. Per report by Bruno Lustosa. + +2008-02-19 14:54 y-asaba + + * Makefile.in (1.20), aclocal.m4 (1.13), configure (1.19), + configure.in (1.17): Stamp 2.1-devel. We hope to release 2.1 on + March. + +2008-02-19 14:46 y-asaba + + * pool_process_query.c (1.96): Fix HINT clause handling in extended + query protocol. pgpool did not replicate the following query with + extended query protocol. + + /* REPLICATION */ SELECT func(); + + Per report by Sagar Thapa. + +2008-02-19 14:18 y-asaba + + * pool_process_query.c (1.95): Fix misspell. Patch contributed by + Jun Kuriyama. + +2008-02-18 18:58 y-asaba + + * pool_stream.c (1.11, V2_1_0_BETA2, V2_1_0_BETA1): Add error + checking. + +2008-02-15 18:43 y-asaba + + * main.c (1.32): Polling signals per 3 secs when health check is + disabled. + +2008-02-15 18:36 y-asaba + + * main.c (1.31): Fix zombie process problem. "switching" flag did + not clear when invalid node ID was detached. + +2008-02-15 15:19 y-asaba + + * pool_process_query.c (1.94): Fix DISCARD statement handling. + +2008-02-15 13:04 y-asaba + + * main.c (1.30): Fix compiler warning. + +2008-02-14 14:48 y-asaba + + * main.c (1.29): Add comment. + +2008-02-14 14:24 y-asaba + + * ChangeLog (1.27): Add ChangeLog items. + +2008-02-14 14:09 y-asaba + + * main.c (1.28): Fix a failover bug that pgpool did not determine a + next master node in raw_mode. + +2008-02-14 14:05 y-asaba + + * pool_connection_pool.c (1.11, V2_1_0_BETA1): Do not create + connection cache to standby nodes in raw_mode. As a result, we can + use pgpool-II + warm standby with raw_mode. + +2008-02-12 20:16 y-asaba + + * child.c (1.19), pgpool.conf.sample (1.18), pool.h (1.29, + V2_1_0_BETA2, V2_1_0_BETA1), pool_config.c (1.23), pool_config.l + (1.21, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pool_process_query.c (1.93), pool_stream.c (1.10), + doc/pgpool-en.html (1.23), doc/pgpool-ja.html (1.37): Remove + "replication_timeout" parameter. + + This parameter was enabled if replication_strict = false. However + replication_strict was already removed. + +2008-02-12 16:29 yamaguti + + * pool.h (1.28): Fix a bug in raw mode where only 1 of multiple + nodes were recognized by pgpool. + +2008-02-08 19:57 y-asaba + + * pool_stream.c (1.9): Fix wrong timeout handling in pool_read2() + and pool_read_string(). + +2008-02-08 17:10 yamaguti + + * pcp/pcp.c (1.7, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1): + Disabled PCP client's timeout. + + PCP commands still take timeout option, but ignores and set + notimeout. + +2008-02-08 15:47 y-asaba + + * sql/pgpool-recovery/pgpool-recovery.c (1.5, V2_1_0_BETA2, + V2_1_0_BETA1): PostgreSQL superuser can *only* execute + pgpool_recovery and pgpool_remote_start functions because of + security issue. + +2008-02-08 15:47 yamaguti + + * main.c (1.27), pcp_child.c (1.10, V2_1_0_BETA1), recovery.c + (1.9): Implemented configuration file "reload" function into PCP. + +2008-02-08 13:11 yamaguti + + * recovery.c (1.8): Use "recovery_timeout" to decide how long + pgpool should wait before online-recovery fails. + +2008-02-08 13:10 yamaguti + + * pgpool.conf.sample (1.17), pool.h (1.27), pool_config.c (1.22), + pool_config.l (1.20): added a new configuration parameter + "recovery_timeout". + + pgpool waits so many seconds, specified by recovery_timeout, for: + + 1) all client connections are closed before the 2nd stage + 2) a remote host to start up in the final stage + + Note that "recovery_timeout = 0" means NO WAIT; not no timeout. + +2008-02-05 19:05 y-asaba + + * pool_auth.c (1.10): Fix minor bug introduced by previous commit. + +2008-02-05 18:57 y-asaba + + * pool_auth.c (1.9): Fix authentication error when master was down. + +2008-02-05 11:13 y-asaba + + * pool_process_query.c (1.92): Remove unneccesary flushing output + buffer. + +2008-01-29 11:01 y-asaba + + * doc/pgpool-ja.html (1.36): Add description of recovery script. + +2008-01-29 10:56 y-asaba + + * ChangeLog (1.26), child.c (1.18), main.c (1.26), pcp_child.c + (1.9), pool.h (1.26), pool_auth.c (1.8), pool_config.c (1.21), + pool_config.l (1.19), pool_connection_pool.c (1.10), pool_error.c + (1.3, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pool_hba.c (1.4, V2_1_0_BETA1), pool_ip.c (1.2, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pool_ip.h (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pool_ipc.h (1.3, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pool_params.c (1.3, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pool_path.c + (1.2, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pool_path.h (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pool_process_query.c (1.91), pool_query_cache.c (1.9, V2_2_3, + V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pool_rewrite_query.c (1.9, V2_1_0_BETA2, V2_1_0_BETA1), + pool_rewrite_query.h (1.6, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pool_sema.c (1.4, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1), pool_shmem.c (1.3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pool_signal.c + (1.3, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pool_signal.h (1.4, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pool_stream.c (1.8), pool_system.c (1.5, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pool_type.h + (1.8, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + ps_status.c (1.2, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), recovery.c (1.7), strlcpy.c (1.2, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + COPYING (1.3, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pcp/Makefile.in (1.12), pcp/pcp.c (1.6), pcp/pcp.h + (1.3, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pcp/pcp_attach_node.c (1.2, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/Makefile.in (1.13), parser/copyfuncs.c + (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1), parser/gram.c (1.9, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pcp/pcp_detach_node.c + (1.2, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pcp/pcp_error.c (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pcp/pcp_node_count.c + (1.2, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pcp/pcp_node_info.c (1.2, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pcp/pcp_proc_count.c (1.3, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1), pcp/pcp_proc_info.c (1.2, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), pcp/pcp_recovery_node.c + (1.2), pcp/pcp_stop_pgpool.c (1.2, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1), pcp/pcp_stream.c (1.4, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), pcp/pcp_stream.h (1.2, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + pcp/pcp_systemdb_info.c (1.2, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), sql/pgpool-recovery/pgpool-recovery.c (1.4), + parser/gram.h (1.8, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/gram.y (1.5, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/keywords.c (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), parser/keywords.h (1.3, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/list.c (1.3, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/makefuncs.c (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), parser/makefuncs.h (1.3, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/memnodes.h (1.2, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/nodes.c (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), parser/nodes.h (1.3, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/outfuncs.c (1.6, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/parsenodes.h (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), parser/parser.h (1.3, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/pg_list.h (1.3, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/pool_memory.c (1.10, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/pool_memory.h (1.5, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/pool_parser.h (1.5, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/pool_string.c (1.4, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/pool_string.h (1.4, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/primnodes.h (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), parser/scan.c (1.8, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/scan.l (1.5, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), + parser/scansup.h (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1), parser/value.c (1.3, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/value.h (1.3, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1): + Update copyright. + +2008-01-28 11:31 y-asaba + + * ChangeLog (1.25): Add item. + +2008-01-28 11:26 y-asaba + + * pool_process_query.c (1.90): Change log level of the following + message from ERROR to LOG. + + ProcessFrontendResponse: failed to read kind from frontend. fronend + abnormally exited + + This means that pgpool detects unexpected EOF. This is not pgpool's + error. + +2008-01-25 18:49 y-asaba + + * ChangeLog (1.24): Add item. + +2008-01-25 16:20 y-asaba + + * pool_process_query.c (1.89): Load balancing node was changed + after processing transaction. For example, + + SELECT 1; <-- node 1 + BEGIN; + SELECT 2; <-- node 0(master) + END; + SELECT 3; <-- node 0(master) + + "SELECT 3" was sended to a master node, not a load balancing node. + + VALID_BACKEND macro does not check node validation if + in_load_balancing is 1. So we do not use VALID_BACKEND macro to + check whether load balancing node is down. + +2008-01-19 18:49 y-asaba + + * pool_process_query.c (1.88): Add comments. + +2008-01-15 11:10 y-asaba + + * pool_process_query.c (1.87): Remove unused variable. + +2008-01-11 12:11 y-asaba + + * pool_process_query.c (1.86): Add comments. + +2008-01-11 11:30 y-asaba + + * ChangeLog (1.23), main.c (1.25), pool_hba.c (1.3), + pool_process_query.c (1.85), parser/parser.c (1.5, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1), parser/pool_memory.c (1.9), parser/pool_memory.h + (1.4): Fix memory leak at prepared statement list. + + pgpool caches a parse tree in prepared statement list. The parse + tree copy deeply, but we freed only the top node of the parse tree. + +2008-01-09 18:10 y-asaba + + * recovery.c (1.6): Refactoring recovery code. + +2008-01-08 13:31 y-asaba + + * main.c (1.24): Fix compile error. + +2008-01-08 11:20 y-mori + + * doc/: tutorial-en.html (1.4), tutorial-ja.html (1.3) (utags: + V2_1_0_BETA1): FIX tutorial + Because replicate_def table is confused dist_def table when a + parallel mode is set according to the tutorial, data is not + divided. + +2008-01-02 17:32 t-ishii + + * main.c (1.23): Fix bug in previous commit Fix typo + +2007-12-27 12:00 y-asaba + + * ChangeLog (1.22): Add ChangeLog items. + +2007-12-27 11:21 y-asaba + + * main.c (1.22), pgpool.conf.sample (1.16), doc/pgpool-en.html + (1.22), doc/pgpool-ja.html (1.35): Allow '%m' character to obtain + master node id in failover_command and failback_command. + +2007-12-26 16:05 y-asaba + + * doc/: pgpool-en.html (1.21), pgpool-ja.html (1.34): Add + multi-statement restriction. + +2007-12-26 11:40 y-asaba + + * pool_process_query.c (1.84): Fix internal transaction handling in + extended query protocol. pgpool did not send "COMMIT" to close an + internal transaction block. + +2007-12-22 09:11 t-ishii + + * recovery.c (1.5): Add lots of pool_log to show the recovery steps + +2007-12-11 12:59 t-ishii + + * main.c (1.21): Change "starting health checking" and "retrying %d + th health checking" log messages to DEBUG messages since they are + too verbose. + +2007-12-07 15:35 y-asaba + + * TODO (1.10, V2_1_0_BETA1): TODO: Add replication function list. + +2007-12-07 14:08 y-asaba + + * child.c (1.17), config.h.in (1.5), configure (1.18), configure.in + (1.16), pcp_child.c (1.8), pool_config.c (1.20), pool_config.l + (1.18), pcp/pcp.c (1.5): Fix compile error and warning on Solaris + 10. + +2007-12-06 13:59 y-mori + + * pool_rewrite_query.c (1.8): FIX: INSERT statment in a parallel + mode How to count the Value Clause list was wrong + +2007-12-05 17:15 y-asaba + + * pool_stream.c (1.7): Improve buffering algorithm in pool_write(). + +2007-12-03 10:47 y-asaba + + * pool_process_query.c (1.83): Don't output log if PostgreSQL send + a warning message in do_command(). + +2007-12-02 11:45 y-asaba + + * pool_process_query.c (1.82): Fix segmentation fault if + CloseComplete command was received. + +2007-12-01 23:50 y-asaba + + * pool_process_query.c (1.81): Fix memory leak when PREPARE or + DEALLOCATE is failed. + +2007-12-01 22:26 y-asaba + + * pool_process_query.c (1.80): Remove debug log. + +2007-11-30 16:38 y-mori + + * pool_rewrite_query.c (1.7): Fix: The INSERT statment did not + correspond to the parser of postgresql 8.3 that pgpool-II 2.0 had. + Therefore, the following errors occur if INSERT is done in a + parallel mode + + ERROR: pgpool2 sql restriction + DETAIL: cannot use SElectStmt in InserStmt + +2007-11-24 22:04 t-ishii + + * doc/: pgpool-en.html (1.20), pgpool-ja.html (1.33): Fix english + docs. Add a link to tutorial. + +2007-11-23 09:14 t-ishii + + * pool_config.c (1.19), pool_config.l (1.17): Add missing + replicate_select entry. per bug report on [pgsql-jp: 38968]. + +2007-11-22 04:35 devrim + + * pgpool.spec (1.10): Update to 2.0.1 + +2007-11-21 19:18 y-asaba + + * configure (1.17), configure.in (1.15) (utags: V2_0_1): Prepare + for 2.0.1. + +2007-11-21 19:09 y-asaba + + * NEWS (1.15), doc/pgpool-ja.html (1.32) (utags: V2_0_1): Release + note for pgpool-II 2.0.1. + +2007-11-21 18:39 y-asaba + + * ChangeLog (1.21, V2_0_1): update. + +2007-11-21 18:37 y-asaba + + * pool_process_query.c (1.79, V2_0_1): Fix segmentation fault when + UPDATE or DELETE is executed. The bug is critical so we must + release 2.0.1 as soon as possible. + +2007-11-21 13:47 y-asaba + + * recovery.c (1.4, V2_0_1): Use snprintf() instead of sprintf(). + +2007-11-21 10:47 y-asaba + + * pool_process_query.c (1.78): Send a syntax error query to a + master node when master_slave is true. + +2007-11-16 14:29 y-mori + + * doc/: pgpool-en.html (1.19, V2_0_1), pgpool-ja.html (1.31) + (utags: V2_0_0): ADD: documents (Setting method of Query cache) + +2007-11-16 11:52 y-asaba + + * pool_auth.c (1.7, V2_0_1, V2_0_0): Fix segmentation fault in a + password authentication when a node is down. + +2007-11-16 10:56 y-asaba + + * ChangeLog (1.20, V2_0_0): pgpool-II 2.0 + +2007-11-16 10:51 y-asaba + + * Makefile.in (1.19, V2_0_1), aclocal.m4 (1.12, V2_0_1), configure + (1.16), parser/Makefile.in (1.12, V2_0_1), parser/gram.c (1.8, + V2_0_1), parser/gram.h (1.7, V2_0_1), pcp/Makefile.in (1.11, + V2_0_1) (utags: V2_0_0): Prepare for pgpool-II 2.0. + +2007-11-16 10:39 y-asaba + + * doc/: pgpool-en.html (1.18), pgpool-ja.html (1.30): + - Fix the sample script of online recovery. + - Add note about timeout of pcp_recovery_node. + +2007-11-16 09:20 gleu + + * doc/pgpool-en.html (1.17): Typo fix. + +2007-11-15 09:39 y-mori + + * pool_rewrite_outfuncs.c (1.11, V2_1_0_BETA1), + pool_rewrite_query.h (1.5) (utags: V2_0_0, V2_0_1): FIX: It + corresponed to the following Queries. ex) select * from (select + a,b,c from t1) as t2(d,e,f) ~~~~~ + +2007-11-14 16:46 y-mori + + * pool_process_query.c (1.77, V2_0_0): FIX: The load-balnace was + not functioning in a parallel mode + +2007-11-14 13:59 y-mori + + * pool_rewrite_outfuncs.c (1.10): FIX: + It made a mistake in the processing of OUTER JOIN (syntax of C + lang) + +2007-11-14 12:59 y-mori + + * pool.h (1.25, V2_0_1, V2_0_0), pool_process_query.c (1.76), + pool_stream.c (1.6, V2_0_1, V2_0_0): fix: + -When the setting of replication_timeout was effective, + SELECT that the execution time is long did the time-out + in only a parallel mode. + + -A wrong number was displayed when replicated table was + updated or deleted in only a parallel mode. + +2007-11-13 10:44 y-asaba + + * configure.in (1.14, V2_0_0): Prepare for pgpool-II 2.0. + +2007-11-13 03:12 devrim + + * doc/pgpool-en.html (1.16): Removed some garbage chars Fixed + indendation of some paragraphs Fixed some typos + + There seems a lot to do btw. + +2007-11-12 18:04 y-asaba + + * NEWS (1.14, V2_0_0), doc/pgpool-ja.html (1.29): Prepare for + pgpool-II 2.0. + +2007-11-12 18:02 y-asaba + + * doc/pgpool-ja.html (1.28): Fix typo. + +2007-11-12 17:34 y-mori + + * doc/tutorial-en.html (1.3, V2_0_1, V2_0_0): add: pgpoo-II 2.0 + tutorial -parallel-query section + +2007-11-12 15:40 y-mori + + * doc/: pgpool-en.html (1.15), pgpool-ja.html (1.27): add: + pgpool-II 2.0 manual. + -add parallel-query section + + fix: + Japanese manual. + - typo + +2007-11-09 16:25 y-mori + + * doc/: pgpool-ja.html (1.26), pgpool.css (1.4, V2_0_1, V2_0_0), + tutorial-ja.html (1.2, V2_0_1, V2_0_0): pgpoo-ll 2.0 manual & + tutorial (Japanese) + - Add parallel query section + +2007-11-09 15:09 y-mori + + * sample/replicate_def_pgbench.sql (1.1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0): ADD Sample SQL file + +2007-11-09 13:56 y-mori + + * sql/system_db.sql (1.2, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, + V2_0_0): ADD "replicate_def" table in "pgpool_catalog" schema + +2007-11-09 13:41 y-asaba + + * pgpool.8.in (1.3, V2_1_0_BETA1, V2_0_1, V2_0_0): Add reload + option. + +2007-11-09 13:37 y-asaba + + * main.c (1.20, V2_0_1, V2_0_0): Add pgpool reload in usage(). + +2007-11-09 12:00 y-asaba + + * Makefile.am (1.19), test/jdbc/README.euc_jp (1.1, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1) (utags: V2_0_0, V2_0_1, V2_1_0_BETA1, + V2_1_0_BETA2): Add README.euc_jp + +2007-11-08 10:43 y-asaba + + * doc/pgpool-en.html (1.14): pgpool-II 2.0 manual. + - Add online recovery section. + - Add new parameters. + + TODO: review my English... + +2007-11-07 19:05 y-asaba + + * pool_process_query.c (1.75): Send Sync message before calling + insert_lock(). + +2007-11-07 15:35 y-mori + + * pool_rewrite_outfuncs.c (1.9): fix: join rule for /*NOT*/SQL99 + type join,CROSS JOIN and NATURAL JOIN + +2007-11-06 16:07 y-asaba + + * test/jdbc/InsertTest.java (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + test/jdbc/RunTest.java (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + test/jdbc/pgpool.properties (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + test/jdbc/prepare.sql (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + test/jdbc/expected/insert (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + Makefile.am (1.18): Add INSERT statement test. + +2007-11-05 14:26 y-asaba + + * pool_process_query.c (1.74): Fix insert_lock with extended query + protocol. + +2007-11-05 11:08 y-asaba + + * pool_process_query.c (1.73): Use FD_SETSIZE instead of 1024 at + set_fd, isset_fd and zero_fd. + +2007-11-05 10:41 y-asaba + + * pool_process_query.c (1.72): Ignore white space in + need_insert_lock(). + +2007-11-02 18:20 y-mori + + * pool_process_query.c (1.71): Fix: compile error at FreeBSD4.1 + +2007-11-02 01:57 devrim + + * pgpool.spec (1.9, V2_0_1, V2_0_0): Update spec file for 2.0 beta1 + +2007-11-01 19:14 y-asaba + + * Makefile.am (1.17): Fix compile error with SUN's cc. + +2007-11-01 19:11 y-asaba + + * configure.in (1.13), pool_process_query.c (1.70), + parser/Makefile.am (1.4, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + pcp/Makefile.am (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0): Fix + compile error with SUN's cc. + +2007-11-01 17:17 y-asaba + + * pcp/pcp_proc_count.c (1.2, V2_0_1, V2_0_0): Fix warning with + SUN's cc. + +2007-11-01 11:08 t-ishii + + * Makefile.in (1.18, V2_0_0_BETA1): Rerun autoconf + +2007-11-01 11:01 y-asaba + + * Makefile.am (1.16, V2_0_0_BETA1): Remove test.diff + +2007-11-01 10:45 t-ishii + + * Makefile.in (1.17), aclocal.m4 (1.11, V2_0_0_BETA1), configure + (1.15, V2_0_0_BETA1), pool_config.c (1.18, V2_0_1, V2_0_0, + V2_0_0_BETA1), parser/Makefile.in (1.11, V2_0_0_BETA1), + pcp/Makefile.in (1.10, V2_0_0_BETA1): Run autoconf + +2007-10-31 19:45 y-asaba + + * NEWS (1.13), pgpool.conf.sample (1.15, V2_0_1, V2_0_0), pool.h + (1.24), pool_config.l (1.16, V2_0_1, V2_0_0), + pool_process_query.c (1.69), doc/pgpool-en.html (1.13), + doc/pgpool-ja.html (1.25) (utags: V2_0_0_BETA1): Remove + replicate_strict derective. pgpool-II 2.x always set to true. + +2007-10-31 19:13 y-asaba + + * ChangeLog (1.19, V2_0_0_BETA1): pgpool-II 2.0 beta1 + +2007-10-31 18:41 y-mori + + * test/pdo-test/README.euc_jp (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1): ADD: pdo test program manual(Japanese) + +2007-10-31 15:10 y-asaba + + * doc/pgpool-ja.html (1.24): Add comments about reloadable + derectives. + +2007-10-31 13:15 y-asaba + + * pool_config.l (1.15): Allow to reload pcp_timeout. + +2007-10-31 12:49 y-mori + + * pool_rewrite_outfuncs.c (1.8, V2_0_0_BETA1): FIX: "IN" predicate + at query rewriting + +2007-10-31 12:31 y-asaba + + * NEWS (1.12): pgpool-II 2.0(beta1) release note. + +2007-10-30 21:44 t-ishii + + * pool_auth.c (1.6, V2_0_0_BETA1): Fix confusing variable name + Enhance error message Check unsupported auth method + +2007-10-30 16:13 y-asaba + + * pool_process_query.c (1.68): Fix segfault with "SHOW + pool_status". + +2007-10-30 16:09 y-asaba + + * Makefile.am (1.15): Remove gprof option. + +2007-10-30 15:58 y-asaba + + * doc/: pgpool-ja.html (1.23), pgpool.css (1.3, V2_0_0_BETA1): + Improve online-recovery documentation. + +2007-10-30 11:35 y-asaba + + * configure.in (1.12, V2_0_0_BETA1): Prepare for pgpool-II 2.0 + beta1. + +2007-10-30 11:11 y-asaba + + * pool_auth.c (1.5): Previous commit did not support V2 protocol. + +2007-10-30 10:53 y-asaba + + * pool_auth.c (1.4): Send the following error message to frontend + if client auth method is md5 password in replication, master-slave + and parallel modes. + + MD5 authentication is unsupported in replication, master-slave and + parallel modes. + +2007-10-29 17:12 y-asaba + + * Makefile.am (1.14): Merge V1_STABLE branch. + +2007-10-29 15:55 y-asaba + + * pgpool.spec (1.8, V2_0_0_BETA1): Merge V1_STABLE branch. + +2007-10-29 15:28 y-asaba + + * redhat/: pgpool.init (1.2), pgpool.sysconfig (1.2, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1) (utags: V2_0_0, + V2_0_0_BETA1, V2_0_1, V2_1_0_BETA1, V2_1_0_BETA2): Merge redhat + scripts from V1_STABLE branch. + +2007-10-29 15:09 y-asaba + + * doc/pgpool-ja.html (1.22): Fix insert_lock description. + +2007-10-29 14:52 y-asaba + + * doc/pgpool-ja.html (1.21): Add new directives and update + description of online recovery. + +2007-10-29 14:50 y-asaba + + * pgpool.conf.sample (1.14), pool.h (1.23), pool_config.l (1.14), + pool_process_query.c (1.67), recovery.c (1.3, V2_0_0, + V2_0_0_BETA1): Add new directives "recovery_1st_stage_command" + and "recovery_2nd_stage_command". + + pgpool don't block client connections and data update operations + while executing recovery_1st_stage_command. In + recovery_2nd_stage_command, pgpool block them. + + If you recover by PITR, the first stage command get a base backup. + Then you switch XLOG in the second stage command. + +2007-10-29 13:37 y-asaba + + * sql/pgpool-recovery/: pgpool-recovery.c (1.3), + pgpool-recovery.sql.in (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1) (utags: V2_0_0, + V2_0_0_BETA1, V2_0_1): Change pgpool_recovery signature from + pgpol_recovery(text, text) to pgpool_recovery(text, text, text). The + first argument is script name. + + * pgpool_recovery arguments: + #1: script name + #2: remote host name + #3: remote database cluster path + + return value: + command status (= "$?" value) + +2007-10-29 13:16 y-mori + + * pool_process_query.c (1.66), pool_rewrite_outfuncs.c (1.7), + pool_rewrite_query.h (1.4, V2_0_0_BETA1), parser/outfuncs.c (1.5, + V2_0_1, V2_0_0, V2_0_0_BETA1): add optimization of aggregate + function and group by clause in parallel mode + +2007-10-29 10:20 t-ishii + + * Makefile.in (1.16), pgpool.conf.sample (1.13), pool.h (1.22), + pool_config.c (1.17), pool_config.l (1.13), pool_process_query.c + (1.65), parser/gram.c (1.7, V2_0_0_BETA1), parser/scan.c (1.7, + V2_0_1, V2_0_0, V2_0_0_BETA1): Change child_idle_limit to + client_idle_limit + +2007-10-26 20:28 y-asaba + + * pool_process_query.c (1.64): All signals are blocked while + sending a "COMMIT" command. + +2007-10-26 16:41 y-asaba + + * pool_process_query.c (1.63): Check return value of pool_flush(). + +2007-10-23 16:32 y-asaba + + * sql/pgpool-recovery/pgpool-recovery.c (1.2): Change error + message. + +2007-10-23 13:44 y-asaba + + * Makefile.am (1.13), doc/pgpool-ja.html (1.20), + sample/pgpool_recovery_pitr (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1): Add online recovery script using pitr. + +2007-10-22 17:59 y-asaba + + * test/jdbc/.cvsignore (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1): Add .cvsignore file. + +2007-10-22 17:55 y-asaba + + * Makefile.am (1.12): Add test/jdbc/* into tar ball. + +2007-10-22 17:47 y-asaba + + * test/jdbc/: AutoCommitTest.java (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0), BatchTest.java (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0), ColumnTest.java (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0), LockTest.java (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0), PgpoolTest.java (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0), RunTest.java (1.1), SelectTest.java (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0), UpdateTest.java (1.1, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0), pgpool.properties (1.1), + prepare.sql (1.1), run.sh (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + expected/autocommit (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + expected/batch (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + expected/column (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + expected/lock (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + expected/select (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0), + expected/update (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0) (utags: + V2_0_0_BETA1): Add test program using Java+JDBC driver. + +2007-10-22 13:23 y-asaba + + * NEWS (1.11), doc/pgpool-ja.html (1.19): Merge from V1_STABLE + branch. + +2007-10-18 18:55 y-asaba + + * pool_query_cache.c (1.8, V2_0_1, V2_0_0, V2_0_0_BETA1): Although + the second argument of PQunescapeBytea() requires size_t which size + is 8 byte in 64bit machine, pgpool passed 4 byte variable. It + caused segfault. So fixed passing size_t variable. + +2007-10-18 18:52 y-mori + + * test/pdo-test/: collections.inc (1.1), def.inc (1.1), log.txt + (1.1), pdotest.php (1.1), regsql.inc (1.1), SQLlist/test1.sql + (1.1), SQLlist/test2.sql (1.1), mod/database.inc (1.1), + mod/def.inc (1.1), mod/errorhandler.inc (1.1) (utags: V2_0_0, + V2_0_0_BETA1, V2_0_1, V2_1_0, V2_1_0_BETA1, V2_1_0_BETA2, + V2_1_0_RC1, V2_2_0, V2_2_0_BETA1, V2_2_0_BETA2, V2_2_0_RC1, + V2_2_0_RC2, V2_2_1, V2_2_2, V2_2_3, V2_2_4): ADD: extend protocol + test tool + +2007-10-18 17:24 y-asaba + + * sample/pgpool_recovery (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1): execute rsync as background jobs. + +2007-10-18 13:48 y-asaba + + * sample/pgpool_recovery (1.2): + * Add --update option. + * Sync pg_twophase directory. + +2007-10-18 11:54 y-asaba + + * pool_process_query.c (1.62): Fix compile warning on Solaris. + +2007-10-18 10:21 y-asaba + + * pool_config.c (1.16), pool_config.l (1.12): Set failback_command + default value to empty string; + +2007-10-17 19:23 y-asaba + + * main.c (1.19, V2_0_0_BETA1): Fix segfault when failover_command + is empty. + +2007-10-17 15:31 y-mori + + * pool_rewrite_outfuncs.c (1.6): FIX: lost alias name of column in + query rewriting when it was used at GRUP BY CLAUSE..etc + +2007-10-17 12:00 y-mori + + * pool.h (1.21), pool_process_query.c (1.61), + pool_rewrite_outfuncs.c (1.5): Fix: compiler's warning + +2007-10-16 12:44 y-asaba + + * pool_process_query.c (1.60): Fix hang up in load balancing mode. + +2007-10-15 22:56 y-mori + + * pool_rewrite_outfuncs.c (1.4): fix Type Casting of Constant value + was not supported + +2007-10-15 21:56 y-mori + + * pool_process_query.c (1.59): FIX wrong file descriptor was used + at pool_prallel_exec + +2007-10-15 19:38 y-mori + + * pool_process_query.c (1.58), pool_rewrite_query.c (1.6, V2_0_1, + V2_0_0, V2_0_0_BETA1): FIX insert rule in parallel mode + +2007-10-15 19:20 y-asaba + + * test/parser/: expected/create.out (1.2), expected/select.out + (1.2), input/select.sql (1.3) (utags: V2_0_0, V2_0_0_BETA1, + V2_0_1, V2_1_0, V2_1_0_BETA1, V2_1_0_BETA2, V2_1_0_RC1, V2_2_0, + V2_2_0_BETA1, V2_2_0_BETA2, V2_2_0_RC1, V2_2_0_RC2, V2_2_1, + V2_2_2, V2_2_3, V2_2_4): Add test cases. + +2007-10-15 19:18 y-asaba + + * parser/outfuncs.c (1.4): Support interval operator. + +2007-10-15 18:51 y-asaba + + * parser/: gram.y (1.4), scan.l (1.4) (utags: V2_0_0, V2_0_0_BETA1, + V2_0_1): Fix core dump with the following SQL. + SELECT * FROM tbl LIMIT 1,0; + +2007-10-15 16:05 y-asaba + + * pool_process_query.c (1.57): Fix invalid memory access when + pgpool processed DEALLOCATE statement. + +2007-10-15 15:56 y-mori + + * pool_config.c (1.15), pool_process_query.c (1.56), + pool_rewrite_outfuncs.c (1.3), pool_rewrite_query.c (1.5), + pool_rewrite_query.h (1.3), pool_system.c (1.4, V2_0_1, V2_0_0, + V2_0_0_BETA1), pool_type.h (1.7, V2_0_1, V2_0_0, V2_0_0_BETA1): + ADD query rewriting to main trunc + +2007-10-15 15:11 y-asaba + + * parser/pool_memory.c (1.8, V2_0_1, V2_0_0, V2_0_0_BETA1): Fix + core dump with a large SQL. + +2007-10-12 21:27 t-ishii + + * pgpool.conf.sample (1.12), pool.h (1.20), pool_config.c (1.14), + pool_process_query.c (1.55), parser/scan.c (1.6): Add pool_status + entry for child_idle_limit Fix comments + +2007-10-12 18:15 y-asaba + + * pgpool.conf.sample (1.11): Add new directive + "authentication_timeout" into pgpool.conf.sample. + +2007-10-12 15:56 y-asaba + + * doc/pgpool-ja.html (1.18): Add authentication_timeout. + +2007-10-12 14:55 y-asaba + + * main.c (1.18): Fix compiler warning. + +2007-10-12 14:30 y-asaba + + * parser/: parser.c (1.4, V2_0_1, V2_0_0, V2_0_0_BETA1), + pool_parser.h (1.4, V2_0_1, V2_0_0, V2_0_0_BETA1), scan.l (1.3): + Fix scanner's error handling. If there was a unterminated + double-quote identifier, scanner entered infinite-loop. + +2007-10-12 13:51 y-asaba + + * child.c (1.16, V2_0_1, V2_0_0, V2_0_0_BETA1), pool.h (1.19), + pool_config.c (1.13), pool_config.l (1.11), pool_process_query.c + (1.54): Add new directive "authentication_timeout". The directive + means the maximum time in seconds to complete client authentication. + The default value is 60. + +2007-10-12 13:50 y-asaba + + * TODO (1.9, V2_0_1, V2_0_0, V2_0_0_BETA1): Remove some items. + +2007-10-12 13:39 y-asaba + + * test/parser/input/select.sql (1.2): Add test cases. + +2007-10-12 13:38 y-asaba + + * parser/outfuncs.c (1.3): Support for XmlExprt object. + +2007-10-12 13:35 y-asaba + + * pcp_child.c (1.7, V2_0_1, V2_0_0, V2_0_0_BETA1): recovery request + can be accepted only in replication mode. + +2007-10-12 13:34 t-ishii + + * Makefile.am (1.11), Makefile.in (1.15), pgpool.conf.sample + (1.10), pool.h (1.18), pool_config.c (1.12), pool_config.l + (1.10), pool_process_query.c (1.53), parser/Makefile.am (1.3, + V2_0_0_BETA1), parser/Makefile.in (1.10), parser/gram.c (1.6), + parser/gram.h (1.6, V2_0_0_BETA1): Add child_idle_limit. # If + child_idle_limit is n (n > 0), the child is forced to be # + disconnected after n seconds idle between transactions. # 0 means + no disconnect. + + Need to work on show pool_status and docs. + +2007-10-11 17:32 y-asaba + + * child.c (1.15), pool.h (1.17): Check startup packet length. If + the length is greater than 10,000 byte, pgpool reject the + connection. + +2007-10-11 10:49 y-asaba + + * TODO (1.8): Add graceful {shutodwn, attach, detach} into TODO + list. + + * TODO for TODO list translate Japanse into English. + +2007-10-04 13:17 y-asaba + + * doc/: pgpool-ja.html (1.17), pgpool.css (1.2): Update Japanse + manual. + - Add release note for pgpool-II 2.0 + - Add failover_command and failback_command description + +2007-10-04 12:00 y-asaba + + * doc/pgpool-en.html (1.12): Merge V1_STABLE branch. + +2007-10-04 11:36 y-asaba + + * version.h (1.3, V2_0_1, V2_0_0, V2_0_0_BETA1): Change + PGPOOLVERSION to "hikitsuboshi". + +2007-10-03 15:19 y-asaba + + * TODO (1.7): Remove TODO items. + +2007-10-03 14:21 y-asaba + + * pool_process_query.c (1.52): Reset a prepared statement list when + DISCARD ALL or DISCARD PLANS statement is completed. + +2007-10-03 13:52 y-asaba + + * test/parser/: README (1.2), run-test (1.2) (utags: V2_0_0, + V2_0_0_BETA1, V2_0_1, V2_1_0, V2_1_0_BETA1, V2_1_0_BETA2, + V2_1_0_RC1, V2_2_0, V2_2_0_BETA1, V2_2_0_BETA2, V2_2_0_RC1, + V2_2_0_RC2, V2_2_1, V2_2_2, V2_2_3, V2_2_4): Translate from + Japanese into English. + +2007-10-03 13:47 y-asaba + + * Makefile.am (1.10), Makefile.in (1.14), test/parser/.cvsignore + (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/Makefile (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), test/parser/README (1.1), test/parser/main.c (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/parse_schedule (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), test/parser/pool.h (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/run-test (1.1), + test/parser/expected/copy.out (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/expected/create.out + (1.1), test/parser/expected/cursor.out (1.1, V2_2_4, V2_2_3, + V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/expected/delete.out + (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/expected/drop.out (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/expected/insert.out + (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/expected/misc.out (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/expected/prepare.out + (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/expected/privileges.out (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/expected/select.out + (1.1), test/parser/expected/transaction.out (1.1, V2_2_4, V2_2_3, + V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/expected/update.out + (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/expected/var.out (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/input/alter.sql (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/input/copy.sql (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), test/parser/input/create.sql (1.1, V2_2_4, V2_2_3, + V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/input/cursor.sql (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/input/delete.sql (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/input/drop.sql (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/input/insert.sql (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/input/misc.sql (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/input/prepare.sql (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/input/privileges.sql + (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/input/select.sql (1.1), + test/parser/input/transaction.sql (1.1, V2_2_4, V2_2_3, V2_2_2, + V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, + V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, + V2_0_1, V2_0_0, V2_0_0_BETA1), test/parser/input/update.sql (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), + test/parser/input/var.sql (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1): Add SQL parser test. + +2007-10-03 13:25 y-asaba + + * Makefile.in (1.13), aclocal.m4 (1.10), config.sub (1.2, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), configure (1.14), + ltmain.sh (1.3, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), pool_hba.c (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + pool_process_query.c (1.51), pool_rewrite_outfuncs.c (1.2), + pool_rewrite_query.c (1.4), parser/Makefile.in (1.9), + parser/copyfuncs.c (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/gram.c (1.5), parser/gram.h (1.5), parser/gram.y (1.3), + parser/gramparse.h (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), parser/keywords.c (1.2, V2_0_1, V2_0_0, + V2_0_0_BETA1), parser/keywords.h (1.2, V2_0_1, V2_0_0, + V2_0_0_BETA1), parser/list.c (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/makefuncs.c (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/makefuncs.h (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/nodes.h (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/outfuncs.c (1.2), parser/parsenodes.h (1.2, V2_0_1, + V2_0_0, V2_0_0_BETA1), parser/parser.c (1.3), parser/parser.h + (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), parser/pg_list.h (1.2, + V2_0_1, V2_0_0, V2_0_0_BETA1), parser/pool_parser.h (1.3), + parser/primnodes.h (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/scan.c (1.5), parser/scan.l (1.2), parser/value.c (1.2, + V2_0_1, V2_0_0, V2_0_0_BETA1), parser/value.h (1.2, V2_0_1, + V2_0_0, V2_0_0_BETA1), pcp/Makefile.in (1.9): Import PostgreSQL + 8.3 SQL parser. The revision of gram.y is 2.603. + +2007-10-03 13:17 y-asaba + + * pgpool.conf.sample (1.9), pool_config.c (1.11), pool_config.l + (1.9): The default value of ignore_leading_white_space is true in + pgpool-II 2.x. + +2007-09-27 18:38 gleu + + * pool_process_query.c (1.50): Typo fix. + +2007-09-27 11:48 y-asaba + + * TODO (1.6): Remove TODO item. + +2007-09-27 11:46 y-asaba + + * pool_process_query.c (1.49): Call read_kind_from_backend() + function instead of pool_read_kind() in Execute(), Parse() and + SimpleForwardToFrontend(). + +2007-09-26 18:09 y-asaba + + * pool_process_query.c (1.48): Remove debug message. + +2007-09-26 17:56 y-asaba + + * pool_process_query.c (1.47): SET, PREPARE and DEALLOCATE + statements are replicated in master/slave mode. + +2007-09-26 14:29 y-asaba + + * main.c (1.17), pool.h (1.16), pool_process_query.c (1.46), + pool_stream.c (1.5, V2_0_0_BETA1): pgpool-II could not detach + multiple node when message kinds were mismatched. + + For example: + node-1(master): success + node-2: fail + node-3: success + node-4: fail + node-5: success + + node-2 was only detached. + + Now it determine detached nodes by "majority voting rule". And it + can detach them at the same time. + + For example: + node-1(master): success + node-2: fail + node-3: success + node-4: fail + node-5: success + + node-2 and node-4 are detached because they are minority. + + node-1(master): success + node-2: fail + node-3: fail + node-4: success + + The number of the group which gain "success" is same as the number + of the group which gain "fail". In this case, node-2 and node-3 are + detached because these don't belong to the group which master + belongs to. + +2007-09-26 12:32 y-asaba + + * pool_sema.c (1.3, V2_0_1, V2_0_0, V2_0_0_BETA1): Fix initializing + semaphore values. + +2007-09-16 11:08 y-asaba + + * pgpool.conf.sample (1.8): Add comments abount failover_command + and failback_command. + +2007-09-14 22:36 y-asaba + + * main.c (1.16), pgpool.conf.sample (1.7), pool.h (1.15), + pool_config.c (1.10), pool_config.l (1.8), pool_process_query.c + (1.45), parser/gram.c (1.4), parser/gram.h (1.4), parser/gram.y + (1.2), parser/pool_string.c (1.3, V2_0_1, V2_0_0, V2_0_0_BETA1), + parser/pool_string.h (1.3, V2_0_1, V2_0_0, V2_0_0_BETA1): Add + "failover_command" and "failback_command" directives. If failover + or failback occur, pgpool execute setting command by system(3). + These directives evaluate special characters with the following + rule. + + %d: node id + %h: backend's hostname + %p: backend's port number + %D: backend's data directory + + example) pgpool.conf: --- + failover_command = 'echo %h %p %D %d > /tmp/failover' + failback_command = 'echo %h %p %D %d > /tmp/failback' + + backend_hostname1 = 'localhost' + backend_port1 = 5433 + backend_weight1 = 1 + backend_data_directory1 = '/home/postgres/pgdata/data5433' --- + + When node 1 is down, pgpool execute the following failover command. + + failover localhost 5433 /home/postgres/pgdata/data5433 1 + + /tmp/failover is created. + + % cat /tmp/failover + failover localhost 5433 /home/postgres/pgdata/data5433 1 + +2007-09-14 20:11 y-asaba + + * child.c (1.14), pool.h (1.14), pool_process_query.c (1.44): Fix + hang up when load balancing node was down. + +2007-09-10 22:29 t-ishii + + * pool_process_query.c (1.43): Modfify pool_send_error_message() so + that it won't be blocked by sending packet to the closing frontend + connection. Also rename set_non_block() and unset_non_block() to + pool_sen_non_block() and pool_unset_non_block() respectively to make + them public functions. + +2007-09-10 22:25 t-ishii + + * child.c (1.13), pool.h (1.13): Modfify pool_send_error_message() + so that it won't be blocked by sending packet to the closing + frontend connection. Also rename set_non_block() and + unset_non_block() to pool_sen_non_block() and pool_unset_non_block() + respectively to make them public functions. + +2007-09-10 21:47 t-ishii + + * child.c (1.12): Fix misspell in a comment + +2007-09-07 18:08 y-asaba + + * pool_process_query.c (1.42), parser/parser.c (1.2), + parser/pool_memory.c (1.7), parser/pool_memory.h (1.3, V2_0_1, + V2_0_0, V2_0_0_BETA1): Improve performance. + - Reuse parser memory space in free_parser(). + - Check node type before comparing with "show pool_status()". + +2007-09-06 10:43 y-asaba + + * doc/pgpool-en.html (1.11): Fix restricted query section. + +2007-08-29 15:49 y-asaba + + * pool_query_cache.c (1.7), pcp/pcp.c (1.4, V2_0_1, V2_0_0, + V2_0_0_BETA1), pcp/pcp_stream.c (1.3, V2_0_1, V2_0_0, + V2_0_0_BETA1): Fix compile error on FreeBSD 4.11. + +2007-08-29 15:48 y-asaba + + * recovery.c (1.2): Fix compile error. + +2007-08-29 15:01 y-asaba + + * pool_process_query.c (1.41): Read response messages in Parse() + until receiving ParseComplete or ErrorResponse message. + +2007-08-28 19:07 y-asaba + + * pool_process_query.c (1.40): Add checking deadlock error message + in Parse(). + +2007-08-28 11:28 y-asaba + + * pool_process_query.c (1.39): + * Fix handling Parse message. Parse message including + INSERT/UPDATE/DELETE query acquires RowExclusiveLock. However pgpool + did not wait a response from each node. It was possible to occur + deadlock problem. + + * Fix memory leak in reset_prepared_list() + +2007-08-17 10:50 t-ishii + + * TODO (1.5), doc/pgpool-ja.html (1.16): Enhance documentation. + +2007-08-13 11:23 y-asaba + + * pgpool.conf.sample (1.6), pool.h (1.12), pool_config.l (1.7), + pool_process_query.c (1.38): Add new parameter named + "replicate_select". Default value is 'false'. + + If it is true, pgpool replicates SELECT queries when load balancing + is disabled. This is a old specification which was V1.0. + + If it is false, pgpool only sends them to the master node. This is a + current specification. + +2007-08-06 10:42 y-asaba + + * pool_process_query.c (1.37): Fix memory leak. + +2007-08-01 13:27 y-asaba + + * child.c (1.11): Remove compiler warning. + +2007-07-27 10:19 y-asaba + + * doc/pgpool-ja.html (1.15): Merge from V1_STABLE branch + +2007-07-26 19:15 y-asaba + + * child.c (1.10), pool.h (1.11), pool_connection_pool.c (1.9, + V2_0_1, V2_0_0, V2_0_0_BETA1): SIGALRM handler didn't safe. + Because it called non-reentrant functions. We only set a flag in + SIGALRM handler. Then we close expired connections in safe places. + +2007-07-26 14:15 y-asaba + + * pool_connection_pool.c (1.8): Fix memory leak when connection + slot is full. + +2007-07-26 11:28 t-ishii + + * aclocal.m4 (1.9), configure (1.13), pool_config.c (1.9): Run + autoconf + +2007-07-26 11:21 y-asaba + + * pool_config.l (1.6): Fix using uninitialized value. + +2007-07-25 21:31 y-asaba + + * pool_process_query.c (1.36): Fix hang up and SEGV if Parse + message contains a warning statement. + + SELECT '\''; + WARNING: nonstandard use of \' in a string literal + + If pgpool receives a warning message that is NoticeMessage('N') + under the extended query protocol, it reads a next message. + +2007-07-24 18:02 y-asaba + + * pool.h (1.10), pool_process_query.c (1.35): Detect deadlock in + do_command(). When insert_lock was true, kind mismatch error + occured. + +2007-07-23 14:32 y-asaba + + * pool_process_query.c (1.34): Fixed that + start_internal_transaction() was only called under replication mode + or parallel mode. + +2007-07-23 14:24 y-asaba + + * main.c (1.15): Remove debug code. + +2007-07-23 13:37 y-asaba + + * child.c (1.9), main.c (1.14), pool.h (1.9), pool_config.c (1.8), + pool_config.l (1.5), pool_process_query.c (1.33), pool_type.h + (1.6): Add reloading config files. pgpool can reload pgpool.conf, + pool_hba.conf and distributed rules from system DB. If reload, you + type the following command. + + % pgpool reload + + Or you send SIGHUP signal to the pgpool parent process. + +2007-07-17 15:04 y-asaba + + * pool_process_query.c (1.32): Fix hang up when backend node did + fast or immediate shutdown. + + If shutdown occured, postgres send an error which error code is + "57P01" and error message is "terminating connection due to + administrator command". + + However, another nodes did not send any messages. pgpool waited for + a message from them. when the error is sended, pgpool reads the + message and degenerate. + +2007-07-17 11:33 y-asaba + + * pool_process_query.c (1.31, ROOT_OF_V2_0_PARALLEL_UNSTABLE): + Rearrange detect_deadlock_error(). + +2007-07-10 18:56 y-asaba + + * main.c (1.13, ROOT_OF_V2_0_PARALLEL_UNSTABLE), pool.h (1.8, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), pool_process_query.c (1.30), + pool_stream.c (1.4, ROOT_OF_V2_0_PARALLEL_UNSTABLE): + * Change type of InRecovery variable to sig_atomic_t* + + * Fixed kind mismatch error when deadlock error occured. The + problem is the following senario. + + A: BEGIN: + B: BEGIN; + A: LOCK TABLE t1 IN SHARE ROW EXCLUSIVE MODE; + B: LOCK TABLE t2 IN SHARE ROW EXCLUSIVE MODE; + A: LOCK TABLE t2 IN SHARE ROW EXCLUSIVE MODE; + B: LOCK TABLE t1 IN SHARE ROW EXCLUSIVE MODE; + + Transaction "A" aborts on master node, but it completes on another + nodes. It causes wrong failover. + + So pgpool checks deadlock error(code == '40P01') and sends error + query to another nodes. + +2007-07-09 14:18 y-asaba + + * main.c (1.12): Add comments. + +2007-07-09 13:23 y-asaba + + * main.c (1.11): Fix race condition between flag checking and + signal blocking. + + Normally, this case solve to call pselect(2). But Linux's pselect(2) + is emulated by select(2) and sigprocmask(2). It contains this race. + So pgpool archieves using the self-pipe trick. + + See 'man pselect' if you want to get more information. + +2007-07-09 10:29 y-asaba + + * config.guess (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1, ROOT_OF_V2_0_PARALLEL_UNSTABLE), config.h.in (1.4, + V2_0_1, V2_0_0, V2_0_0_BETA1, ROOT_OF_V2_0_PARALLEL_UNSTABLE), + configure (1.12, ROOT_OF_V2_0_PARALLEL_UNSTABLE), configure.in + (1.11, ROOT_OF_V2_0_PARALLEL_UNSTABLE), ltmain.sh (1.2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), aclocal.m4 (1.8, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), child.c (1.8, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), pcp_child.c (1.6, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), pool_connection_pool.c (1.7, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), pool_process_query.c (1.29), + pool_query_cache.c (1.6, ROOT_OF_V2_0_PARALLEL_UNSTABLE), + pool_stream.c (1.3): configure checks that OS has sys/select.h. + If it exists, include it. + +2007-07-06 17:32 y-asaba + + * child.c (1.7), pool_process_query.c (1.28), pool_type.h (1.5, + ROOT_OF_V2_0_PARALLEL_UNSTABLE): Load balancing node was chosen + before sending "SELECT" statement. But this way had the following + problems. + + psql>\d accounts + Did not find any relation with OID XXX + + pgpool chooses it after receiving AuthenticationOK('R') message. So + pgpool load balance to the same node inside a same session. + +2007-07-05 18:12 y-asaba + + * main.c (1.10): Improve signal handling. + + We fixed signal handling at revision 1.6. That fix was to set a flag + in signal handler, then pgpool checked flags in safe points. However + It has a race condition in the following case. + + CHECK_REQUEST; <-- check flags + <-- set flags + pause(); <-- wait for signals + + So, we modified to deliver signals in safe places which are in + pause() and sleep(). + +2007-07-05 11:14 y-asaba + + * pool_process_query.c (1.27): + * Remove debug code. + * Refactor ReadyForQuery() and do_command(). + +2007-07-04 17:18 y-asaba + + * pool_process_query.c (1.26): In replication mode, pgpool checks + the numbers of insert/update/delete tuples in CommandComplete + message. If these numbers are not same, a transaction is aborted by + pgpool. It is for data consistency. + + TODO: This behavior will be able to switch by pgpool.conf. + +2007-07-03 18:23 y-asaba + + * TODO (1.4, ROOT_OF_V2_0_PARALLEL_UNSTABLE): Rearrange TODO list. + +2007-06-29 23:15 y-asaba + + * main.c (1.9): Fix race condition between unsetting SIGCHLD flag + and unblocking SIGCHLD signal. + +2007-06-28 21:35 y-asaba + + * main.c (1.8): Fix SIGUSR2 handling. The signal handler only set + flag. Then, pgpool call SIGUSR2 handler in CHECK_REQUEST macro. + +2007-06-27 18:29 y-asaba + + * ChangeLog (1.18, ROOT_OF_V2_0_PARALLEL_UNSTABLE), pool.h (1.7), + pool_process_query.c (1.25): Fix hang up when a SELECT query has + error inside transaction block. It occurs only in simple query + protocol. + +2007-06-27 18:04 y-asaba + + * sample/pgpool_remote_start (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1, ROOT_OF_V2_0_PARALLEL_UNSTABLE): Fix checking the + number of arguments. + +2007-06-26 10:35 y-asaba + + * pcp_child.c (1.5): Remove unused variable. + +2007-06-22 19:10 t-ishii + + * Makefile.in (1.12, ROOT_OF_V2_0_PARALLEL_UNSTABLE), aclocal.m4 + (1.7), configure (1.11), parser/Makefile.in (1.8, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), parser/scan.c (1.4, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), pcp/Makefile.in (1.8, + ROOT_OF_V2_0_PARALLEL_UNSTABLE): run autoconf and flex + +2007-06-22 18:50 y-asaba + + * Makefile.am (1.9, ROOT_OF_V2_0_PARALLEL_UNSTABLE), Makefile.in + (1.11), aclocal.m4 (1.6), child.c (1.6), configure (1.10), + configure.in (1.10), main.c (1.7), pcp_child.c (1.4), + pgpool.conf.sample (1.5, ROOT_OF_V2_0_PARALLEL_UNSTABLE), pool.h + (1.6), pool_config.c (1.7, ROOT_OF_V2_0_PARALLEL_UNSTABLE), + pool_config.l (1.4, ROOT_OF_V2_0_PARALLEL_UNSTABLE), + pool_process_query.c (1.24), pool_type.h (1.4), recovery.c (1.1, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), doc/pgpool-ja.html (1.14, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), parser/Makefile.in (1.7), + pcp/Makefile.am (1.2, V2_0_0_BETA1, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), pcp/Makefile.in (1.7), pcp/pcp.c + (1.3, ROOT_OF_V2_0_PARALLEL_UNSTABLE), pcp/pcp.h (1.2, V2_0_1, + V2_0_0, V2_0_0_BETA1, ROOT_OF_V2_0_PARALLEL_UNSTABLE), + pcp/pcp_recovery_node.c (1.1, V2_0_1, V2_0_0, V2_0_0_BETA1, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), sample/pgpool_recovery (1.1, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), sample/pgpool_remote_start + (1.1), sql/pgpool-recovery/Makefile (1.1, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), sql/pgpool-recovery/pgpool-recovery.c (1.1), + sql/pgpool-recovery/pgpool-recovery.sql.in (1.1): Add new + features in pgpool-II 2.0. + * support online-recovery in replication mode. + - based on physical data copy + + * improve replication mode. + - employ "primary copy method" to enhance the performance + - more stable replication + +2007-06-21 10:17 y-asaba + + * ChangeLog (1.17): update ChangeLog. + +2007-06-20 18:09 y-asaba + + * main.c (1.6): Fix SIGCHLD and SIGUSR1 signal handling. Signal + handlers set flags only, then a parent process checks flags in + signal safe places. + +2007-06-20 17:14 t-ishii + + * pool_config.c (1.6), parser/gram.c (1.3, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE), parser/gram.h (1.3, V1_3, + V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE), parser/scan.c + (1.3, V1_2_1, V1_2): run flex + +2007-06-18 11:40 y-asaba + + * pool_process_query.c (1.23): Fix memory leak in + NotificationResponse(). + +2007-06-18 11:37 y-asaba + + * ChangeLog (1.16): update ChangeLog. + +2007-06-18 11:34 y-asaba + + * pool_process_query.c (1.22): + * Fix compile warning. + * Fix memory leak in CursorResponse(). + +2007-06-18 10:33 t-ishii + + * Makefile.in (1.10, V1_2_1, V1_2): run autoconf + +2007-06-15 22:35 devrim + + * pgpool.spec (1.7, ROOT_OF_V2_0_PARALLEL_UNSTABLE): Update spec + file + +2007-06-15 12:21 y-asaba + + * NEWS (1.10, ROOT_OF_V2_0_PARALLEL_UNSTABLE), doc/pgpool-ja.html + (1.13) (utags: V1_1_1): Update release note. + +2007-06-15 11:57 t-ishii + + * configure (1.9, V1_1_1): Run autoconf. + +2007-06-15 11:55 t-ishii + + * doc/pgpool-ja.html (1.12): Fix typo. + +2007-06-14 16:44 y-asaba + + * ChangeLog (1.15, V1_1_1): Prepare for 1.1.1 + +2007-06-12 10:49 y-asaba + + * NEWS (1.9): Prepare for 1.1.1 + +2007-06-11 15:37 y-asaba + + * configure.in (1.9, V1_1_1), doc/pgpool-ja.html (1.11): Prepare + for 1.1.1 + +2007-06-11 12:06 y-asaba + + * ChangeLog (1.14): Update ChangeLog. + +2007-06-11 12:01 y-asaba + + * pool_process_query.c (1.21, V1_1_1): Fix kind mismatch error when + load_balance_mode is true. + +2007-06-07 11:38 y-asaba + + * pool_process_query.c (1.20): Fix handling nullmap (V2 only). + +2007-06-06 17:32 yamaguti + + * doc/: pgpool-en.html (1.10, ROOT_OF_V2_0_PARALLEL_UNSTABLE, + V1_1_1), pgpool-ja.html (1.10): added an explanation about + command line option "-a" for HBA file. + +2007-06-02 09:54 y-asaba + + * pool_process_query.c (1.19): Fix typo EmptyQueryResponse message. + pgpool hung up in EXECUTE command. (Patch contributed by Kenichi + Sawada) + +2007-05-29 10:58 y-asaba + + * pool_process_query.c (1.18): Fix handling protocol version 2. + +2007-05-28 18:13 y-asaba + + * pool_process_query.c (1.17): Fix handling protocol version 2. + +2007-05-25 12:02 y-asaba + + * Makefile.am (1.8, V1_2_1, V1_2), Makefile.in (1.9) (utags: V1_1, + V1_1_1): Fix typo + +2007-05-25 11:45 y-asaba + + * ChangeLog (1.13, V1_1): Prepare for 1.1 + +2007-05-25 11:37 y-asaba + + * doc/: pgpool-en.html (1.9), pgpool-ja.html (1.9) (utags: V1_1): + Add handling "SELECT nextval". + +2007-05-25 11:30 y-asaba + + * doc/pgpool-ja.html (1.8): Add Japanese release note for 1.1 + +2007-05-24 23:27 t-ishii + + * Makefile.in (1.8), aclocal.m4 (1.5, V1_3, V1_2_1, V1_2, V1_1_1, + V1_1), configure (1.8, V1_1), parser/Makefile.in (1.6, V1_3, + V1_2_1, V1_2, V1_1_1, V1_1), pcp/Makefile.in (1.6, V1_3, V1_2_1, + V1_2, V1_1_1, V1_1): Resync files generated by configure.in + +2007-05-24 23:25 t-ishii + + * TODO (1.3, V1_3, V1_2_1, V1_2, V1_1_1, V1_1): update + TODO(Japanese) + +2007-05-24 15:42 y-asaba + + * NEWS (1.8, V1_1): update NEWS + +2007-05-24 15:38 y-asaba + + * parser/pool_memory.c (1.6, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1), ChangeLog (1.12): + Fix core dump in pool_memory_realloc(). + +2007-05-23 11:01 yamaguti + + * ChangeLog (1.11), NEWS (1.7): + + fixed pgpool.pam so it is installed under $PREFIX/share/pgpool-II/ + +2007-05-23 10:59 yamaguti + + * ac_func_accept_argtypes.m4 (1.1, V2_2_4, V2_2_3, V2_2_2, V2_2_1, + V2_2_0, V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, + V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1), pool_hba.c (1.1), pool_hba.conf.sample (1.1, + V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1), pool_ip.c (1.1, + V2_0_1, V2_0_0, V2_0_0_BETA1), pool_ip.h (1.1, V2_0_1, V2_0_0, + V2_0_0_BETA1), pool_path.c (1.1, V2_0_1, V2_0_0, V2_0_0_BETA1), + pool_path.h (1.1, V2_0_1, V2_0_0, V2_0_0_BETA1), ps_status.c + (1.1, V2_0_1, V2_0_0, V2_0_0_BETA1), strlcpy.c (1.1, V2_0_1, + V2_0_0, V2_0_0_BETA1) (utags: ROOT_OF_V2_0_PARALLEL_UNSTABLE, + V1_1, V1_1_1, V1_2, V1_2_1, V1_3): + + new files for HBA, ps display, log_hostname & log_connections + +2007-05-22 15:28 y-asaba + + * pool_process_query.c (1.16, V1_1): Add checking a message length + is valid. (Reported by Fujii Masao) + +2007-05-21 14:49 y-asaba + + * NEWS (1.6), configure.in (1.8, V1_1), version.h (1.2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1): Prepare for 1.1 + +2007-05-21 11:16 yamaguti + + * Makefile.am (1.7), Makefile.in (1.7): pgpool.pam and + system_db.sql is now installed under share/pgpool-II/ + +2007-05-17 15:46 yamaguti + + * ChangeLog (1.10), Makefile.am (1.6), Makefile.in (1.6), + aclocal.m4 (1.4), child.c (1.5, V1_1_1, V1_1), config.h.in (1.3, + V1_1_1, V1_1), configure (1.7), configure.in (1.7), main.c (1.5, + V1_1_1, V1_1), pcp_child.c (1.3, V1_3, V1_2_1, V1_2, V1_1_1, + V1_1), pgpool.conf.sample (1.4, V1_1_1, V1_1), pool.h (1.5, + V1_1_1, V1_1), pool_config.c (1.5, V1_1_1, V1_1), pool_config.l + (1.3, V1_1_1, V1_1), pool_process_query.c (1.15), + pool_query_cache.c (1.5, V1_2, V1_1_1, V1_1), pool_type.h (1.3, + V1_1_1, V1_1), doc/pgpool-en.html (1.8), doc/pgpool-ja.html + (1.7), parser/Makefile.in (1.5), parser/gram.c (1.2, V1_1_1, + V1_1), parser/gram.h (1.2, V1_1_1, V1_1), parser/pool_parser.h + (1.2, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, + V1_1), pcp/Makefile.in (1.5), sample/pgpool.pam (1.1, V2_2_4, + V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, V2_2_0_RC1, + V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, V2_1_0_BETA2, + V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1): + * Support HBA authentication. + * Support log_connections + * Support log_hostname + * Support "ps" status display + * Fixed compiler warning in pool_query_cache.c + * sample/pgpool.pam: PAM service configuration file. It will be + installed to "$PREFIX/share/" + * doc/pgpool-ja.html: Added pool_hba description. + * doc/pgpool-en.html: Added pool_hba description. + * Updated ChangeLog + +2007-04-26 14:26 y-asaba + + * ChangeLog (1.9), pool_connection_pool.c (1.6, V1_1_1, V1_1): + Retry connect() when it is interrupted by signal. + +2007-04-20 16:18 y-asaba + + * ChangeLog (1.8): Add entry. + +2007-04-20 15:41 y-asaba + + * pool_process_query.c (1.14): Enhance that the query that begins + with "SELECT nextval()" or "SELECT setval()" are always replicated + under replication mode. + + Then, SELECT statements are only executed by MASTER node if + load_balance_mode is false. If need to replicate select statement, + add a comment in the begining of the query. + + Example: + SELECT foo() -> /*REPLICATION*/ SELECT foo() + +2007-04-15 20:26 t-ishii + + * pool_process_query.c (1.13): Fix read_kind_from_backend(). It + calls notice_backend_error() with fixed db node number 1. Make it + the db node which returns different packet kind from master. + +2007-04-12 17:30 devrim + + * pool_process_query.c (1.12): Patch to surpress compiler warnings, + per Ralf Corsepius + +2007-03-01 13:06 y-asaba + + * ChangeLog (1.7), pool_process_query.c (1.11): Support load + balancing with extended protocol. (Parallel query isn't supported + extended protocol yet.) + +2007-03-01 12:03 y-asaba + + * ChangeLog (1.6), parser/Makefile.am (1.2, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1), parser/copyfuncs.c + (1.1, V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, + V1_1): Porting deep copy functions for tree nodes from + PostgreSQL. + +2007-02-28 20:04 y-asaba + + * ChangeLog (1.5): Add ChangeLog entry. + +2007-02-28 19:44 y-asaba + + * Makefile.am (1.5): Fix link error on Solaris. Solaris's ld does + not have --rpath option. So it uses libtool's -rpath option instead + of ld's option. + +2007-02-21 04:38 devrim + + * pgpool.spec (1.6, V1_1_1, V1_1): Fixes from Jarod Wilson + + - Create proper devel package, drop -libs package + - Nuke rpath + - Don't install libtool archive and static lib + - Clean up %%configure line + - Use proper %%_smp_mflags + - Install config files properly, without .sample on the end + - Preserve timestamps on header files + +2007-02-20 18:20 devrim + + * pgpool.spec (1.5): + - Update to 1.0.2-1 + - Fix various build problems and prepared for Fedora Submission + + + ---------------------------------------------------------------------- + +2007-02-20 15:02 devrim + + * pgpool.conf.sample (1.3): Update header so that we can see that + it is pgpool-II conf file (I was confused after removing pgpool and + installing pgpool-II :) ) + +2007-02-16 22:56 t-ishii + + * Makefile.in (1.5), configure (1.6), parser/Makefile.in (1.4), + pcp/Makefile.in (1.4): automake & autoconf + +2007-02-16 20:31 y-asaba + + * ChangeLog (1.4), Makefile.am (1.4), configure.in (1.6), + pool_connection_pool.c (1.5), pool_query_cache.c (1.4), pcp/pcp.c + (1.2, V1_2, V1_1_1, V1_1), pcp/pcp_stream.c (1.2, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1): Fixed compile + error on MacOS X. MacOS's ld does not have rpath option. So add + --disable-rpath option to configure for MacOS X. + +2007-02-13 12:44 y-asaba + + * ChangeLog (1.3, V1_0_2): + * Add entries using cvs2cl. + +2007-02-12 16:23 y-asaba + + * doc/pgpool-ja.html (1.6, V1_0_2): Add release note. + +2007-02-12 15:51 y-asaba + + * doc/pgpool-ja.html (1.5): Add Japanese release note into + pgpool-ja.html. + +2007-02-12 11:32 y-asaba + + * child.c (1.4), pool.h (1.4), pool_connection_pool.c (1.4) (utags: + V1_0_2): pgpool *only* checks backend connection when connection + pool is reused. + +2007-02-09 12:54 y-asaba + + * NEWS (1.5, V1_0_2): fix indent. + +2007-02-09 12:50 y-asaba + + * NEWS (1.4): Remove '\000'. + +2007-02-08 22:08 t-ishii + + * doc/pgpool-en.html (1.7, V1_0_2): prepare for 1.0.2 + +2007-02-08 21:52 t-ishii + + * NEWS (1.3), config.h.in (1.2, V1_0_2), configure (1.5, V1_0_2): + Prepare for 1.0.2 + +2007-02-08 17:56 y-asaba + + * doc/pgpool-ja.html (1.4): Add new loadbalancing rule in + replication mode section. + +2007-02-08 17:34 y-asaba + + * pool_query_cache.c (1.3), configure.in (1.5), pool_system.c (1.3, + V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1) + (utags: V1_0_2): Fixed configure error if libpq version is 7.4.x. + 7.4 does not have PQprepare(). So when version is 7.4, pgpool uses + PREPARE statement instead of PQprepare(). + +2007-02-08 00:44 y-asaba + + * configure.in (1.4): Prepare for 1.0.2 + +2007-02-07 19:08 t-ishii + + * Makefile.in (1.4, V1_0_2), aclocal.m4 (1.3, V1_0_2), configure + (1.4), configure.in (1.3), pool_config.c (1.4, V1_0_2), + parser/Makefile.in (1.3, V1_0_2), pcp/Makefile.in (1.3, V1_0_2): + update configure.in to use pg_config. Patch made by Yoshiyuki + Asaba. + +2007-02-06 11:46 y-asaba + + * pool_connection_pool.c (1.3): Add checking socket state when + connection pool is reused. If socket is closed, pgpool try to + create new connection pool. + +2007-01-30 11:25 y-asaba + + * pool_process_query.c (1.10, V1_0_2): Disable to load balance in + the following cases. + - SELECT FOR UPDATE + - SELECT INTO + - /* xxx */ SELECT ... (This is pgpool-I spec.) + +2007-01-13 23:56 yamaguti + + * pool_signal.h (1.3, V2_0_1, V2_0_0, V2_0_0_BETA1, V1_3, V1_2_1, + V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2): + + fixed #ifndef ~ #define macro for that it could have been included + redundantly. + +2007-01-10 04:02 y-asaba + + * pool_process_query.c (1.9): Fix auto-deallocation. If a client + used PDO interface, pgpool didn't clean prepared statement. + +2007-01-05 02:27 devrim + + * COPYING (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), child.c + (1.3), main.c (1.4, V1_0_2), pcp_child.c (1.2, V1_0_2), + pgpool.8.in (1.2, V2_0_0_BETA1, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), pool.h + (1.3), pool_auth.c (1.3, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), + pool_config.c (1.3), pool_config.l (1.2, V1_0_2), + pool_connection_pool.c (1.2), pool_error.c (1.2, V2_0_1, V2_0_0, + V2_0_0_BETA1, V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, + V1_1_1, V1_1, V1_0_2), pool_ipc.h (1.2, V2_0_1, V2_0_0, + V2_0_0_BETA1, V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, + V1_1_1, V1_1, V1_0_2), pool_params.c (1.2, V2_0_1, V2_0_0, + V2_0_0_BETA1, V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, + V1_1_1, V1_1, V1_0_2), pool_process_query.c (1.8), + pool_query_cache.c (1.2), pool_rewrite_query.c (1.3, V1_3, + V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, + V1_0_2), pool_rewrite_query.h (1.2, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), + pool_sema.c (1.2, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), + pool_shmem.c (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1, V1_3, V1_2_1, + V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), + pool_signal.c (1.2, V2_0_1, V2_0_0, V2_0_0_BETA1, V1_3, V1_2_1, + V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), + pool_signal.h (1.2), pool_stream.c (1.2, V1_1_1, V1_1, V1_0_2), + pool_system.c (1.2), pool_type.h (1.2, V1_0_2), + parser/pool_memory.c (1.5, V1_0_2), parser/pool_memory.h (1.2, + V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, + V1_0_2), parser/pool_string.c (1.2, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2), + parser/pool_string.h (1.2, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2): Copyright + update + +2006-12-25 19:14 y-asaba + + * Makefile.am (1.3, V1_0_2), Makefile.in (1.3): Fix libpq link + error (Reported by ISHIDA Akio). + +2006-12-04 14:49 t-ishii + + * pool_process_query.c (1.7): Fix bug with replication mode. With + UPDATE/DELETE, the number of affcted rows should not be sum of each + node. + +2006-12-02 22:41 t-ishii + + * pool_process_query.c (1.6): Add backend status info to show + pool_status + +2006-12-02 22:40 t-ishii + + * main.c (1.3): enhance logging to make it clear what kind of + failover/failback event ocuured. + +2006-12-02 22:38 t-ishii + + * TODO (1.2, V1_0_2): update TODO document to reflect current + status + +2006-11-30 07:33 devrim + + * child.c (1.2), pool_auth.c (1.2): Fix small typos in messages + +2006-11-30 06:54 devrim + + * pgpool.conf.sample (1.2, V1_0_2): Fix small typos in config file + +2006-11-15 18:30 y-asaba + + * pool_process_query.c (1.5): Fix an extended query protocol + handling. + +2006-11-13 14:02 y-asaba + + * parser/pool_memory.c (1.4): Fix SIGSEGV under parallel mode. + +2006-11-10 12:48 y-asaba + + * parser/pool_memory.c (1.3): + * Add NULL checking in pool_memory_free(). + + * Fix SIGSEGV in pool_memory_alloc() if allocate size is 8192 byte. + + void *x; + pool_memory = pool_memory_create(); + x = pool_memory_alloc(pool_memory, 8192); + +2006-11-04 16:38 y-asaba + + * parser/pool_memory.c (1.2): Fixed a inifinite loop in + pool_memory_free(). + +2006-10-04 14:57 y-asaba + + * pool_rewrite_query.c (1.2): Fix rewriting a query which refers + pg_catalog. Patch contributed by Yoshiharu Mori. + +2006-10-04 04:31 devrim + + * pgpool.spec (1.4, V1_0_2): + - Added -libs and -devel RPM + - Fix .so link problem + - Cosmetic changes to spec file + +2006-10-04 04:29 devrim + + * pgpool.spec (1.3): [no log message] + +2006-09-27 14:45 devrim + + * pgpool.spec (1.2): + * Thu Sep 27 2006 - Devrim GUNDUZ 1.0.1-3 + - Fix spec, per Yoshiyuki Asaba + + * Thu Sep 26 2006 - Devrim GUNDUZ 1.0.1-2 + - Fixed rpmlint errors + - Fixed download url + - Added ldconfig for .so files + + ** Thu Sep 21 2006 - David Fetter 1.0.1-1 + - Initial build pgpool-II 1.0.1 for PgPool Global Development Group + +2006-09-27 11:14 y-asaba + + * pool_process_query.c (1.4): Fix load balancing algorithm. Patch + contributed by Jeff Davis. + + See the following URL for more details. + + http://pgfoundry.org/pipermail/pgpool-hackers/2006-September/000034.html + +2006-09-25 12:03 y-asaba + + * doc/: pgpool-en.html (1.6), pgpool-ja.html (1.3): Add pam + authentication in supported authentication protocol list. Reported + by Jeff Davis. + +2006-09-22 15:04 t-ishii + + * Makefile.am (1.2), Makefile.in (1.2), aclocal.m4 (1.2), configure + (1.3), pool_config.c (1.2), parser/Makefile.in (1.2), + parser/scan.c (1.2, V1_1_1, V1_1, V1_0_2), pcp/Makefile.in (1.2) + (utags: V1_0_1): Update Makefile.am to reflect the fact that some + doc names have been changed. + +2006-09-22 14:39 t-ishii + + * ChangeLog (1.2, V1_0_1), NEWS (1.2, V1_0_1), configure (1.2), + configure.in (1.2, V1_0_1): Version 1.0.1 + +2006-09-15 15:06 y-asaba + + * doc/pgpool-ja.html (1.2, V1_0_1): A restriction of extended + protocol is *only* in parallel mode. Fixed the description. + +2006-09-14 11:04 t-ishii + + * pool.h (1.2, V1_0_1): Fix NUM_BACKENDS macro when operated in + MASTER_SLAVE mode. See following message for more details. + + Subject: [Pgpool-general] pgpool-II master/slave mode, BackendError + From: Jeff Davis To: + pgpool-general@pgfoundry.org Date: Tue, 12 Sep 2006 16:48:49 -0700 + +2006-09-14 11:00 t-ishii + + * pool_process_query.c (1.3, V1_0_1): Fix debug message in + simpleQuery() so that it correctly prints query string when operated + in MASTER_SLAVE mode. + +2006-09-14 10:56 t-ishii + + * main.c (1.2, V1_0_1): enhance health check error messages + +2006-09-13 19:21 y-asaba + + * pool_process_query.c (1.2): Fix kind mismatch error in COPY FROM + STDIN. + +2006-09-11 23:50 y-asaba + + * doc/pgpool-en.html (1.5, V1_0_1): Remove multibyte character. + +2006-09-11 15:47 y-asaba + + * doc/tutorial-ja.html (1.1, V2_0_0_BETA1, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2, V1_0_1): + Rename `tutorial.html' to `tutorial-ja.html'. + +2006-09-11 15:42 y-asaba + + * README.euc_jp (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, + V2_2_0_RC2, V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, + V2_1_0_RC1, V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, + V2_0_0_BETA1, V1_3, V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, + V1_1_1, V1_1, V1_0_2, V1_0_1), doc/pgpool-ja.html (1.1): + * Rename `doc/pgpool.html' to `doc/pgpool-ja.html'. + + * Merge Devrim's patch. + +2006-09-11 15:32 y-asaba + + * doc/pgpool-en.html (1.4): Remove Japanese comment. + +2006-09-11 15:13 y-asaba + + * doc/tutorial-en.html (1.2, V2_0_0_BETA1, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2, V1_0_1): + Remove Japanese characters. + +2006-09-11 14:53 y-asaba + + * README (1.2, V2_2_4, V2_2_3, V2_2_2, V2_2_1, V2_2_0, V2_2_0_RC2, + V2_2_0_RC1, V2_2_0_BETA2, V2_2_0_BETA1, V2_1_0, V2_1_0_RC1, + V2_1_0_BETA2, V2_1_0_BETA1, V2_0_1, V2_0_0, V2_0_0_BETA1, V1_3, + V1_2_1, V1_2, ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, + V1_0_2, V1_0_1): Update README. + +2006-09-08 21:01 devrim + + * doc/pgpool-en.html (1.3): Far better look for HTML page, suitable + for web and local browsing. + +2006-09-08 20:09 devrim + + * doc/pgpool-en.html (1.2): comment last modified line for a better + look + +2006-09-08 20:05 devrim + + * doc/pgpool.css (1.1, V1_3, V1_2_1, V1_2, + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_1_1, V1_1, V1_0_2, V1_0_1): + Add pgpool.css for readme files. This is the same stylesheet that we + use in pgpool page. + +2006-09-08 19:16 devrim + + * doc/: pgpool-en.html (1.1), tutorial-en.html (1.1): + + Renamed files so that some browsers won't complain. + +2006-09-08 12:35 t-ishii + + * README (1.1), configure.in (1.1), Makefile.am (1.1), aclocal.m4 + (1.1), Makefile.in (1.1), config.h.in (1.1), configure (1.1), + COPYING (1.1), ChangeLog (1.1), NEWS (1.1), TODO (1.1), + config.guess (1.1), config.sub (1.1), ltmain.sh (1.1), pg_md5.c + (1.1), pool_config.c (1.1), README.euc_jp (1.1), main.c (1.1), + pgpool.conf.sample (1.1), pgpool.spec (1.1), pool.h (1.1), + pool_type.h (1.1), version.h (1.1), child.c (1.1), pool_auth.c + (1.1), pool_config.l (1.1), pool_error.c (1.1), + pool_connection_pool.c (1.1), pool_params.c (1.1), + pool_process_query.c (1.1), pool_signal.c (1.1), pool_signal.h + (1.1), pool_stream.c (1.1), pcp_child.c (1.1), pool_ipc.h (1.1), + pool_sema.c (1.1), pool_shmem.c (1.1), pool_system.c (1.1), + pool_rewrite_query.c (1.1), pool_rewrite_query.h (1.1), + pool_rewrite_outfuncs.c (1.1), pgpool.8.in (1.1), + pool_query_cache.c (1.1), parser/Makefile.am (1.1), + parser/Makefile.in (1.1), sql/system_db.sql (1.1), parser/gram.c + (1.1), parser/gram.h (1.1), parser/gram.y (1.1), + parser/gramparse.h (1.1), parser/list.c (1.1), parser/makefuncs.c + (1.1), parser/makefuncs.h (1.1), parser/memnodes.h (1.1), + parser/nodes.c (1.1), parser/nodes.h (1.1), parser/parsenodes.h + (1.1), parser/parser.c (1.1), parser/parser.h (1.1), + parser/pg_list.h (1.1), parser/pool_memory.c (1.1), + parser/pool_memory.h (1.1), parser/pool_string.c (1.1), + parser/pool_string.h (1.1), parser/keywords.c (1.1), + parser/keywords.h (1.1), parser/pool_parser.h (1.1), + parser/primnodes.h (1.1), parser/scansup.h (1.1), parser/value.c + (1.1), parser/value.h (1.1), parser/outfuncs.c (1.1), + parser/scan.c (1.1), parser/scan.l (1.1), pcp/Makefile.am (1.1), + pcp/Makefile.in (1.1), pcp/pcp.h (1.1), pcp/pcp.c (1.1), + pcp/pcp_attach_node.c (1.1), pcp/pcp_detach_node.c (1.1), + pcp/pcp_error.c (1.1), pcp/pcp_node_count.c (1.1), + pcp/pcp_stream.c (1.1), pcp/pcp_stream.h (1.1), + pcp/pcp_node_info.c (1.1), pcp/pcp_proc_count.c (1.1), + pcp/pcp_proc_info.c (1.1), pcp/pcp_stop_pgpool.c (1.1), + pcp/pcp_systemdb_info.c (1.1): Initial revision + +2006-09-08 12:35 t-ishii + + * AUTHORS (1.1.1.1, V2_2_4), INSTALL (1.1.1.1, V2_2_4), depcomp + (1.1.1.1, V2_2_4), install-sh (1.1.1.1, V2_2_4), missing + (1.1.1.1, V2_2_4), mkinstalldirs (1.1.1.1, V2_2_4), md5.c + (1.1.1.1), md5.h (1.1.1.1, V2_2_4), pcp.conf.sample (1.1.1.1, + V2_2_4), sample/dist_def_pgbench.sql (1.1.1.1, V2_2_4), pcp/md5.h + (1.1.1.1, V2_2_4), pcp/md5.c (1.1.1.1) (utags: + ROOT_OF_V2_0_PARALLEL_UNSTABLE, V1_0_0, V1_0_1, V1_0_2, V1_1, + V1_1_1, V1_2, V1_2_1, V1_3, V2_0_0, V2_0_0_BETA1, V2_0_1, V2_1_0, + V2_1_0_BETA1, V2_1_0_BETA2, V2_1_0_RC1, V2_2_0, V2_2_0_BETA1, + V2_2_0_BETA2, V2_2_0_RC1, V2_2_0_RC2, V2_2_1, V2_2_2, V2_2_3): + pgpool-II initial release + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..3083f1a --- /dev/null +++ b/INSTALL @@ -0,0 +1 @@ +See README diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..2600a50 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,70 @@ +bin_PROGRAMS = pgpool pg_md5 + +pgpool_SOURCES = pool.h pool_type.h version.h pgpool.conf.sample \ + README.euc_jp pgpool.spec \ + main.c child.c pool_auth.c pool_config.l pool_error.c \ + pool_process_query.c pool_stream.c pool_connection_pool.c pool_params.c \ + pool_signal.h pool_signal.c pcp_child.c md5.c md5.h pcp.conf.sample \ + pool_ipc.h pool_shmem.c pool_sema.c pool_system.c \ + pool_rewrite_query.c pool_rewrite_query.h pool_rewrite_outfuncs.c \ + pool_query_cache.c pool_hba.conf.sample sample/pgpool.pam\ + pool_hba.c pool_path.h pool_path.c pool_ip.h pool_ip.c pool_type.h \ + ps_status.c strlcpy.c recovery.c \ + pool_proto_modules.c pool_proto_modules.h + +pg_md5_SOURCES = pg_md5.c md5.c md5.h + +DEFS = @DEFS@ \ + -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" + +sysconf_DATA = pgpool.conf.sample pcp.conf.sample pool_hba.conf.sample +pkgdata_DATA = sql/system_db.sql sample/pgpool.pam + +AM_CPPFLAGS = -D_GNU_SOURCE -I @PGSQL_INCLUDE_DIR@ + +pgpool_LDADD = -L@PGSQL_LIB_DIR@ -lpq parser/libsql-parser.a pcp/libpcp.la parser/nodes.o +if enable_rpath + pgpool_LDFLAGS = -rpath @PGSQL_LIB_DIR@ -rpath $(libdir) +else + pgpool_LDFLAGS = +endif + +AM_YFLAGS = -d + +man_MANS = pgpool.8 + +pgpool.8: pgpool.8.in + sed 's,@sysconfdir\@,$(sysconfdir),g' $? >$@ + +CLEANFILES = pgpool.8 +EXTRA_DIST = pgpool.8.in sql/system_db.sql sample/pgpool.pam doc/pgpool-ja.html doc/pgpool-en.html \ + doc/tutorial-ja.html doc/tutorial-en.html doc/pgpool.css \ + doc/load_balance.png doc/load_balance.odp \ + sample/pgpool_remote_start sample/pgpool_recovery sample/pgpool_recovery_pitr \ + sample/dist_def_pgbench.sql sample/replicate_def_pgbench.sql \ + sql/pgpool-recovery/pgpool-recovery.c \ + sql/pgpool-recovery/pgpool-recovery.sql.in sql/pgpool-recovery/Makefile \ + test/parser/expected/cursor.out test/parser/expected/copy.out \ + test/parser/expected/privileges.out test/parser/expected/delete.out \ + test/parser/expected/insert.out test/parser/expected/misc.out \ + test/parser/expected/prepare.out test/parser/expected/transaction.out \ + test/parser/expected/select.out test/parser/expected/update.out \ + test/parser/expected/var.out test/parser/expected/create.out \ + test/parser/expected/drop.out test/parser/input/cursor.sql \ + test/parser/input/copy.sql test/parser/input/privileges.sql \ + test/parser/input/delete.sql test/parser/input/insert.sql \ + test/parser/input/misc.sql test/parser/input/prepare.sql \ + test/parser/input/transaction.sql test/parser/input/select.sql \ + test/parser/input/update.sql test/parser/input/var.sql \ + test/parser/input/create.sql test/parser/input/drop.sql \ + test/parser/input/alter.sql test/parser/.cvsignore test/parser/Makefile \ + test/parser/README test/parser/main.c \ + test/parser/pool.h test/parser/run-test \ + test/parser/parse_schedule \ + test/jdbc/*.java test/jdbc/README.euc_jp test/jdbc/pgpool.properties test/jdbc/prepare.sql test/jdbc/run.sh \ + test/jdbc/expected/autocommit test/jdbc/expected/batch \ + test/jdbc/expected/column test/jdbc/expected/lock test/jdbc/expected/select \ + test/jdbc/expected/update test/jdbc/expected/insert \ + redhat/pgpool.init redhat/pgpool.sysconfig + +SUBDIRS = parser pcp diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..2ed8bfb --- /dev/null +++ b/Makefile.in @@ -0,0 +1,913 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = pgpool$(EXEEXT) pg_md5$(EXEEXT) +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ + TODO config.guess config.sub depcomp install-sh ltmain.sh \ + missing mkinstalldirs pool_config.c ylwrap +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/ac_func_accept_argtypes.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man8dir)" \ + "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(sysconfdir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_pg_md5_OBJECTS = pg_md5.$(OBJEXT) md5.$(OBJEXT) +pg_md5_OBJECTS = $(am_pg_md5_OBJECTS) +pg_md5_LDADD = $(LDADD) +am_pgpool_OBJECTS = main.$(OBJEXT) child.$(OBJEXT) pool_auth.$(OBJEXT) \ + pool_config.$(OBJEXT) pool_error.$(OBJEXT) \ + pool_process_query.$(OBJEXT) pool_stream.$(OBJEXT) \ + pool_connection_pool.$(OBJEXT) pool_params.$(OBJEXT) \ + pool_signal.$(OBJEXT) pcp_child.$(OBJEXT) md5.$(OBJEXT) \ + pool_shmem.$(OBJEXT) pool_sema.$(OBJEXT) pool_system.$(OBJEXT) \ + pool_rewrite_query.$(OBJEXT) pool_rewrite_outfuncs.$(OBJEXT) \ + pool_query_cache.$(OBJEXT) pool_hba.$(OBJEXT) \ + pool_path.$(OBJEXT) pool_ip.$(OBJEXT) ps_status.$(OBJEXT) \ + strlcpy.$(OBJEXT) recovery.$(OBJEXT) \ + pool_proto_modules.$(OBJEXT) +pgpool_OBJECTS = $(am_pgpool_OBJECTS) +pgpool_DEPENDENCIES = parser/libsql-parser.a pcp/libpcp.la \ + parser/nodes.o +DEFAULT_INCLUDES = -I. -I$(srcdir) -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) +SOURCES = $(pg_md5_SOURCES) $(pgpool_SOURCES) +DIST_SOURCES = $(pg_md5_SOURCES) $(pgpool_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +man8dir = $(mandir)/man8 +NROFF = nroff +MANS = $(man_MANS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +pkgdataDATA_INSTALL = $(INSTALL_DATA) +sysconfDATA_INSTALL = $(INSTALL_DATA) +DATA = $(pkgdata_DATA) $(sysconf_DATA) +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ \ + -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" + +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PGCONFIG = @PGCONFIG@ +PGSQL_INCLUDE_DIR = @PGSQL_INCLUDE_DIR@ +PGSQL_LIB_DIR = @PGSQL_LIB_DIR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +YACC = @YACC@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +enable_rpath_FALSE = @enable_rpath_FALSE@ +enable_rpath_TRUE = @enable_rpath_TRUE@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +pgpool_SOURCES = pool.h pool_type.h version.h pgpool.conf.sample \ + README.euc_jp pgpool.spec \ + main.c child.c pool_auth.c pool_config.l pool_error.c \ + pool_process_query.c pool_stream.c pool_connection_pool.c pool_params.c \ + pool_signal.h pool_signal.c pcp_child.c md5.c md5.h pcp.conf.sample \ + pool_ipc.h pool_shmem.c pool_sema.c pool_system.c \ + pool_rewrite_query.c pool_rewrite_query.h pool_rewrite_outfuncs.c \ + pool_query_cache.c pool_hba.conf.sample sample/pgpool.pam\ + pool_hba.c pool_path.h pool_path.c pool_ip.h pool_ip.c pool_type.h \ + ps_status.c strlcpy.c recovery.c \ + pool_proto_modules.c pool_proto_modules.h + +pg_md5_SOURCES = pg_md5.c md5.c md5.h +sysconf_DATA = pgpool.conf.sample pcp.conf.sample pool_hba.conf.sample +pkgdata_DATA = sql/system_db.sql sample/pgpool.pam +AM_CPPFLAGS = -D_GNU_SOURCE -I @PGSQL_INCLUDE_DIR@ +pgpool_LDADD = -L@PGSQL_LIB_DIR@ -lpq parser/libsql-parser.a pcp/libpcp.la parser/nodes.o +@enable_rpath_FALSE@pgpool_LDFLAGS = +@enable_rpath_TRUE@pgpool_LDFLAGS = -rpath @PGSQL_LIB_DIR@ -rpath $(libdir) +AM_YFLAGS = -d +man_MANS = pgpool.8 +CLEANFILES = pgpool.8 +EXTRA_DIST = pgpool.8.in sql/system_db.sql sample/pgpool.pam doc/pgpool-ja.html doc/pgpool-en.html \ + doc/tutorial-ja.html doc/tutorial-en.html doc/pgpool.css \ + doc/load_balance.png doc/load_balance.odp \ + sample/pgpool_remote_start sample/pgpool_recovery sample/pgpool_recovery_pitr \ + sample/dist_def_pgbench.sql sample/replicate_def_pgbench.sql \ + sql/pgpool-recovery/pgpool-recovery.c \ + sql/pgpool-recovery/pgpool-recovery.sql.in sql/pgpool-recovery/Makefile \ + test/parser/expected/cursor.out test/parser/expected/copy.out \ + test/parser/expected/privileges.out test/parser/expected/delete.out \ + test/parser/expected/insert.out test/parser/expected/misc.out \ + test/parser/expected/prepare.out test/parser/expected/transaction.out \ + test/parser/expected/select.out test/parser/expected/update.out \ + test/parser/expected/var.out test/parser/expected/create.out \ + test/parser/expected/drop.out test/parser/input/cursor.sql \ + test/parser/input/copy.sql test/parser/input/privileges.sql \ + test/parser/input/delete.sql test/parser/input/insert.sql \ + test/parser/input/misc.sql test/parser/input/prepare.sql \ + test/parser/input/transaction.sql test/parser/input/select.sql \ + test/parser/input/update.sql test/parser/input/var.sql \ + test/parser/input/create.sql test/parser/input/drop.sql \ + test/parser/input/alter.sql test/parser/.cvsignore test/parser/Makefile \ + test/parser/README test/parser/main.c \ + test/parser/pool.h test/parser/run-test \ + test/parser/parse_schedule \ + test/jdbc/*.java test/jdbc/README.euc_jp test/jdbc/pgpool.properties test/jdbc/prepare.sql test/jdbc/run.sh \ + test/jdbc/expected/autocommit test/jdbc/expected/batch \ + test/jdbc/expected/column test/jdbc/expected/lock test/jdbc/expected/select \ + test/jdbc/expected/update test/jdbc/expected/insert \ + redhat/pgpool.init redhat/pgpool.sysconfig + +SUBDIRS = parser pcp +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .l .lo .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +pg_md5$(EXEEXT): $(pg_md5_OBJECTS) $(pg_md5_DEPENDENCIES) + @rm -f pg_md5$(EXEEXT) + $(LINK) $(pg_md5_LDFLAGS) $(pg_md5_OBJECTS) $(pg_md5_LDADD) $(LIBS) +pgpool$(EXEEXT): $(pgpool_OBJECTS) $(pgpool_DEPENDENCIES) + @rm -f pgpool$(EXEEXT) + $(LINK) $(pgpool_LDFLAGS) $(pgpool_OBJECTS) $(pgpool_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/child.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_child.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pg_md5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_auth.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_config.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_connection_pool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_error.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_hba.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_ip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_params.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_path.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_process_query.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_proto_modules.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_query_cache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_rewrite_outfuncs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_rewrite_query.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_sema.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_shmem.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_signal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_stream.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_system.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ps_status.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recovery.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +.l.c: + $(LEXCOMPILE) $< + sed '/^#/ s|$(LEX_OUTPUT_ROOT)\.c|$@|' $(LEX_OUTPUT_ROOT).c >$@ + rm -f $(LEX_OUTPUT_ROOT).c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +install-man8: $(man8_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man8dir)" || $(mkdir_p) "$(DESTDIR)$(man8dir)" + @list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.8*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 8*) ;; \ + *) ext='8' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst"; \ + done +uninstall-man8: + @$(NORMAL_UNINSTALL) + @list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.8*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 8*) ;; \ + *) ext='8' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man8dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man8dir)/$$inst"; \ + done +install-pkgdataDATA: $(pkgdata_DATA) + @$(NORMAL_INSTALL) + test -z "$(pkgdatadir)" || $(mkdir_p) "$(DESTDIR)$(pkgdatadir)" + @list='$(pkgdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pkgdataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgdatadir)/$$f'"; \ + $(pkgdataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgdatadir)/$$f"; \ + done + +uninstall-pkgdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgdata_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \ + done +install-sysconfDATA: $(sysconf_DATA) + @$(NORMAL_INSTALL) + test -z "$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)" + @list='$(sysconf_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sysconfDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(sysconfdir)/$$f'"; \ + $(sysconfDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(sysconfdir)/$$f"; \ + done + +uninstall-sysconfDATA: + @$(NORMAL_UNINSTALL) + @list='$(sysconf_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sysconfdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sysconfdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/doc $(distdir)/redhat $(distdir)/sample $(distdir)/sql $(distdir)/sql/pgpool-recovery $(distdir)/test/jdbc $(distdir)/test/jdbc/expected $(distdir)/test/parser $(distdir)/test/parser/expected $(distdir)/test/parser/input + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(sysconfdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f pool_config.c +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-man install-pkgdataDATA + +install-exec-am: install-binPROGRAMS install-sysconfDATA + +install-info: install-info-recursive + +install-man: install-man8 + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man \ + uninstall-pkgdataDATA uninstall-sysconfDATA + +uninstall-info: uninstall-info-recursive + +uninstall-man: uninstall-man8 + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ + check-am clean clean-binPROGRAMS clean-generic clean-libtool \ + clean-recursive ctags ctags-recursive dist dist-all dist-bzip2 \ + dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-recursive distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-man8 \ + install-pkgdataDATA install-strip install-sysconfDATA \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ + pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am uninstall-man \ + uninstall-man8 uninstall-pkgdataDATA uninstall-sysconfDATA + + +pgpool.8: pgpool.8.in + sed 's,@sysconfdir\@,$(sysconfdir),g' $? >$@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..d7faaca --- /dev/null +++ b/NEWS @@ -0,0 +1,474 @@ +2.2.5 (urukiboshi) 2009/10/4 + * Version 2.2.5 + + This version fixes various bugs in 2.2.4 or before. + + * Bug fixes + + - Fix connection_count_down(). It decrements the connection + counter too much in some corner cases and causes online + recover never completes(Tatsuo) + + - Detect frontend exiting while waiting for commands complete in + other cases such as internal locks are issued and Parse + (Tatsuo) + + - Fix inifinit loop in reset_backend(Xavier Noguer, Tatsuo) + + - Fix Parse() to print actual query when it detects kind + mismatch error(Tatsuo) + + - Document enhancements(Tatsuo) + +2.2.4 (urukiboshi) 2009/8/24 + * Version 2.2.4 + + This version fixes various bugs in 2.2.3 or before. + + * Bug fixes + + - Fix possible bug introduced in pgpool-II 2.2.2. Load balance + control variables may remain not be restored and subsequent + DML/DDL call might sent to only master node(Tatsuo) + + - Send NOTICE message to frontend periodically if V2 protocol is + used. This is ifdef out since it affectes visible change to + applications. 2.2.3 unconditionaly sends param packet to + client even it uses version 2 protocol, which is apparentlt + wrong. Also tweak checking period from 1 second to 30 seconds + since 1 second seems too aggressive(Tatsuo) + + - Block signals before forking children rather after. Otherwise + parent will be killed by failover signal if it receives a + signal before establishing signal handler(Tatsuo) + + - Remove unnecessary spaces and tabs at the end of line(Jun Kuriyama) + +2.2.3 (urukiboshi) 2009/8/11 + * Version 2.2.3 + + This version fixes various bugs in 2.2.2 or before. + + * Bug fixes + + - Fix child process death if one of backends is not available(Tatsuo). + + - Fix various parallel query bugs(Yoshiharu Mori) + + - Fix message corruption for kid mismatch error(Akio Ishida) + + - Now stetmemt_time works(Tatsuo) + + - Enhance health checking to detect postmaster stopping by + SIGSTOP(Tatsuo) + + - Detect frontend abnormal exiting while waiting for reply from + backend. This only works with V3 protocol(Tatsuo) + + - Do not start internal transaction if command is CLUSTER + without arguments(Tatsuo) + + - Fix bug with COPY FROM in that backend process remains after + COPY failed(Tatsuo) + + * Enhancements + + - Show last query for extended protocol(Akio Ishida) + + - Allow to compile sql/pgpool-recovery/pgpool-recovery.c with + PostgreSQL 8.4(Tatsuo) + +2.2.2 (urukiboshi) 2009/5/5 + * Version 2.2.2 + + This version fixes various bugs in 2.2.1 or before. Please note + that an importan fix is made to avoid data incositency risk, + which could happen when client does not exit gracely(without + sending "X" packet) while pgpool is trying to send data to + it. This could happen with all version of pgpool-II. + + * Bug fixes + + - Ignore write error on frontend connection. This is needed to + continue processing with backend, otherwise we risk data + incositency(Tatsuo) + + - Fix bug introduced in 2.2.1 (In master slave mode, sometimes + DEALLOCATE fails). If prepared statement reused, pgpool + hangs(Toshihiro) + + - Fix pgpool crash when SQL command PREPARE and protocol level + EXECUTE are mixed. The bug was introduced in 2.2(Tatsuo) + + - Avoid "unexpected EOF on client connection" error in PostgreSQL + when reset query fails(Tatsuo) + +2.2.1 (urukiboshi) 2009/4/25 + * Version 2.2.1 + + This version fixes various bugs in 2.2. + + * Bug fixes + + - In master slave mode, sometimes DEALLOCATE fails. This is + caused by that the first PREPARE was not executed on the + slave(Toshihiro) + + - Update pgpool.spec along with related files(Devrim) + + - Fix inser_lock so that it is ignored when protocol version is + 2(Tatsuo) + + - Remove excessive log messages regarding parameter change notice(Tatsuo) + + - Add missing files to doc(Tatsuo) + +2.2 (urukiboshi) 2009/2/28 + * Version 2.2 + + This version enhances SERIAL data type handling and on line + recovery. Also an important bug, serializable transactions could + cause data inconsistency among DB nodes, is fixed. Query + cancelation, which never worked since pgpool-II was born, is + finally fixed. + + * New features/enhancements + + - With insert_lock, now a table is locked only if it has + SERIAL data type and now the default value for insert_lock + is true(Tatsuo) + + - Start internal transaction other than INSERT, UPDATE, DELETE + and SELECT to keep node consistency(Tatsuo) + + - Add client_idle_limit_in_recovery directive. This will + prevent 2nd stage of on line recovery from not going forward + by idle clients sitting forever(Tatsuo) + + - Add pid_file_name directive which specifies a path to the + file containing pgpool process id. "logdir" is no more used(Tatsuo) + + - Allow to load balance DECLARE, FETCH and CLOSE(Tatsuo) + + - Add -d option to pcp commands(Jun Kuriyama) + + - Enahnce kind mismatch error message to include originarl + query string(Tatsuo) + + * Bug fixes + + - Close all file descriptors when running in daemon mode. + Otherwise we inherit sockets from apache when it's + started by pgpoolAdmin. This results in that port 80 is + occupied for example. Patch provided by Akio + Ishida. Also add chdir("/"). This is always good for + daemon programs(Tatsuo) + + - Allow MD5 authentication in raw mode as stated in docs(Tatsuo) + + - Check transaction serialization failure error in + serializable mode and abort all nodes if so. Otherwise + we allow data inconsistency among DB nodes(Tatsuo). + + See following scenario: (M:master, S:slave) + + M:S1:BEGIN; + M:S2:BEGIN; + S:S1:BEGIN; + S:S2:BEGIN; + M:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + M:S2:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + S:S2:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + M:S1:UPDATE t1 SET i = i + 1; + S:S1:UPDATE t1 SET i = i + 1; + M:S2:UPDATE t1 SET i = i + 1; <-- blocked + S:S1:COMMIT; + M:S1:COMMIT; + M:S2:ERROR: could not serialize access due to concurrent update + S:S2:UPDATE t1 SET i = i + 1; <-- success in UPDATE and data becomes inconsistent! + + - avoid kind mismatch error caused by "SET TRANSACTION + ISOLATION LEVEL must be called before any query"(Tatsuo). + + This could happen in following scenario: + + M:S1:BEGIN; + S:S1:BEGIN; + M:S1:SELECT 1; <-- only sent to MASTER + M:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + M: <-- error + S: <-- ok since no previous SELECT is sent. kind mismatch error occurs! + + - Process status display has extra space on FreeeBSD(Jun Kuriyama) + + - Fix incorrect kind mismatch detection case. e.g: BEGIN; + BEGIN; (Tatsuo) + + - If PostgreSQL sends lots of DEBUG message, sometimes pgpool + complains: + 2008-11-08 22:41:53 ERROR: pid 23744: do_command: backend does not + return ReadyForQuery. This due to a wrong assumption for the + client/server protocol(Tatsuo) + + - Fix the case when sending an erronous query to abort + transaction. It assumed that after sending an error query, + always ReadyForQuery came right after that. If some + debugging or logging verboseness is set, PostgreSQL might + sends NOTICE before ReadyForQuery(Tatsuo) + + - Query cancelation now works. It never worked since pgpool-II + was born(Tatsuo) + + - Fix online recovery to wait for failback done before + allowing to accept connections from clients. It was supposed + to work like this but actually was not since the day 0 when + online recovery was born. Without the fix there could be + potential data inconsistency among DB nodes(Tatsuo) + + - Fix pgpool-II crash after on line recovery. This happens + after the failback process adds a recovered node which has + no connection to the node(Tatsuo) + + - Fix pgpool-II errors when postgresql.conf is reloaded. This + was caused by parameter status packet sent asynchronously + from backend, which indicates the internal setting of + backend has been changed(Tatsuo) + + * Incompatible changes + + - Always fail over and restart all children. Before we do + restart only if master has not been changed. This is + wrong. If we have trouble with network cable or something, + TCP/IP stack keeps on retrying for long time and the only + way to prevent it is restarting process(Tatsuo) + + - "logdir" is no more used. Instead use + "pid_file_name"(Tatsuo) + + - Default value for insert_lock is now true(Tatsuo) + +2.1 (inamiboshi) 2008/7/25 + * Version 2.1 + + * New feature + - Add '%m' format to failover_command and failback_command to + obtain new master node ID. (Yoshiyuki) + - Add '%m' format to failover_command and failback_command to + obtain old master node ID. (Yoshiyuki) + - Add new directive "recovery_timeout" to specify recovery + timeout in second. (Taiki) + - Add optino '-v' to print pgpool version. (Yoshiyuki) + + * Incompatibility + - Restrict pgpool_recovery() and pgpool_remote_start() + functions to superusers. (Yoshiyuki) + - Do not create a connection pool to standby node in raw + mode. (Yoshiyuki) + - Remove "replication_timeout" parameter. (Yoshiyuki) + - This enabled if replication_strict was false. However, + replication_strict was already removed. + - Ignore timeout argument of pcp commands. (Taiki) + - Do not replicate "COPY TO STDOUT" when replicate_select is + false. (Yoshiyuki) + + * Bug fix + ** General + - Fix crash when CloseComplete message was + received. (Yoshiyuki) + - Improve network I/O routine. (Yoshiyuki) + - Fix compile errors on Solaris 10. (Yoshiyuki) + - Improve log messages of health check and recovery. (Tatsuo) + - Change error level of the "failed to read kind from + frontend" message from ERROR to LOG. (Yoshiyuki) + - Fix failover failure in raw mode. (Taiki) + - Fix zombie process bug. (Yoshiyuki) + - Fix health_check_timeout to work correctly. (Kenichi Sawada) + - Support ps status on FreeBSD. (ISHIDA Akio) + - Improve bind(2) failure report. (Jun Kuriyama) + - Improve error message when client authentication + failed. (Tatsuo) + + ** Replication + - Fix replicate_select to work correctly. (Tatsuo) + - Fix a wrong rollback bug with extended query. (Yoshiyuki) + - Fix a bug with asynchronous query. (Yoshiyuki) + - Fix hint clause handling like /*REPLICATION*/ with extended + query. (Yoshiyuki) + - Fix crash of "DEALLOCATE ALL". (Yoshiyuki) + - Fix hang up when a backend node does immediate + shutdown. (Yoshiyuki) + - Fix hang up online recovery in high load. (Yoshiyuki) + - Fix hang up with extended query protocol when SELECT is + failed inside a transaction block. (Yoshiyuki) + + ** Master Slave + - Fix load balancing to work correctly. (Yoshiyuki) + - Fix crash if SET, PREPARE or DEALLOCATE is executed inside a + transaction block. (Yoshiyuki) + + ** Parallel query + - Fix INSERT failure. (Yoshiharu) + - Fix syntax error when a query contains "AS" in FROM + clause. (sho) + - Fix Hung up when two or more statment was executed + in parallel mode (Yoshiharu) + - Fix Query rewriting of Join Expression and DISTINCT ON + (Yoshiharu) + +2.0.1 (hikitsuboshi) 2007/11/21 + * Version 2.0.1 + * Fix process down with UPDATE or DELETE query.(Yoshiyuki) + * Send a syntax query only to a master node if master_slave is + true.(Yoshiyuki) + +2.0 (hikitsuboshi) 2007/11/16 + * Version 2.0 + + * Incompatibility since pgpool-II 1.x + - the default value for ignore_leading_white_space is now + true(Yoshiyuki) + - replicate_strict is removed. The value is always + true(Yoshiyuki) + + * General + - Allow to reload pgpool.conf(Yoshiyuki) + - The paraser is now compatible with PostgreSQL 8.3(Yoshiyuki) + - Add new directive "failover_command" to specify command when + a node is detached(Yoshiyuki) + - Add new directive "client_idle_limit" to specify the time out since + the last command is arrived from a client(Tatsuo) + + * Replication + - Always start a new transaction even if the query is not in + an explicit transaction to enhance the reliabilty of + replication(Yoshiyuki) + - Enhance the performance of replication for write + queries. Now the worst case is 1/2 compared with single DB + node regardless the number of DB nodes. Previous release + tends to degrade according to the numer of DB + nodes(Yoshiyuki) + - Add "online recovery" which allows to add a DB node and sync + with other DB nodes without stopping the pgpool + server(Yoshiyuki) + - Abort a transaction if INSERT, UPDATE and DELETE reports + different number of result rows(Yoshiyuki) + + x=# update t set a = a + 1; + ERROR: pgpool detected difference of the number of update tuples + HINT: check data consistency between master and other db node + + - If the results from DB nodes do not match, select the + possible correct result by "decide by majority". Previous + release always trust the result of the master DB + node(Yoshiyuki) + - Allow load balance in V2 frontend/backend protocol(Yoshiyuki) + + * Parallel query + - Allow "partial replication" to enhance the performance of + the parallel query(Yoshiharu) + +1.3 (sohiboshi) 2007/10/23 + * Version 1.3 + * Add new "authentication_timeout" directive, being the default + value is 60. (Yoshiyuki) + - Maximum time in seconds to complete client authentication. + * Reject a connection when startup packet length is greater than + 10,000 byte. (Yoshiyuki) + * Fix invalid memory access when pgpool processed DEALLOCATE + statement. (Yoshiyuki) + * Fix hang up in load balance mode. (Yoshiyuki) + - This was introduced in V1.2. + * Fix segmentation fault in 64-bit environment when query cache + is enable. (Yoshiyuki) + +1.2.1 (tomoboshi) 2007/09/28 + * Version 1.2.1 + * Fix deadlock while processing Parse message. (Yoshiyuki) + * Fix memory leak in reset_prepared_list(). (Yoshiyuki) + * Fix compile error on FreeBSD 4.11. (Yoshiyuki) + * SET, PREPARE and DEALLOCATE statements are replicated in + master/slave mode. (Yoshiyuki) + +1.2 (tomoboshi) 2007/08/01 + * Version 1.2 + * Add new "replicate_select" directive, being the default value + is false. (Yoshiyuki) + - If it is true, SELECT query is replicated. This behavior is + same as V3.2 or earlier. + * Improve signal handling. (Yoshiyuki) + - Occasionaly, zombie processes were remained. Or processes + were unstable. + * Fix hang up when SELECT was error inside a transaction + block. The bug was introduced in V3.3. (Yoshiyuki) + * Fix PREPARE/EXECUTE handling in master slave mode. (Yoshiyuki) + * Fix "kind mismatch error" when deadlock error + * Fix hang up and SEGV in extended query protocol when a warning + SQL like "SELECT '\'';" executed. (Yoshiyuki) + * Fix hang up when postmaster did fast or immediate + shutdown. (Yoshiyuki) + * Fix memory leak when connection cache was full. (Yoshiyuki) + * Load balancing node is selected when a session + starts. (Yoshiyuki) + * Fix buffer overrun if connection_life_time was + set. (Yoshiyuki) + +1.1.1 (amiboshi) 2007/6/15 + * Version 1.1.1 + * Fix "kind mismatch" bug when load_balance_mode is true + introduced in 1.1 (Yoshiyuki) + * Fix deadlock with extended query protocol(Yoshiyuki) + * Fix numerous bugs with protocol V2(Yoshiyuki) + +1.1 (amiboshi) 2007/5/25 + * Version 1.1 + * Support HBA authentication(Taiki) + * Support log_connections(Taiki) + * Support log_hostname(Taiki) + * Show pgpool status in ps command(Taiki) + * Fix compile error on MacOS X(Yoshiyuki) + * Allow load balancing with extended protocol(Yoshiyuki) + * Improve replication. SELECT nextval() and SELECT setval() are + now replicated. (Yoshiyuki) + * Change SELECT query is only sent to the master node. (Yoshiyuki) + - Use /*REPLICATION*/ comment to repliate a SELECT query. + * Fix unexpected failover error due to receiving an interrupt + signal while connecting to the backend. (Yoshiyuki) + * Add "pgpool.pam" file, for PAM configuration file, to be + installed under "$PREFIX/share/pgpool-II/". (Taiki) + * Fix core dump when executing large SQL. (Yoshiyuki) + +1.0.2 (suboshi) 2007/02/12 + * Version 1.0.2 + * Fix bug when executing large SQL to prevent pgpool goes into + infinite loop(Yoshiyuki) + * Fix bug with extended protocol handling(Yoshiyuki) + * Enhance log for failover and failback(Tatsuo) + * Add backend status info to show pool_status(Tatsuo) + * Fix UPDATE/DELETE returns wrong number of rows(Tatsuo) + * Fix configure fails to link libpq when used with older + version of gcc(Yoshiyuki) + * Fix DEALLOCATE treatment when used with PHP:PDO DBD-Pg(Yoshiyuki) + * Do not load balance SELECT FOR UPDATE, SELECT INTO and SELECT + with comments. This behavior is compatible with + pgpool-I(Yoshiyuki) + * Obtain path to libpq using pg_config. --with-pgsql will be + removed in next version(Yoshiyuki) + * When reusing connection pool, reconnect to backend if the + socket is broken(Yoshiyuki) + * Fix error with configure when used with PostgreSQL + 7.4(Yoshiyuki) + +1.0.1 (suboshi) 2006/09/22 + * Version 1.0.1 + * This version fixes bugs including master/slave not being + working, deadlock problem in COPY FROM STDIN. Also documents + are improved. + +1.0.0 (suboshi) 2006/09/08 + * Initial release + +Local Variables: +mode: outline +End: diff --git a/README b/README new file mode 100644 index 0000000..091b0fd --- /dev/null +++ b/README @@ -0,0 +1 @@ +See the file doc/pgpool-en.html diff --git a/README.euc_jp b/README.euc_jp new file mode 100644 index 0000000..179766f --- /dev/null +++ b/README.euc_jp @@ -0,0 +1 @@ +doc/pgpool-ja.html ¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£ diff --git a/TODO b/TODO new file mode 100644 index 0000000000000000000000000000000000000000..54825ffbd3566a0cdbf826fb7b3f29c90dd5e5fb GIT binary patch literal 10178 zcmeHN>vG%H5$<2(DR!t#OeqpYfEQ8p$O$FU4l^<-lXTK1O*tTNNWuaE1~|}Vn#ajY z^iLlluhBn!h<$rc~a>k}`uxEGA-ggf_`&yW`2%2 zx|%kK#_xqCoAkr2LVPlf-~33I(Ucx$!lNj3yeY-6$@FZxeY*(6!VHA=D)8q`vW4e_ zUkTd@r5Thgf36MvCdG`V_`X_9Cw}DF!Bfc(rrNbBMU%c0_AwcCYJn89O?sngRGLPa zz9{2a(+6k4|H)Z7|7HJ1gmI zrM5-eiUG^_JXo^hd(e9niVIl5#0f$fo55(}2eHiYYzgOHz=Sp|V?`U9sgxVqK`mjk zYM)nX%%<&+teNB5RE#|5aWt_nD#utClK-qKJ*)RXP&Ll9gL;Z!TsKTc07mXc=7*2~ zA2Y`$GdCR%m>QM3c5s$rvaIt8V}gAzL_ozXq+T~5+(rs&>$=ULO1Pmb#Da>UfUMRC z=nbQ)9h|4z%<-9`z~rfD22<;zeoXkjhu@7SjrzG+j?bDfSZg%2;?y1=YTB&|4jeP& zOb}v%6m#LpQmKTvkZSKGy$KOiaw~;G{;|^?wEIKqbca2X0*aL8*o6t2hxBdh=3RS0 z#n1G^>?SH22Zt|7&)}hAm6ytyrI{e{YVEn;Me|5HE`s(t=*>E)Uaqgh^w(h) z(~&8CXC3YjYjEG^o)Zz)a*Ho%FQB|KUXqtXl3=cCbHrV9Do8#p1d>u+!0!T%SDbC; z$ZWwqoc;kZNFYwILwJWdOfRXEd)|e)dj6Z3J56fO7xGCZ-!uuVQ`>R)wR6rQvwAa{s2zjZI5;s0E0 z&I?J;$$RM*d7!-{xfjq-Ywxz>^;CG7H?_Qxt>qAv;B`0b#54NP1Cd! zYT5R(05};|3 z?h|7l%mBVhVoOSBY`J|wO@M!>_>)I2z@v~i#)Y|1#g{cRJtVU!8UvLL!=GGq?%srK zhbf`l2)V?tW{k&Ju?l|$;k7$ ztC7I`;NaEV3?<4LB>lPh-VYr41VpP|F5Y^@*ppPhfJBYDZWzt@-P{QkIzX6nA16wB z@36!|3LS14To57EaMObsqT+mad)*qgX&jiIHN#N{?IDfFri(`bL>J2k`hrd>4NN4y z`?}r71`xj>{Y4?BZ3}6lAVpz=X-4^ns~<`KVelg}+d-)-#5~L@if0lbr0=@^gA%fijN>XryYHj#S%vl-NV8mO!|^X_N1{PbE#`VaZ9^I58@Oc}cn6G<3S@y+$2G zES_3j*PG-4d6S%Q6h`P0(GdrP8Y#k>?`>kJtYI+DQVcw+8OSGyG1=Z3^p5Gx^`G`Y zQvVc4py~K5yE%cxi*n|`@X>6tj^RF`?{d)$S1?Kj`qC4!1Ajqr6B*9@2tE85CA3E- zNf<(C!tOm9yS{bzB`Xl<-beNnIA#J0-iO9*uXi&V3|qr@16FDvN8IHEp6QO3Bz&)^ zz^;1TZu@H3>2*i^Oh<{~9#hx11s!?#|4{p@_6#VF1wm_2S*aR;CfZz^2T*Yr(zsmQ4e^uwrb7Pzs^eH@OjqyTDm-1O!L~li0%b z6AT5*C+vKfU+rnGDym`2c1#ji8TK^EDkK^rp3(B*zkKk$ZH2GWzcWh-6103ny57G%k;B}4{>yhaaEHuew^60Y9bA?8GBvhbHnhr zt5i?ZAu0%DFnEoB7cFRlbi{)Kq*LV35HW{?hu)~2omZ-x=iY_;19IG(zc?RRD$H`u z=j=xa7znn0;uB3uRf6yRxr;G>oL06PPUBM02!NY|B9{43Q;< zO=`3%^`e7>C=WNn9xxi)F{bW|3MDR9l?R)yx_m)&hXaS}y4{T}d&b|*+V3^N-E8h} zf+#!GROdzdWtk|&!o8}AWzCzfbl2)!6rNo!Jlm@9L`jP5GZH*U!^Hq%gLRiJI;q#VI2Hn*>P%1=%fOjp+#K><;PQh@ z33}D)+_bMXRZ)bdhYkdHGmzRgAhostX%kg{?z4^wZHbiw;D-#5dbe;FQ*>T=xOE^G z*Dk_W*R(6Z43J`6`ER%|(WtFH86fRq$48?x@+YM0RdvS#Q&B0TM7wvS`k9%Fg@E0t zTjFfHDuW1hqoeA^QCv=`l@vydLRAHVmK%y=;N#|Il=NTmDzu5I?qt~pFZaMOV*JS^ zv^{!6;U4oH7RN&Q7yTJYkXtjp;p02&6gX1~12tb>9VdP69p82lE1^Q5~Bb~%Q0PSo%1anm_TQaT?LK?!+z&#h<>54H@bP`N@q3hU^)XIO|FB% zLE^noAZh`$y6|GUzC`f)(UWpbVQQQHf&t* zD}{xQj8yhX809zvaeGrp9krIHq=Q`;2H*z8L6^T2MMt%Z2q(DcOvOVc(}bb1497f? z2!)LABXAI06{vPH7NDB$ps!RD8NOABuW4dbEqe~B17vRAA<3dp^Su)nx5Yq-Ig1Z% zJ;9z}R7!OocM8c70`XIXSqy~5@|&@GUFVKB#;9?PJ@+NtLUL1!i&eBxtjmdmu)I{Y znjR>N=}hRlGq`H?uc>u&!;v@#&b)yduCdjeWaJ`mD@)Aut)PuR0i`a*L}jKFcQ?d?DaXjBq@Uz`A`|Al(sQD8w_q>hYOCgD??>D ztMkQ~#(`uM-h>O)Z8N^4k5m({R%APpCXuIp7l3O>`Sc}Ye8bvcpI)f3P$YQqb%5wO ziI8$;k+l5>LOMr;z5_Ip4HSS4y*~k zvDIeKarhs!-@a>iui7irYXH5@_3B+l6{&3DE6N1ZZ7>d>Q$B1S$s0Yf#PFzi$Un@9 z|KcO}(Cxz)mY%Spkov|*$F)CHI~5}iP#hUS2lK}4T#Zc?zf)p!;atK!#@NJUk^?Wt z=Xj*)!_$PcO7M+|zfz@YpP2BK>Z6hgyNV?Ybc-1s3LQ6&T?}_C0+c*p1v(dr?z!Je zyqIShj|v(Vx;hZJRz`y$kdB(Nid?;hq>uw3KGtG_A`N#iU_@s4_N#vH4UWf^q^8;9 zivx(2$0`{6O!$tNMWAyOxB16B_^B7Y_pyza4Yh1=inH|+erIAE`2U5LmhoJUs9HfpfS@^e+*%Gd&$Bl7Os+D tL52BL`tJrPXcMWk629qmx@;oXzNHlX9fsFv#GUcNT2Sk@gDD1H{0k<(Y?}Z8 literal 0 HcmV?d00001 diff --git a/ac_func_accept_argtypes.m4 b/ac_func_accept_argtypes.m4 new file mode 100644 index 0000000..917d59a --- /dev/null +++ b/ac_func_accept_argtypes.m4 @@ -0,0 +1,85 @@ +# $PostgreSQL: pgsql/config/ac_func_accept_argtypes.m4,v 1.6 2003/11/29 19:51:17 pgsql Exp $ +# This comes from the official Autoconf macro archive at +# +# (I removed the $ before the Id CVS keyword below.) + + +dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES +dnl +dnl Checks the data types of the three arguments to accept(). Results are +dnl placed into the symbols ACCEPT_TYPE_RETURN and ACCEPT_TYPE_ARG[123], +dnl consistent with the following example: +dnl +dnl #define ACCEPT_TYPE_RETURN int +dnl #define ACCEPT_TYPE_ARG1 int +dnl #define ACCEPT_TYPE_ARG2 struct sockaddr * +dnl #define ACCEPT_TYPE_ARG3 socklen_t +dnl +dnl This macro requires AC_CHECK_HEADERS to have already verified the +dnl presence or absence of sys/types.h and sys/socket.h. +dnl +dnl NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES +dnl macro. Credit for that one goes to David MacKenzie et. al. +dnl +dnl @version Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $ +dnl @author Daniel Richard G. +dnl + +# PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3 +# is a pointer type. That's kind of useless because then you can't +# use the macro to define a corresponding variable. We also make the +# reasonable(?) assumption that you can use arg3 for getsocktype etc. +# as well (i.e., anywhere POSIX.2 has socklen_t). +# +# arg2 can also be `const' (e.g., RH 4.2). Change the order of tests +# for arg3 so that `int' is first, in case there is no prototype at all. +# +# Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t' +# which is *not* 'socklen_t *'). If we detect that, then we assume +# 'int' as the result, because that ought to work best. +# +# On Win32, accept() returns 'unsigned int PASCAL' + +AC_DEFUN([AC_FUNC_ACCEPT_ARGTYPES], +[AC_MSG_CHECKING([types of arguments for accept()]) + AC_CACHE_VAL(ac_cv_func_accept_return,dnl + [AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl + [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl + [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl + [for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do + for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do + for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do + for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do + AC_TRY_COMPILE( +[#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);], + [], [ac_not_found=no; break 4], [ac_not_found=yes]) + done + done + done + done + if test "$ac_not_found" = yes; then + AC_MSG_ERROR([could not determine argument types]) + fi + if test "$ac_cv_func_accept_arg3" = "void"; then + ac_cv_func_accept_arg3=int + fi + ])dnl AC_CACHE_VAL + ])dnl AC_CACHE_VAL + ])dnl AC_CACHE_VAL + ])dnl AC_CACHE_VAL + AC_MSG_RESULT([$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *]) + AC_DEFINE_UNQUOTED(ACCEPT_TYPE_RETURN, $ac_cv_func_accept_return, + [Define to the return type of 'accept']) + AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1, $ac_cv_func_accept_arg1, + [Define to the type of arg 1 of 'accept']) + AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2, $ac_cv_func_accept_arg2, + [Define to the type of arg 2 of 'accept']) + AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3, $ac_cv_func_accept_arg3, + [Define to the type of arg 3 of 'accept']) +]) diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..dd819f5 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,7277 @@ +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 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. + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + +# serial 48 AC_PROG_LIBTOOL + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +AC_DEFUN([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +AC_DEFUN([_LT_COMPILER_BOILERPLATE], +[ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +AC_DEFUN([_LT_LINKER_BOILERPLATE], +[ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* +])# _LT_LINKER_BOILERPLATE + + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_AC_SYS_LIBPATH_AIX + + +# _LT_AC_SHELL_INIT(ARG) +# ---------------------- +AC_DEFUN([_LT_AC_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_AC_SHELL_INIT + + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[_LT_AC_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string=`eval $cmd`) 2>/dev/null && + echo_test_string=`eval $cmd` && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +])])# _LT_AC_PROG_ECHO_BACKSLASH + + +# _LT_AC_LOCK +# ----------- +AC_DEFUN([_LT_AC_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) LD="${LD-ld} -64" ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; + ]) +esac + +need_locks="$enable_libtool_lock" + +])# _LT_AC_LOCK + + +# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED]) +AC_CACHE_CHECK([$1], [$2], + [$2=no + ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $rm conftest* +]) + +if test x"[$]$2" = xyes; then + ifelse([$5], , :, [$5]) +else + ifelse([$6], , :, [$6]) +fi +])# AC_LIBTOOL_COMPILER_OPTION + + +# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ------------------------------------------------------------ +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], +[AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + ifelse([$4], , :, [$4]) +else + ifelse([$5], , :, [$5]) +fi +])# AC_LIBTOOL_LINKER_OPTION + + +# AC_LIBTOOL_SYS_MAX_CMD_LEN +# -------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], +[# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +])# AC_LIBTOOL_SYS_MAX_CMD_LEN + + +# _LT_AC_CHECK_DLFCN +# ------------------ +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h)dnl +])# _LT_AC_CHECK_DLFCN + + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# --------------------------------------------------------------------- +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + + +# AC_LIBTOOL_DLOPEN_SELF +# ---------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + + +# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) +# --------------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler +AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* +]) +])# AC_LIBTOOL_PROG_CC_C_O + + +# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) +# ----------------------------------------- +# Check to see if we can do hard links to lock some files if needed +AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], +[AC_REQUIRE([_LT_AC_LOCK])dnl + +hard_links="nottested" +if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS + + +# AC_LIBTOOL_OBJDIR +# ----------------- +AC_DEFUN([AC_LIBTOOL_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +])# AC_LIBTOOL_OBJDIR + + +# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) +# ---------------------------------------------- +# Check hardcoding attributes. +AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_AC_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ + test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ + test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_AC_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_AC_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_AC_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH + + +# AC_LIBTOOL_SYS_LIB_STRIP +# ------------------------ +AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], +[striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) +fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +])# AC_LIBTOOL_SYS_LIB_STRIP + + +# AC_LIBTOOL_SYS_DYNAMIC_LINKER +# ----------------------------- +# PORTME Fill in your ld.so characteristics +AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], +[AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi +])# AC_LIBTOOL_SYS_DYNAMIC_LINKER + + +# _LT_AC_TAGCONFIG +# ---------------- +AC_DEFUN([_LT_AC_TAGCONFIG], +[AC_ARG_WITH([tags], + [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], + [include additional configurations @<:@automatic@:>@])], + [tagnames="$withval"]) + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + AC_MSG_WARN([output file `$ofile' does not exist]) + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) + else + AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) + fi + fi + if test -z "$LTCFLAGS"; then + eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in + "") ;; + *) AC_MSG_ERROR([invalid tag name: $tagname]) + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + AC_MSG_ERROR([tag name \"$tagname\" already exists]) + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_LIBTOOL_LANG_CXX_CONFIG + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + AC_LIBTOOL_LANG_F77_CONFIG + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + AC_LIBTOOL_LANG_GCJ_CONFIG + else + tagname="" + fi + ;; + + RC) + AC_LIBTOOL_LANG_RC_CONFIG + ;; + + *) + AC_MSG_ERROR([Unsupported tag name: $tagname]) + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + AC_MSG_ERROR([unable to update list of available tagged configurations.]) + fi +fi +])# _LT_AC_TAGCONFIG + + +# AC_LIBTOOL_DLOPEN +# ----------------- +# enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], + [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_DLOPEN + + +# AC_LIBTOOL_WIN32_DLL +# -------------------- +# declare package support for building win32 DLLs +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_WIN32_DLL + + +# AC_ENABLE_SHARED([DEFAULT]) +# --------------------------- +# implement the --enable-shared flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([shared], + [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]AC_ENABLE_SHARED_DEFAULT) +])# AC_ENABLE_SHARED + + +# AC_DISABLE_SHARED +# ----------------- +# set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no) +])# AC_DISABLE_SHARED + + +# AC_ENABLE_STATIC([DEFAULT]) +# --------------------------- +# implement the --enable-static flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([static], + [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]AC_ENABLE_STATIC_DEFAULT) +])# AC_ENABLE_STATIC + + +# AC_DISABLE_STATIC +# ----------------- +# set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no) +])# AC_DISABLE_STATIC + + +# AC_ENABLE_FAST_INSTALL([DEFAULT]) +# --------------------------------- +# implement the --enable-fast-install flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([fast-install], + [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) +])# AC_ENABLE_FAST_INSTALL + + +# AC_DISABLE_FAST_INSTALL +# ----------------------- +# set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no) +])# AC_DISABLE_FAST_INSTALL + + +# AC_LIBTOOL_PICMODE([MODE]) +# -------------------------- +# implement the --with-pic flag +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default) +])# AC_LIBTOOL_PICMODE + + +# AC_PROG_EGREP +# ------------- +# This is predefined starting with Autoconf 2.54, so this conditional +# definition can be removed once we require Autoconf 2.54 or later. +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +])]) + + +# AC_PATH_TOOL_PREFIX +# ------------------- +# find a file program which can recognise shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +])# AC_PATH_TOOL_PREFIX + + +# AC_PATH_MAGIC +# ------------- +# find a file program which can recognise a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# AC_PATH_MAGIC + + +# AC_PROG_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH([gnu-ld], + [AC_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no]) +AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix3*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown +])# AC_DEPLIBS_CHECK_METHOD + + +# AC_PROG_NM +# ---------- +# find the pathname to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +])# AC_PROG_NM + + +# AC_CHECK_LIBM +# ------------- +# check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +])# AC_CHECK_LIBM + + +# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, +# it is assumed to be `libltdl'. LIBLTDL will be prefixed with +# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' +# (note the single quotes!). If your package is not flat and you're not +# using automake, define top_builddir and top_srcdir appropriately in +# the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_CONVENIENCE + + +# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl installable library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, +# and an installed libltdl is not found, it is assumed to be `libltdl'. +# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and top_srcdir +# appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, lt_dlinit, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLINCL= + fi + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_INSTALLABLE + + +# AC_LIBTOOL_CXX +# -------------- +# enable support for C++ libraries +AC_DEFUN([AC_LIBTOOL_CXX], +[AC_REQUIRE([_LT_AC_LANG_CXX]) +])# AC_LIBTOOL_CXX + + +# _LT_AC_LANG_CXX +# --------------- +AC_DEFUN([_LT_AC_LANG_CXX], +[AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) +])# _LT_AC_LANG_CXX + +# _LT_AC_PROG_CXXCPP +# ------------------ +AC_DEFUN([_LT_AC_PROG_CXXCPP], +[ +AC_REQUIRE([AC_PROG_CXX]) +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +fi +])# _LT_AC_PROG_CXXCPP + +# AC_LIBTOOL_F77 +# -------------- +# enable support for Fortran 77 libraries +AC_DEFUN([AC_LIBTOOL_F77], +[AC_REQUIRE([_LT_AC_LANG_F77]) +])# AC_LIBTOOL_F77 + + +# _LT_AC_LANG_F77 +# --------------- +AC_DEFUN([_LT_AC_LANG_F77], +[AC_REQUIRE([AC_PROG_F77]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) +])# _LT_AC_LANG_F77 + + +# AC_LIBTOOL_GCJ +# -------------- +# enable support for GCJ libraries +AC_DEFUN([AC_LIBTOOL_GCJ], +[AC_REQUIRE([_LT_AC_LANG_GCJ]) +])# AC_LIBTOOL_GCJ + + +# _LT_AC_LANG_GCJ +# --------------- +AC_DEFUN([_LT_AC_LANG_GCJ], +[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], + [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], + [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], + [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) +])# _LT_AC_LANG_GCJ + + +# AC_LIBTOOL_RC +# ------------- +# enable support for Windows resource files +AC_DEFUN([AC_LIBTOOL_RC], +[AC_REQUIRE([LT_AC_PROG_RC]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) +])# AC_LIBTOOL_RC + + +# AC_LIBTOOL_LANG_C_CONFIG +# ------------------------ +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) +AC_DEFUN([_LT_AC_LANG_C_CONFIG], +[lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF + +# Report which library types will actually be built +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_C_CONFIG + + +# AC_LIBTOOL_LANG_CXX_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) +AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], +[AC_LANG_PUSH(C++) +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Dependencies to place before and after the object being linked: +_LT_AC_TAGVAR(predep_objects, $1)= +_LT_AC_TAGVAR(postdep_objects, $1)= +_LT_AC_TAGVAR(predeps, $1)= +_LT_AC_TAGVAR(postdeps, $1)= +_LT_AC_TAGVAR(compiler_lib_search_path, $1)= + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + $as_unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + $as_unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' +else + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + AC_PROG_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +_LT_AC_TAGVAR(ld_shlibs, $1)=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes ; then + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + freebsd-elf*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + freebsd* | kfreebsd*-gnu | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + ;; + gnu*) + ;; + hpux9*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + ;; + *) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + interix3*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + linux*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc*) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC*) + # Portland Group C++ compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + m88k*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + openbsd*) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + ;; + osf3*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ + $rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. We must also pass each convience library through + # to the system linker between allextract/defaultextract. + # The C++ compiler will combine linker options so we + # cannot just pass the convience library names through + # without $wl. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + # So that behaviour is only enabled if SCOABSPATH is set to a + # non-empty value in the environment. Most likely only useful for + # creating official distributions of packages. + # This is a hack until libtool officially supports absolute path + # names for shared libraries. + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; +esac +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_AC_TAGVAR(GCC, $1)="$GXX" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_POSTDEP_PREDEP($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +])# AC_LIBTOOL_LANG_CXX_CONFIG + +# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) +# ------------------------------------ +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" +ifelse([$1], [], +[#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG], +[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) + +# Is the compiler the GNU C compiler? +with_gcc=$_LT_AC_TAGVAR(GCC, $1) + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_[]_LT_AC_TAGVAR(LD, $1) + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) + +# Commands used to build and install a shared archive. +archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) +archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) +module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" + +# Set to yes if exported symbols are required. +always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) + +# The commands to list exported symbols. +export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) + +# Symbols that must always be exported. +include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) + +ifelse([$1],[], +[# ### END LIBTOOL CONFIG], +[# ### END LIBTOOL TAG CONFIG: $tagname]) + +__EOF__ + +ifelse([$1],[], [ + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +]) +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi +])# AC_LIBTOOL_CONFIG + + +# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl + +_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI + + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDGIRSTW]]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[[]] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + + +# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) +# --------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], +[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) + ifelse([$1],[CXX],[ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc* | ecpc*) + # Intel C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC*) + # Portland Group C++ compiler. + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + newsos6) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + linux*) + case $cc_basename in + icc* | ecc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then + AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), + [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" +AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) +]) + + +# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) +# ------------------------------------ +# See if the linker supports building shared libraries. +AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], +[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +ifelse([$1],[CXX],[ + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +],[ + runpath_var= + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)= + _LT_AC_TAGVAR(archive_expsym_cmds, $1)= + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown + _LT_AC_TAGVAR(hardcode_automatic, $1)=no + _LT_AC_TAGVAR(module_cmds, $1)= + _LT_AC_TAGVAR(module_expsym_cmds, $1)= + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_AC_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + _LT_CC_BASENAME([$compiler]) + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix3*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + # see comment about different semantics on the GNU ld section + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + bsdi[[45]]*) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' + _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu | dragonfly*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + openbsd*) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; + *) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_AC_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac +])# AC_LIBTOOL_PROG_LD_SHLIBS + + +# _LT_AC_FILE_LTDLL_C +# ------------------- +# Be careful that the start marker always follows a newline. +AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ +])# _LT_AC_FILE_LTDLL_C + + +# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) +# --------------------------------- +AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) + + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) + +AC_DEFUN([LT_AC_PROG_GCJ], +[AC_CHECK_TOOL(GCJ, gcj, no) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS) +]) + +AC_DEFUN([LT_AC_PROG_RC], +[AC_CHECK_TOOL(RC, windres, no) +]) + +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +AC_DEFUN([LT_AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_MSG_RESULT([$SED]) +]) + +# Copyright (C) 2002, 2003, 2005 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. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.6])]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 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. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 +# 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. + +# serial 7 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# 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. + +# serial 8 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# 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. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# 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. + +# serial 8 + +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# 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. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 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. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 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. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 +# 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. + +# serial 5 + +# AM_PROG_LEX +# ----------- +# Autoconf leaves LEX=: if lex or flex can't be found. Change that to a +# "missing" invocation, for better error output. +AC_DEFUN([AM_PROG_LEX], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AM_MISSING_HAS_RUN])dnl +AC_REQUIRE([AC_PROG_LEX])dnl +if test "$LEX" = :; then + LEX=${am_missing_run}flex +fi]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 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. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# 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. + +# serial 4 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 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. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 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. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# 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. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 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. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 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. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/child.c b/child.c new file mode 100644 index 0000000..025dc5e --- /dev/null +++ b/child.c @@ -0,0 +1,1860 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/child.c,v 1.26.2.8 2009/09/06 03:52:12 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * child.c: child process main + * + */ +#include "config.h" + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_NETINET_TCP_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_CRYPT_H +#include +#endif + +#include "pool.h" +#include "pool_ip.h" +#include "md5.h" + +static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *timeout); +static StartupPacket *read_startup_packet(POOL_CONNECTION *cp); +static POOL_CONNECTION_POOL *connect_backend(StartupPacket *sp, POOL_CONNECTION *frontend); +static RETSIGTYPE die(int sig); +static RETSIGTYPE close_idle_connection(int sig); +static RETSIGTYPE wakeup_handler(int sig); +static RETSIGTYPE reload_config_handler(int sig); +static RETSIGTYPE authentication_timeout(int sig); +static int send_params(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +static void send_frontend_exits(void); +static int s_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password); +static void connection_count_up(void); +static void connection_count_down(void); + +/* + * non 0 means SIGTERM(smart shutdown) or SIGINT(fast shutdown) has arrived + */ +static int exit_request; + +static int idle; /* non 0 means this child is in idle state */ +static int accepted = 0; + +extern int myargc; +extern char **myargv; + +char remote_ps_data[NI_MAXHOST]; /* used for set_ps_display */ + +volatile sig_atomic_t got_sighup = 0; + +/* +* child main loop +*/ +void do_child(int unix_fd, int inet_fd) +{ + POOL_CONNECTION *frontend; + POOL_CONNECTION_POOL *backend; + struct timeval now; + struct timezone tz; + int child_idle_sec; + struct timeval timeout; + static int connected; + int connections_count = 0; /* used if child_max_connections > 0 */ + int first_ready_for_query_received; /* for master/slave mode */ + int found; + char psbuf[NI_MAXHOST + 128]; + + pool_debug("I am %d", getpid()); + + /* Identify myself via ps */ + init_ps_display("", "", "", ""); + + /* set up signal handlers */ + signal(SIGALRM, SIG_DFL); + signal(SIGTERM, die); + signal(SIGINT, die); + signal(SIGHUP, reload_config_handler); + signal(SIGQUIT, die); + signal(SIGCHLD, SIG_DFL); + signal(SIGUSR1, close_idle_connection); + signal(SIGUSR2, wakeup_handler); + signal(SIGPIPE, SIG_IGN); + +#ifdef NONE_BLOCK + /* set listen fds to none block */ + pool_set_nonblock(unix_fd); + if (inet_fd) + { + pool_set_nonblock(inet_fd); + } +#endif + + /* initialize random seed */ + gettimeofday(&now, &tz); + srandom((unsigned int) now.tv_usec); + + /* initialize systemdb connection */ + if (pool_config->parallel_mode || pool_config->enable_query_cache) + { + system_db_connect(); + if (PQstatus(system_db_info->pgconn) != CONNECTION_OK) + { + pool_error("Could not make persistent libpq system DB connection"); + } + + system_db_info->connection = make_persistent_db_connection(pool_config->system_db_hostname, + pool_config->system_db_port, + pool_config->system_db_dbname, + pool_config->system_db_user, + pool_config->system_db_password); + if (system_db_info->connection == NULL) + { + pool_error("Could not make persistent system DB connection"); + } + } + + /* initialize connection pool */ + if (pool_init_cp()) + { + child_exit(1); + } + + child_idle_sec = 0; + + timeout.tv_sec = pool_config->child_life_time; + timeout.tv_usec = 0; + + init_prepared_list(); + + for (;;) + { + int connection_reuse = 1; + int ssl_request = 0; + StartupPacket *sp; + + /* pgpool stop request already sent? */ + if (exit_request) + { + die(0); + child_exit(0); + } + + idle = 1; + accepted = 0; + + /* perform accept() */ + frontend = do_accept(unix_fd, inet_fd, &timeout); + + if (frontend == NULL) /* connection request from frontend timed out */ + { + /* check select() timeout */ + if (connected && pool_config->child_life_time > 0 && + timeout.tv_sec == 0 && timeout.tv_usec == 0) + { + pool_debug("child life %d seconds expired", pool_config->child_life_time); + /* + * Doesn't need to call this. child_exit() calls it. + * send_frontend_exits(); + */ + child_exit(2); + } + continue; + } + + /* set frontend fd to blocking */ + pool_unset_nonblock(frontend->fd); + + /* set busy flag and clear child idle timer */ + idle = 0; + child_idle_sec = 0; + + /* check backend timer is expired */ + if (backend_timer_expired) + { + pool_backend_timer(); + backend_timer_expired = 0; + } + + /* read the startup packet */ + retry_startup: + sp = read_startup_packet(frontend); + if (sp == NULL) + { + /* failed to read the startup packet. return to the accept() loop */ + pool_close(frontend); + connection_count_down(); + continue; + } + + /* cancel request? */ + if (sp->major == 1234 && sp->minor == 5678) + { + cancel_request((CancelPacket *)sp->startup_packet); + + pool_close(frontend); + pool_free_startup_packet(sp); + connection_count_down(); + continue; + } + + /* SSL? */ + if (sp->major == 1234 && sp->minor == 5679) + { + /* SSL not supported */ + pool_debug("SSLRequest: sent N; retry startup"); + if (ssl_request) + { + pool_close(frontend); + pool_free_startup_packet(sp); + connection_count_down(); + continue; + } + + /* + * say to the frontend "we do not suppport SSL" + * note that this is not a NOTICE response despite it's an 'N'! + */ + pool_write_and_flush(frontend, "N", 1); + ssl_request = 1; + pool_free_startup_packet(sp); + goto retry_startup; + } + + if (pool_config->enable_pool_hba) + { + /* + * do client authentication. + * Note that ClientAuthentication does not return if frontend + * was rejected; it simply terminates this process. + */ + frontend->protoVersion = sp->major; + frontend->database = strdup(sp->database); + if (frontend->database == NULL) + { + pool_error("do_child: strdup failed: %s\n", strerror(errno)); + child_exit(1); + } + frontend->username = strdup(sp->user); + if (frontend->username == NULL) + { + pool_error("do_child: strdup failed: %s\n", strerror(errno)); + child_exit(1); + } + ClientAuthentication(frontend); + } + + /* + * Ok, negotiaton with frontend has been done. Let's go to the next step. + */ + + /* + * if there's no connection associated with user and database, + * we need to connect to the backend and send the startup packet. + */ + + first_ready_for_query_received = 0; /* for master/slave mode */ + + /* look for existing connection */ + found = 0; + backend = pool_get_cp(sp->user, sp->database, sp->major, 1); + + if (backend != NULL) + { + found = 1; + + /* existing connection associated with same user/database/major found. + * however we should make sure that the startup packet contents are identical. + * OPTION data and others might be different. + */ + if (sp->len != MASTER_CONNECTION(backend)->sp->len) + { + pool_debug("pool_process_query: connection exists but startup packet length is not identical"); + found = 0; + } + else if(memcmp(sp->startup_packet, MASTER_CONNECTION(backend)->sp->startup_packet, sp->len) != 0) + { + pool_debug("pool_process_query: connection exists but startup packet contents is not identical"); + found = 0; + } + + if (found == 0) + { + /* we need to discard existing connection since startup packet is different */ + pool_discard_cp(sp->user, sp->database, sp->major); + backend = NULL; + } + } + + if (backend == NULL) + { + /* create a new connection to backend */ + connection_reuse = 0; + + if ((backend = connect_backend(sp, frontend)) == NULL) + { + connection_count_down(); + continue; + } + + /* in master/slave mode, the first "ready for query" + * packet should be treated as if we were not in the + * mode + */ + if (MASTER_SLAVE) + first_ready_for_query_received = 1; + } + + else + { + int i, freed = 0; + /* + * save startup packet info + */ + for (i = 0; i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i)) + { + if (!freed) + { + pool_free_startup_packet(backend->slots[i]->sp); + freed = 1; + } + backend->slots[i]->sp = sp; + } + } + + /* reuse existing connection to backend */ + + if (pool_do_reauth(frontend, backend)) + { + pool_close(frontend); + connection_count_down(); + continue; + } + + if (MAJOR(backend) == 3) + { + if (send_params(frontend, backend)) + { + pool_close(frontend); + connection_count_down(); + continue; + } + } + + /* send ReadyForQuery to frontend */ + pool_write(frontend, "Z", 1); + + if (MAJOR(backend) == 3) + { + int len; + char tstate; + + len = htonl(5); + pool_write(frontend, &len, sizeof(len)); + tstate = TSTATE(backend); + pool_write(frontend, &tstate, 1); + } + + if (pool_flush(frontend) < 0) + { + pool_close(frontend); + connection_count_down(); + continue; + } + + } + + connected = 1; + + /* show ps status */ + sp = MASTER_CONNECTION(backend)->sp; + snprintf(psbuf, sizeof(psbuf), "%s %s %s idle", + sp->user, sp->database, remote_ps_data); + set_ps_display(psbuf, false); + + if (MAJOR(backend) == PROTO_MAJOR_V2) + TSTATE(backend) = 'I'; + + if (pool_config->load_balance_mode) + { + /* select load balancing node */ + backend->info->load_balancing_node = select_load_balancing_node(); + } + + /* query process loop */ + for (;;) + { + POOL_STATUS status; + + status = pool_process_query(frontend, backend, 0, first_ready_for_query_received); + + sp = MASTER_CONNECTION(backend)->sp; + + switch (status) + { + /* client exits */ + case POOL_END: + /* + * do not cache connection if: + * pool_config->connection_cahe == 0 or + * database name is template0, template1, postgres or regression + */ + if (pool_config->connection_cache == 0 || + !strcmp(sp->database, "template0") || + !strcmp(sp->database, "template1") || + !strcmp(sp->database, "postgres") || + !strcmp(sp->database, "regression")) + { + pool_close(frontend); + pool_send_frontend_exits(backend); + pool_discard_cp(sp->user, sp->database, sp->major); + } + else + { + POOL_STATUS status1; + + /* send reset request to backend */ + status1 = pool_process_query(frontend, backend, 1, 0); + pool_close(frontend); + + /* if we detect errors on resetting connection, we need to discard + * this connection since it might be in unknown status + */ + if (status1 != POOL_CONTINUE) + { + pool_debug("error in resetting connections. discarding connection pools..."); + pool_send_frontend_exits(backend); + pool_discard_cp(sp->user, sp->database, sp->major); + } + else + pool_connection_pool_timer(backend); + } + break; + + /* error occured. discard backend connection pool + and disconnect connection to the frontend */ + case POOL_ERROR: +#ifdef NOT_USED + pool_discard_cp(sp->user, sp->database); + pool_close(frontend); + notice_backend_error(); +#endif + pool_log("do_child: exits with status 1 due to error"); + child_exit(1); + break; + + /* fatal error occured. just exit myself... */ + case POOL_FATAL: + notice_backend_error(1); + child_exit(1); + break; + + /* not implemented yet */ + case POOL_IDLE: + do_accept(unix_fd, inet_fd, &timeout); + pool_debug("accept while idle"); + break; + + default: + break; + } + + if (status != POOL_CONTINUE) + break; + } + + accepted = 0; + connection_count_down(); + + timeout.tv_sec = pool_config->child_life_time; + timeout.tv_usec = 0; + + /* increment queries counter if necessary */ + if ( pool_config->child_max_connections > 0 ) + connections_count++; + + /* check if maximum connections count for this child reached */ + if ( ( pool_config->child_max_connections > 0 ) && + ( connections_count >= pool_config->child_max_connections ) ) + { + pool_log("child exiting, %d connections reached", pool_config->child_max_connections); + send_frontend_exits(); + child_exit(2); + } + } + child_exit(0); +} + +/* ------------------------------------------------------------------- + * private functions + * ------------------------------------------------------------------- + */ + +/* + * set non-block flag + */ +void pool_set_nonblock(int fd) +{ + int var; + + /* set fd to none blocking */ + var = fcntl(fd, F_GETFL, 0); + if (var == -1) + { + pool_error("fcntl failed. %s", strerror(errno)); + child_exit(1); + } + if (fcntl(fd, F_SETFL, var | O_NONBLOCK) == -1) + { + pool_error("fcntl failed. %s", strerror(errno)); + child_exit(1); + } +} + +/* + * unset non-block flag + */ +void pool_unset_nonblock(int fd) +{ + int var; + + /* set fd to none blocking */ + var = fcntl(fd, F_GETFL, 0); + if (var == -1) + { + pool_error("fcntl failed. %s", strerror(errno)); + child_exit(1); + } + if (fcntl(fd, F_SETFL, var & ~O_NONBLOCK) == -1) + { + pool_error("fcntl failed. %s", strerror(errno)); + child_exit(1); + } +} + +/* +* perform accept() and return new fd +*/ +static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *timeout) +{ + fd_set readmask; + int fds; + int save_errno; + + SockAddr saddr; + int fd = 0; + int afd; + int inet = 0; + POOL_CONNECTION *cp; +#ifdef ACCEPT_PERFORMANCE + struct timeval now1, now2; + static long atime; + static int cnt; +#endif + struct timeval *timeoutval; + struct timeval tv1, tv2, tmback = {0, 0}; + + char remote_host[NI_MAXHOST]; + char remote_port[NI_MAXSERV]; + + set_ps_display("wait for connection request", false); + + FD_ZERO(&readmask); + FD_SET(unix_fd, &readmask); + if (inet_fd) + FD_SET(inet_fd, &readmask); + + if (timeout->tv_sec == 0 && timeout->tv_usec == 0) + timeoutval = NULL; + else + { + timeoutval = timeout; + tmback.tv_sec = timeout->tv_sec; + tmback.tv_usec = timeout->tv_usec; + gettimeofday(&tv1, NULL); + +#ifdef DEBUG + pool_log("before select = {%d, %d}", timeoutval->tv_sec, timeoutval->tv_usec); + pool_log("g:before select = {%d, %d}", tv1.tv_sec, tv1.tv_usec); +#endif + } + + fds = select(Max(unix_fd, inet_fd)+1, &readmask, NULL, NULL, timeoutval); + + save_errno = errno; + /* check backend timer is expired */ + if (backend_timer_expired) + { + pool_backend_timer(); + backend_timer_expired = 0; + } + + /* + * following code fragment computes remaining timeout val in a + * portable way. Linux does this automazically but other platforms do not. + */ + if (timeoutval) + { + gettimeofday(&tv2, NULL); + + tmback.tv_usec -= tv2.tv_usec - tv1.tv_usec; + tmback.tv_sec -= tv2.tv_sec - tv1.tv_sec; + + if (tmback.tv_usec < 0) + { + tmback.tv_sec--; + if (tmback.tv_sec < 0) + { + timeout->tv_sec = 0; + timeout->tv_usec = 0; + } + else + { + tmback.tv_usec += 1000000; + timeout->tv_sec = tmback.tv_sec; + timeout->tv_usec = tmback.tv_usec; + } + } +#ifdef DEBUG + pool_log("g:after select = {%d, %d}", tv2.tv_sec, tv2.tv_usec); + pool_log("after select = {%d, %d}", timeout->tv_sec, timeout->tv_usec); +#endif + } + + errno = save_errno; + + if (fds == -1) + { + if (errno == EAGAIN || errno == EINTR) + return NULL; + + pool_error("select() failed. reason %s", strerror(errno)); + return NULL; + } + + /* timeout */ + if (fds == 0) + { + return NULL; + } + + if (FD_ISSET(unix_fd, &readmask)) + { + fd = unix_fd; + } + + if (FD_ISSET(inet_fd, &readmask)) + { + fd = inet_fd; + inet++; + } + + /* + * Note that some SysV systems do not work here. For those + * systems, we need some locking mechanism for the fd. + */ + memset(&saddr, 0, sizeof(saddr)); + saddr.salen = sizeof(saddr.addr); + +#ifdef ACCEPT_PERFORMANCE + gettimeofday(&now1,0); +#endif + + retry_accept: + + /* wait if recovery is started */ + while (*InRecovery == 1) + { + pause(); + } + + afd = accept(fd, (struct sockaddr *)&saddr.addr, &saddr.salen); + + save_errno = errno; + /* check backend timer is expired */ + if (backend_timer_expired) + { + pool_backend_timer(); + backend_timer_expired = 0; + } + errno = save_errno; + if (afd < 0) + { + if (errno == EINTR && *InRecovery) + goto retry_accept; + + /* + * "Resource temporarily unavailable" (EAGAIN or EWOULDBLOCK) + * can be silently ignored. And EINTR can be ignored. + */ + if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) + pool_error("accept() failed. reason: %s", strerror(errno)); + return NULL; + } +#ifdef ACCEPT_PERFORMANCE + gettimeofday(&now2,0); + atime += (now2.tv_sec - now1.tv_sec)*1000000 + (now2.tv_usec - now1.tv_usec); + cnt++; + if (cnt % 100 == 0) + { + pool_log("cnt: %d atime: %ld", cnt, atime); + } +#endif + + /* reload config file */ + if (got_sighup) + { + pool_get_config(get_config_file_name(), RELOAD_CONFIG); + if (pool_config->enable_pool_hba) + load_hba(get_hba_file_name()); + if (pool_config->parallel_mode) + pool_memset_system_db_info(system_db_info->info); + got_sighup = 0; + } + + connection_count_up(); + accepted = 1; + + if (pool_config->parallel_mode) + { + /* + * do not accept new connection if any of DB node or SystemDB is down when operating in + * parallel mode + */ + int i; + + for (i=0;imajor == PROTO_MAJOR_V3) + { + char buf[256]; + + if (SYSDB_STATUS == CON_DOWN) + snprintf(buf, sizeof(buf), "SystemDB is down"); + else + snprintf(buf, sizeof(buf), "%d th backend is down", i); + + pool_send_error_message(cp, sp->major, "08S01", + msg, + buf, + ((SYSDB_STATUS == CON_DOWN) ? "repair the SystemDB and restart pgpool" + : "repair the backend and restart pgpool"), + __FILE__, + __LINE__); + } + else + { + pool_send_error_message(cp, sp->major, + 0, + msg, + "", + "", + "", + 0); + } + pool_close(cp); + child_exit(1); + } + } + } + else + { + /* + * do not accept new connection if all DB nodes are down when operating in + * non parallel mode + */ + int i; + int found = 0; + + for (i=0;ilog_connections) + { + pool_log("connection received: host=%s%s%s", + remote_host, remote_port[0] ? " port=" : "", remote_port); + } + + /* set NODELAY and KEEPALIVE options if INET connection */ + if (inet) + { + int on = 1; + + if (setsockopt(afd, IPPROTO_TCP, TCP_NODELAY, + (char *) &on, + sizeof(on)) < 0) + { + pool_error("do_accept: setsockopt() failed: %s", strerror(errno)); + close(afd); + return NULL; + } + if (setsockopt(afd, SOL_SOCKET, SO_KEEPALIVE, + (char *) &on, + sizeof(on)) < 0) + { + pool_error("do_accept: setsockopt() failed: %s", strerror(errno)); + close(afd); + return NULL; + } + } + + if ((cp = pool_open(afd)) == NULL) + { + close(afd); + return NULL; + } + + /* save ip addres for hba */ + memcpy(&cp->raddr, &saddr, sizeof(SockAddr)); + if (cp->raddr.addr.ss_family == 0) + cp->raddr.addr.ss_family = AF_UNIX; + + return cp; +} + +/* +* read startup packet +*/ +static StartupPacket *read_startup_packet(POOL_CONNECTION *cp) +{ + StartupPacket *sp; + StartupPacket_v2 *sp2; + int protov; + int len; + char *p; + + sp = (StartupPacket *)calloc(sizeof(*sp), 1); + if (!sp) + { + pool_error("read_startup_packet: out of memory"); + return NULL; + } + + if (pool_config->authentication_timeout > 0) + { + pool_signal(SIGALRM, authentication_timeout); + alarm(pool_config->authentication_timeout); + } + + /* read startup packet length */ + if (pool_read(cp, &len, sizeof(len))) + { + return NULL; + } + len = ntohl(len); + len -= sizeof(len); + + if (len <= 0) + { + pool_error("read_startup_packet: incorrect packet length (%d)", len); + } + else if (len >= MAX_STARTUP_PACKET_LENGTH) + { + pool_error("read_startup_packet: invalid startup packet"); + pool_free_startup_packet(sp); + return NULL; + } + + sp->startup_packet = calloc(len, 1); + if (!sp->startup_packet) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + + /* read startup packet */ + if (pool_read(cp, sp->startup_packet, len)) + { + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + + sp->len = len; + memcpy(&protov, sp->startup_packet, sizeof(protov)); + sp->major = ntohl(protov)>>16; + sp->minor = ntohl(protov) & 0x0000ffff; + p = sp->startup_packet; + + switch(sp->major) + { + case PROTO_MAJOR_V2: /* V2 */ + sp2 = (StartupPacket_v2 *)(sp->startup_packet); + + sp->database = calloc(SM_DATABASE+1, 1); + if (!sp->database) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + strncpy(sp->database, sp2->database, SM_DATABASE); + + sp->user = calloc(SM_USER+1, 1); + if (!sp->user) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + strncpy(sp->user, sp2->user, SM_USER); + + break; + + case PROTO_MAJOR_V3: /* V3 */ + p += sizeof(int); /* skip protocol version info */ + + while(*p) + { + if (!strcmp("user", p)) + { + p += (strlen(p) + 1); + sp->user = strdup(p); + if (!sp->user) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + } + else if (!strcmp("database", p)) + { + p += (strlen(p) + 1); + sp->database = strdup(p); + if (!sp->database) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + } + p += (strlen(p) + 1); + } + break; + + case 1234: /* cancel or SSL request */ + /* set dummy database, user info */ + sp->database = calloc(1, 1); + if (!sp->database) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + sp->user = calloc(1, 1); + if (!sp->user) + { + pool_error("read_startup_packet: out of memory"); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + break; + + default: + pool_error("read_startup_packet: invalid major no: %d", sp->major); + pool_free_startup_packet(sp); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return NULL; + } + + pool_debug("Protocol Major: %d Minor: %d database: %s user: %s", + sp->major, sp->minor, sp->database, sp->user); + alarm(0); + pool_signal(SIGALRM, SIG_IGN); + return sp; +} + +/* +* send startup packet +*/ +int send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp) +{ + int len; + + len = htonl(cp->sp->len + sizeof(len)); + pool_write(cp->con, &len, sizeof(len)); + return pool_write_and_flush(cp->con, cp->sp->startup_packet, cp->sp->len); +} + +/* + * process cancel request + */ +void cancel_request(CancelPacket *sp) +{ + int len; + int fd; + POOL_CONNECTION *con; + int i; + ConnectionInfo *c = NULL; + CancelPacket cp; + + pool_debug("Cancel request received"); + + /* look for cancel key from shmem info */ + for (i=0;inum_init_children*pool_config->max_pool;i++) + { + c = &con_info[i]; + + if (c->pid == sp->pid && c->key == sp->key) + { + pool_debug("found pid:%d key:%d i:%d",c->pid, c->key,i); + c = &con_info[i/pool_config->max_pool * pool_config->max_pool]; + break; + } + } + if (i == pool_config->num_init_children*pool_config->max_pool) + return; /* invalid key */ + + for (i=0;iprotoVersion; + cp.pid = c->pid; + cp.key = c->key; + + pool_debug("pid:%d key: %d",cp.pid,cp.key); + + if (pool_write_and_flush(con, &cp, sizeof(CancelPacket)) < 0) + pool_error("Could not send cancel request packet for backend %d", i); + + pool_close(con); + + /* + * this is needed to enure that the next DB node executes the + * query supposed to be canceled. + */ + sleep(1); + } +} + +static POOL_CONNECTION_POOL *connect_backend(StartupPacket *sp, POOL_CONNECTION *frontend) +{ + POOL_CONNECTION_POOL *backend; + int i; + + /* connect to the backend */ + backend = pool_create_cp(); + if (backend == NULL) + { + pool_send_error_message(frontend, sp->major, "XX000", "connection cache is full", "", + "increase max_pool", __FILE__, __LINE__); + pool_close(frontend); + pool_free_startup_packet(sp); + return NULL; + } + + for (i=0;idb_node_id = i; + + /* mark this is a backend connection */ + CONNECTION(backend, i)->isbackend = 1; + + /* + * save startup packet info + */ + CONNECTION_SLOT(backend, i)->sp = sp; + + /* send startup packet */ + if (send_startup_packet(CONNECTION_SLOT(backend, i)) < 0) + { + pool_error("do_child: fails to send startup packet to the %d th backend", i); + pool_discard_cp(sp->user, sp->database, sp->major); + pool_close(frontend); + return NULL; + } + } + } + + /* + * do authentication stuff + */ + if (pool_do_auth(frontend, backend)) + { + pool_close(frontend); + pool_discard_cp(sp->user, sp->database, sp->major); + return NULL; + } + + return backend; +} + +/* + * signal handler for SIGINT and SIGQUUT + */ +static RETSIGTYPE die(int sig) +{ + exit_request = 1; + + pool_debug("child receives shutdown request signal %d", sig); + + switch (sig) + { + case SIGTERM: /* smart shutdown */ + if (idle == 0) + { + pool_debug("child receives smart shutdown request but it's not in idle state"); + return; + } + break; + + case SIGINT: /* fast shutdown */ + case SIGQUIT: /* immediate shutdown */ + child_exit(0); + break; + default: + break; + } + + /* + * child_exit() does this. So we don't need it. + * send_frontend_exits(); + */ + child_exit(0); +} + +/* + * signal handler for SIGUSR1 + * close all idle connections + */ +static RETSIGTYPE close_idle_connection(int sig) +{ + int i, j; + POOL_CONNECTION_POOL *p = pool_connection_pool; + ConnectionInfo *info; + + pool_debug("child receives close connection request"); + + for (j=0;jmax_pool;j++, p++) + { + if (!MASTER_CONNECTION(p)) + continue; + if (!MASTER_CONNECTION(p)->sp) + continue; + if (MASTER_CONNECTION(p)->sp->user == NULL) + continue; + + if (MASTER_CONNECTION(p)->closetime > 0) /* idle connection? */ + { + pool_debug("close_idle_connection: close idle connection: user %s database %s", MASTER_CONNECTION(p)->sp->user, MASTER_CONNECTION(p)->sp->database); + pool_send_frontend_exits(p); + + for (i=0;isp); + } + pool_close(CONNECTION(p, i)); + } + info = p->info; + memset(p, 0, sizeof(POOL_CONNECTION_POOL)); + p->info = info; + memset(p->info, 0, sizeof(ConnectionInfo)); + } + } +} + +/* + * signal handler for SIGALRM + * + */ +static RETSIGTYPE authentication_timeout(int sig) +{ + pool_log("authentication is timeout"); + child_exit(1); +} + +/* + * send frontend exiting messages to all connections. this is called + * in any case when child process exits, for example failover, child + * life time expires or child max connections expires. + */ +static void send_frontend_exits(void) +{ + int i; + POOL_CONNECTION_POOL *p = pool_connection_pool; + +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + POOL_SETMASK2(&BlockSig, &oldmask); + + for (i=0;imax_pool;i++, p++) + { + if (!MASTER_CONNECTION(p)) + continue; + if (!MASTER_CONNECTION(p)->sp) + continue; + if (MASTER_CONNECTION(p)->sp->user == NULL) + continue; + pool_send_frontend_exits(p); + } + + POOL_SETMASK(&oldmask); +} + +static int send_params(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + int index; + char *name, *value; + int len, sendlen; + + index = 0; + while (pool_get_param(&MASTER(backend)->params, index++, &name, &value) == 0) + { + pool_write(frontend, "S", 1); + len = sizeof(sendlen) + strlen(name) + 1 + strlen(value) + 1; + sendlen = htonl(len); + pool_write(frontend, &sendlen, sizeof(sendlen)); + pool_write(frontend, name, strlen(name) + 1); + pool_write(frontend, value, strlen(value) + 1); + } + + if (pool_flush(frontend)) + { + pool_error("pool_send_params: pool_flush() failed"); + return -1; + } + return 0; +} + +void pool_free_startup_packet(StartupPacket *sp) +{ + if (sp) + { + if (sp->startup_packet) + free(sp->startup_packet); + if (sp->database) + free(sp->database); + if (sp->user) + free(sp->user); + free(sp); + } +} + +/* + * Do house keeping works when pgpool child process exits + */ +void child_exit(int code) +{ + /* count down global connection counter */ + if (accepted) + connection_count_down(); + + /* prepare to shutdown connections to system db */ + if(pool_config->parallel_mode || pool_config->enable_query_cache) + { + if (system_db_info->pgconn) + pool_close_libpq_connection(); + if (pool_system_db_connection()) + pool_close(pool_system_db_connection()->con); + } + + /* let backend know now we are exiting */ + send_frontend_exits(); + + exit(code); +} + +/* + * create a persistent connection + */ +POOL_CONNECTION_POOL_SLOT *make_persistent_db_connection( + char *hostname, int port, char *dbname, char *user, char *password) +{ + POOL_CONNECTION_POOL_SLOT *cp; + int fd; + +#define MAX_USER_AND_DATABASE 1024 + + /* V3 startup packet */ + typedef struct { + int protoVersion; + char data[MAX_USER_AND_DATABASE]; + } StartupPacket_v3; + + static StartupPacket_v3 *startup_packet; + int len, len1; + int status; + + cp = malloc(sizeof(POOL_CONNECTION_POOL)); + if (cp == NULL) + { + pool_error("make_persistent_db_connection: could not allocate memory"); + return NULL; + } + memset(cp, 0, sizeof(POOL_CONNECTION_POOL)); + + startup_packet = malloc(sizeof(*startup_packet)); + if (startup_packet == NULL) + { + pool_error("make_persistent_db_connection: could not allocate memory"); + return NULL; + } + memset(startup_packet, 0, sizeof(*startup_packet)); + startup_packet->protoVersion = htonl(0x00030000); /* set V3 proto major/minor */ + + /* + * create socket + */ + if (*hostname == '\0') + { + fd = connect_unix_domain_socket_by_port(port, pool_config->backend_socket_dir); + } + else + { + fd = connect_inet_domain_socket_by_port(hostname, port); + } + + if (fd < 0) + { + pool_error("make_persistent_db_connection: connection to %s(%d) failed", hostname, port); + return NULL; + } + + cp->con = pool_open(fd); + cp->closetime = 0; + cp->con->isbackend = 1; + + /* + * build V3 startup packet + */ + len = snprintf(startup_packet->data, sizeof(startup_packet->data), "user") + 1; + len1 = snprintf(&startup_packet->data[len], sizeof(startup_packet->data)-len, "%s", user) + 1; + if (len1 >= (sizeof(startup_packet->data)-len)) + { + pool_error("make_persistent_db_connection: too long user name"); + return NULL; + } + + len += len1; + len1 = snprintf(&startup_packet->data[len], sizeof(startup_packet->data)-len, "database") + 1; + if (len1 >= (sizeof(startup_packet->data)-len)) + { + pool_error("make_persistent_db_connection: too long user name"); + return NULL; + } + + len += len1; + len1 = snprintf(&startup_packet->data[len], sizeof(startup_packet->data)-len, "%s", dbname) + 1; + if (len1 >= (sizeof(startup_packet->data)-len)) + { + pool_error("make_persistent_db_connection: too long database name"); + return NULL; + } + len += len1; + startup_packet->data[len++] = '\0'; + + cp->sp = malloc(sizeof(StartupPacket)); + if (cp->sp == NULL) + { + pool_error("make_persistent_db_connection: could not allocate memory"); + return NULL; + } + + cp->sp->startup_packet = (char *)startup_packet; + cp->sp->len = len + 4; + cp->sp->major = 3; + cp->sp->minor = 0; + cp->sp->database = strdup(dbname); + if (cp->sp->database == NULL) + { + pool_error("make_persistent_db_connection: could not allocate memory"); + return NULL; + } + cp->sp->user = strdup(user); + if (cp->sp->user == NULL) + { + pool_error("make_persistent_db_connection: could not allocate memory"); + return NULL; + } + + /* + * send startup packet + */ + status = send_startup_packet(cp); + if (status) + { + pool_error("make_persistent_db_connection: send_startup_packet failed"); + return NULL; + } + + /* + * do authentication + */ + if (s_do_auth(cp, password)) + { + pool_error("make_persistent_db_connection: s_do_auth failed"); + return NULL; + } + + return cp; +} + +/* + * do authentication for cp + */ +static int s_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password) +{ + char kind; + int status; + int length; + int auth_kind; + char state; + char *p; + int pid, key; + + /* + * read kind expecting 'R' packet (authentication response) + */ + status = pool_read(cp->con, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("s_do_auth: error while reading message kind"); + return -1; + } + + if (kind != 'R') + { + pool_error("s_do_auth: expecting R got %c", kind); + return -1; + } + + /* read message length */ + status = pool_read(cp->con, &length, sizeof(length)); + if (status < 0) + { + pool_error("s_do_auth: error while reading message length"); + return -1; + } + length = ntohl(length); + + /* read auth kind */ + status = pool_read(cp->con, &auth_kind, sizeof(auth_kind)); + if (status < 0) + { + pool_error("s_do_auth: error while reading auth kind"); + return -1; + } + auth_kind = ntohl(auth_kind); + pool_debug("s_do_auth: auth kind: %d", auth_kind); + + if (auth_kind == 0) /* trust authentication? */ + { + cp->con->auth_kind = 0; + } + else if (auth_kind == 3) /* clear text password? */ + { + int size = htonl(strlen(password) + 5); + + pool_write(cp->con, "p", 1); + pool_write(cp->con, &size, sizeof(size)); + pool_write_and_flush(cp->con, password, strlen(password) + 1); + status = pool_flush(cp->con); + if (status > 0) + { + pool_error("s_do_auth: error while sending clear text password"); + return -1; + } + return s_do_auth(cp, password); + } + else if (auth_kind == 4) /* crypt password? */ + { + int size; + char salt[3]; + char *crypt_password; + + status = pool_read(cp->con, &salt, 2); + if (status > 0) + { + pool_error("s_do_auth: error while reading crypt salt"); + return -1; + } + salt[2] = '\0'; + + crypt_password = crypt(password, salt); + size = htonl(strlen(crypt_password) + 5); + pool_write(cp->con, "p", 1); + pool_write(cp->con, &size, sizeof(size)); + pool_write_and_flush(cp->con, crypt_password, strlen(crypt_password) + 1); + status = pool_flush(cp->con); + if (status > 0) + { + pool_error("s_do_auth: error while sending crypt password"); + return -1; + } + return s_do_auth(cp, password); + } + else if (auth_kind == 5) /* md5 password? */ + { + char salt[4]; + char *buf, *buf1; + int size; + + status = pool_read(cp->con, &salt, 4); + if (status > 0) + { + pool_error("s_do_auth: error while reading md5 salt"); + return -1; + } + + buf = malloc(2 * (MD5_PASSWD_LEN + 4)); /* hash + "md5" + '\0' */ + if (buf == NULL) + { + pool_error("s_do_auth(): malloc failed: %s", strerror(errno)); + return -1; + } + memset(buf, 0, 2 * (MD5_PASSWD_LEN + 4)); + + /* build md5 password */ + buf1 = buf + MD5_PASSWD_LEN + 4; + pool_md5_encrypt(password, cp->sp->user, strlen(cp->sp->user), buf1); + pool_md5_encrypt(buf1, salt, 4, buf + 3); + memcpy(buf, "md5", 3); + + size = htonl(strlen(buf) + 5); + pool_write(cp->con, "p", 1); + pool_write(cp->con, &size, sizeof(size)); + pool_write_and_flush(cp->con, buf, strlen(buf) + 1); + status = pool_flush(cp->con); + if (status > 0) + { + pool_error("s_do_auth: error while sending md5 password"); + return -1; + } + + status = s_do_auth(cp, password); + free(buf); + return status; + } + else + { + pool_error("s_do_auth: auth kind %d not supported yet", auth_kind); + return -1; + } + + /* + * read pid etc. + */ + for (;;) + { + status = pool_read(cp->con, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("s_do_auth: error while reading message kind"); + return -1; + } + + switch (kind) + { + case 'K': /* backend key data */ + pool_debug("s_do_auth: backend key data received"); + + /* read message length */ + status = pool_read(cp->con, &length, sizeof(length)); + if (status < 0) + { + pool_error("s_do_auth: error while reading message length"); + return -1; + } + if (ntohl(length) != 12) + { + pool_error("s_do_auth: backend key data length is not 12 (%d)", ntohl(length)); + } + + /* read pid */ + if (pool_read(cp->con, &pid, sizeof(pid)) < 0) + { + pool_error("s_do_auth: failed to read pid"); + return -1; + } + cp->pid = pid; + + /* read key */ + if (pool_read(cp->con, &key, sizeof(key)) < 0) + { + pool_error("s_do_auth: failed to read key"); + return -1; + } + cp->key = key; + + /* read kind expecting 'Z' (ready for query) */ + status = pool_read(cp->con, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("s_do_auth: error while reading kind"); + return -1; + } + + if (kind != 'Z') + { + pool_error("s_do_auth: expecting Z got %c", kind); + return -1; + } + + /* read message length */ + status = pool_read(cp->con, &length, sizeof(length)); + if (status < 0) + { + pool_error("s_do_auth: error while reading message length"); + return -1; + } + length = ntohl(length); + + /* read transaction state */ + status = pool_read(cp->con, &state, sizeof(state)); + if (status < 0) + { + pool_error("s_do_auth: error while reading transaction state"); + return -1; + } + + pool_debug("s_do_auth: transaction state: %c", state); + cp->con->tstate = state; + return 0; + break; + + case 'S': /* parameter status */ + pool_debug("s_do_auth: parameter status data received"); + + status = pool_read(cp->con, &length, sizeof(length)); + if (status < 0) + { + pool_error("s_do_auth: error while reading message length"); + return -1; + } + + length = ntohl(length); + length -= 4; + + p = pool_read2(cp->con, length); + if (p == NULL) + return -1; + break; + + default: + pool_error("s_do_auth: unknown response \"%c\" before processing BackendKeyData", + kind); + break; + } + } + return -1; +} + +/* + * Count up connection counter (from frontend to pgpool) + * in shared memory + */ +static void connection_count_up(void) +{ + pool_semaphore_lock(CONN_COUNTER_SEM); + Req_info->conn_counter++; + pool_semaphore_unlock(CONN_COUNTER_SEM); +} + +/* + * Count down connection counter (from frontend to pgpool) + * in shared memory + */ +static void connection_count_down(void) +{ + pool_semaphore_lock(CONN_COUNTER_SEM); + /* + * Make sure that we do not decrement too much. If failed to read + * a start up packet, or receive cancel request etc., + * connection_count_down() is called and goes back to the + * connection accept loop. Problem is, at the very beginning of + * the connection accept loop, if we have received a signal, we + * call child_exit() which calls connection_count_down() again. + */ + if (Req_info->conn_counter > 0) + Req_info->conn_counter--; + pool_semaphore_unlock(CONN_COUNTER_SEM); +} + +/* + * handle SIGUSR2 + * Wakeup all process + */ +static RETSIGTYPE wakeup_handler(int sig) +{ +} + + +/* + * Select load balancing node + */ +int select_load_balancing_node(void) +{ + double total_weight,r; + int i; + + /* choose a backend in random manner with weight */ + selected_slot = MASTER_NODE_ID; + total_weight = 0.0; + + for (i=0;i 0.0) + { + if(r >= total_weight) + selected_slot = i; + else + break; + total_weight += BACKEND_INFO(i).backend_weight; + } + } + + pool_debug("select_load_balancing_node: selected backend id is %d", selected_slot); + return selected_slot; +} + +/* SIGHUP handler */ +static RETSIGTYPE reload_config_handler(int sig) +{ + got_sighup = 1; +} diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..6960a39 --- /dev/null +++ b/config.guess @@ -0,0 +1,1532 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2007-01-15' + +# This file 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +if [ "${UNAME_SYSTEM}" = "Linux" ] ; then + eval $set_cc_for_build + cat << EOF > $dummy.c + #include + #ifdef __UCLIBC__ + # ifdef __UCLIBC_CONFIG_VERSION__ + LIBC=uclibc __UCLIBC_CONFIG_VERSION__ + # else + LIBC=uclibc + # endif + #else + LIBC=gnu + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep LIBC= | sed -e 's: ::g'` +fi + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[3456]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[3456]* | authenticamd:Interix*:[3456]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-${LIBC} + exit ;; + xtensa:Linux:*:*) + echo xtensa-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-${LIBC}" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-${LIBC}aout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-${LIBC}coff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-${LIBC}oldld" + exit ;; + esac + # This should get integrated into the C code below, but now we hack + if [ "$LIBC" != "gnu" ] ; then echo "$TENTATIVE" && exit 0 ; fi + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +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` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..7d2f7ac --- /dev/null +++ b/config.h.in @@ -0,0 +1,246 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to the type of arg 1 of 'accept' */ +#undef ACCEPT_TYPE_ARG1 + +/* Define to the type of arg 2 of 'accept' */ +#undef ACCEPT_TYPE_ARG2 + +/* Define to the type of arg 3 of 'accept' */ +#undef ACCEPT_TYPE_ARG3 + +/* Define to the return type of 'accept' */ +#undef ACCEPT_TYPE_RETURN + +/* Define to 1 if you have the `asprintf' function. */ +#undef HAVE_ASPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_CRYPT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `gai_strerror' function. */ +#undef HAVE_GAI_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_GETOPT_H + +/* Define to 1 if you have the `hstrerror' function. */ +#undef HAVE_HSTRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `BSD' library (-lBSD). */ +#undef HAVE_LIBBSD + +/* Define to 1 if you have the `compat' library (-lcompat). */ +#undef HAVE_LIBCOMPAT + +/* Define to 1 if you have the `gen' library (-lgen). */ +#undef HAVE_LIBGEN + +/* Define to 1 if you have the `IPC' library (-lIPC). */ +#undef HAVE_LIBIPC + +/* Define to 1 if you have the `lc' library (-llc). */ +#undef HAVE_LIBLC + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `pam' library (-lpam). */ +#undef HAVE_LIBPAM + +/* Define to 1 if you have the `pq' library (-lpq). */ +#undef HAVE_LIBPQ + +/* Define to 1 if you have the `PW' library (-lPW). */ +#undef HAVE_LIBPW + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#undef HAVE_LIBRESOLV + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_TCP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PAM_PAM_APPL_H + +/* Define to 1 if you have the `PQprepare' function. */ +#undef HAVE_PQPREPARE + +/* Define to 1 if you have the `pstat' function. */ +#undef HAVE_PSTAT + +/* Define to 1 if you have the header file. */ +#undef HAVE_SECURITY_PAM_APPL_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `setproctitle' function. */ +#undef HAVE_SETPROCTITLE + +/* Define to 1 if you have the `setsid' function. */ +#undef HAVE_SETSID + +/* Define to 1 if you have the `sigprocmask' function. */ +#undef HAVE_SIGPROCMASK + +/* Define to 1 if you have the `socket' function. */ +#undef HAVE_SOCKET + +/* 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 `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* 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 `strtok' function. */ +#undef HAVE_STRTOK + +/* Define to 1 if `sa_len' is member of `struct sockaddr'. */ +#undef HAVE_STRUCT_SOCKADDR_SA_LEN + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE + +/* Define to 1 if `ss_family' is member of `struct sockaddr_storage'. */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY + +/* Define to 1 if `ss_len' is member of `struct sockaddr_storage'. */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN + +/* Define to 1 if `__ss_family' is member of `struct sockaddr_storage'. */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY + +/* Define to 1 if `__ss_len' is member of `struct sockaddr_storage'. */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PSTAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SEM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SHM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_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_TIME_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_SYS_UN_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if the system has the type `union semun'. */ +#undef HAVE_UNION_SEMUN + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if you have the `wait3' system call. Deprecated, you should no + longer depend upon `wait3'. */ +#undef HAVE_WAIT3 + +/* Name of package */ +#undef PACKAGE + +/* 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 version of this package. */ +#undef PACKAGE_VERSION + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 to build with PAM support. (--with-pam) */ +#undef USE_PAM + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if does not define. */ +#undef pid_t diff --git a/config.sub b/config.sub new file mode 100755 index 0000000..2a4932e --- /dev/null +++ b/config.sub @@ -0,0 +1,1640 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2007-01-18' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx | dvp \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]a*eb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]a*eb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsEE* | ee | ps2) + basic_machine=mips64r5900el-scei + case $os in + -linux*) + ;; + *) + os=-elf + ;; + esac + ;; + iop) + basic_machine=mipsel-scei + os=-irx + ;; + dvp) + basic_machine=dvp-scei + os=-elf + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -irx*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 0000000..fb8651e --- /dev/null +++ b/configure @@ -0,0 +1,24051 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59. +# +# Copyright (C) 2003 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 Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; 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 + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# 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'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +echo=${ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string=`eval $cmd`) 2>/dev/null && + echo_test_string=`eval $cmd` && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +tagnames=${tagnames+${tagnames},}CXX + +tagnames=${tagnames+${tagnames},}F77 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LEX LEXLIB LEX_OUTPUT_ROOT YACC PGCONFIG PGSQL_INCLUDE_DIR PGSQL_LIB_DIR enable_rpath_TRUE enable_rpath_FALSE LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# 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. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +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 + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -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 | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$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 ;; + + -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 ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + 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 ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=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 ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +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 + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + 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 + + +# 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 its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + 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 + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP +ac_env_CXX_set=${CXX+set} +ac_env_CXX_value=$CXX +ac_cv_env_CXX_set=${CXX+set} +ac_cv_env_CXX_value=$CXX +ac_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_env_CXXFLAGS_value=$CXXFLAGS +ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_cv_env_CXXFLAGS_value=$CXXFLAGS +ac_env_CXXCPP_set=${CXXCPP+set} +ac_env_CXXCPP_value=$CXXCPP +ac_cv_env_CXXCPP_set=${CXXCPP+set} +ac_cv_env_CXXCPP_value=$CXXCPP +ac_env_F77_set=${F77+set} +ac_env_F77_value=$F77 +ac_cv_env_F77_set=${F77+set} +ac_cv_env_F77_value=$F77 +ac_env_FFLAGS_set=${FFLAGS+set} +ac_env_FFLAGS_value=$FFLAGS +ac_cv_env_FFLAGS_set=${FFLAGS+set} +ac_cv_env_FFLAGS_value=$FFLAGS + +# +# 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 this package 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 \`..'] + +_ACEOF + + cat <<_ACEOF +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] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --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] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-shared[=PKGS] + build shared libraries [default=yes] + --enable-static[=PKGS] + build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-rpath do not embed shared library search path in executables + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-tags[=TAGS] + include additional configurations [automatic] + --with-pgsql=DIR site header files for PostgreSQL in DIR + --with-pgsql-includedir=DIR site header files for PostgreSQL in DIR + --with-pgsql-libdir=DIR site library files for PostgreSQL in DIR + --with-pam build with PAM support + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + F77 Fortran 77 compiler command + FFLAGS Fortran 77 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. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style 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 + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright (C) 2003 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 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +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` +hostinfo = `(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=. + echo "PATH: $as_dir" +done + +} >&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_sep= +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=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$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 + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export 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: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >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 + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + 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. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +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 `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; 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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`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. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +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=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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_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" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +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 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out 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. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$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 +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* 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 -std1 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 -std1. */ +int osf4_cc_array ['\x00' == 0 ? 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 +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +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 + + +am__api_version="1.9" +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +DEPDIR="${am__leading_dot}deps" + + ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=pgpool-II + VERSION=2.2.5 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi; + +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi; + +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi; + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 +if test "${lt_cv_path_SED+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done + +fi + +SED=$lt_cv_path_SED +echo "$as_me:$LINENO: result: $SED" >&5 +echo "${ECHO_T}$SED" >&6 + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 +with_gnu_ld=$lt_cv_prog_gnu_ld + + +echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 +echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 +if test "${lt_cv_ld_reload_flag+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_ld_reload_flag='-r' +fi +echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 +echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + +echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 +if test "${lt_cv_path_NM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi +fi +echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 +echo "${ECHO_T}$lt_cv_path_NM" >&6 +NM="$lt_cv_path_NM" + +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + +echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 +echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 +if test "${lt_cv_deplibs_check_method+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix4* | aix5*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump'. + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | kfreebsd*-gnu | dragonfly*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix3*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 +echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 3744 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 +if test "${lt_cv_cc_needs_belf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lt_cv_cc_needs_belf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +lt_cv_cc_needs_belf=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + 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 + +fi +echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) LD="${LD-ld} -64" ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + + +esac + +need_locks="$enable_libtool_lock" + + +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 +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +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 + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +ac_ext=cc +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 -n "$ac_tool_prefix"; then + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CXX" && break +done +test -n "$ac_ct_CXX" || ac_ct_CXX="g++" + + CXX=$ac_ct_CXX +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cxx_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$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 +for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +ac_ext=cc +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 + +depcc="$CXX" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + + +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cc +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 +echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f 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 +echo "$as_me:$LINENO: result: $CXXCPP" >&5 +echo "${ECHO_T}$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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=cc +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 + +fi + + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran + 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 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$F77"; then + ac_cv_prog_F77="$F77" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_F77="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +F77=$ac_cv_prog_F77 +if test -n "$F77"; then + echo "$as_me:$LINENO: result: $F77" >&5 +echo "${ECHO_T}$F77" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$F77" && break + done +fi +if test -z "$F77"; then + ac_ct_F77=$F77 + for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_F77"; then + ac_cv_prog_ac_ct_F77="$ac_ct_F77" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_F77="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_F77=$ac_cv_prog_ac_ct_F77 +if test -n "$ac_ct_F77"; then + echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 +echo "${ECHO_T}$ac_ct_F77" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_F77" && break +done + + F77=$ac_ct_F77 +fi + + +# Provide some information about the compiler. +echo "$as_me:5343:" \ + "checking for Fortran 77 compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +rm -f a.out + +# If we don't use `.F' as extension, the preprocessor is not run on the +# input file. (Note that this only needs to work for GNU compilers.) +ac_save_ext=$ac_ext +ac_ext=F +echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 +if test "${ac_cv_f77_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF + program main +#ifndef __GNUC__ + choke me +#endif + + end +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_f77_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 +ac_ext=$ac_save_ext +ac_test_FFLAGS=${FFLAGS+set} +ac_save_FFLAGS=$FFLAGS +FFLAGS= +echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 +echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_f77_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + FFLAGS=-g +cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_f77_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_f77_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 +echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 +if test "$ac_test_FFLAGS" = set; then + FFLAGS=$ac_save_FFLAGS +elif test $ac_cv_prog_f77_g = yes; then + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-g -O2" + else + FFLAGS="-g" + fi +else + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-O2" + else + FFLAGS= + fi +fi + +G77=`test $ac_compiler_gnu = yes && echo yes` +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 + + + +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! + +# find the maximum length of command line arguments +echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 +echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 +if test "${lt_cv_sys_max_cmd_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 +echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 +else + echo "$as_me:$LINENO: result: none" >&5 +echo "${ECHO_T}none" >&6 +fi + + + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 +echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDGIRSTW]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + echo "$as_me:$LINENO: result: failed" >&5 +echo "${ECHO_T}failed" >&6 +else + echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 +fi + +echo "$as_me:$LINENO: checking for objdir" >&5 +echo $ECHO_N "checking for objdir... $ECHO_C" >&6 +if test "${lt_cv_objdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 +echo "${ECHO_T}$lt_cv_objdir" >&6 +objdir=$lt_cv_objdir + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + AR=$ac_ct_AR +else + AR="$ac_cv_prog_AR" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 +echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + echo "$as_me:$LINENO: checking for file" >&5 +echo $ECHO_N "checking for file... $ECHO_C" >&6 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +enable_dlopen=no +enable_win32_dll=no + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + + +# Check whether --with-pic or --without-pic was given. +if test "${with_pic+set}" = set; then + withval="$with_pic" + pic_mode="$withval" +else + pic_mode=default +fi; +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +lt_save_CC="$CC" +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 + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + +echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:6406: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:6410: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic='-qnocommon' + lt_prog_compiler_wl='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + linux*) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:6674: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:6678: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 + +if test x"$lt_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works=yes + fi + else + lt_prog_compiler_static_works=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 + +if test x"$lt_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:6778: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:6782: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag= + enable_shared_with_static_runtimes=no + archive_cmds= + archive_expsym_cmds= + old_archive_From_new_cmds= + old_archive_from_expsyms_cmds= + export_dynamic_flag_spec= + whole_archive_flag_spec= + thread_safe_flag_spec= + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_direct=no + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + link_all_deplibs=unknown + hardcode_automatic=no + module_cmds= + module_expsym_cmds= + always_export_symbols=no + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + interix3*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu | dragonfly*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld='-rpath $libdir' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + *) + whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs" >&5 +echo "${ECHO_T}$ld_shlibs" >&6 +test "$ld_shlibs" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 +echo "${ECHO_T}$archive_cmds_need_lc" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 8247 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var" || \ + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action" >&5 +echo "${ECHO_T}$hardcode_action" >&6 + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +char (*f) () = shl_load; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != shl_load; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6 +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main () +{ +shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +char (*f) () = dlopen; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != dlopen; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6 +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_svld_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main () +{ +dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_dld_link=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6 + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# Report which library types will actually be built +echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6 + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler \ + CC \ + LD \ + lt_prog_compiler_wl \ + lt_prog_compiler_pic \ + lt_prog_compiler_static \ + lt_prog_compiler_no_builtin_flag \ + export_dynamic_flag_spec \ + thread_safe_flag_spec \ + whole_archive_flag_spec \ + enable_shared_with_static_runtimes \ + old_archive_cmds \ + old_archive_from_new_cmds \ + predep_objects \ + postdep_objects \ + predeps \ + postdeps \ + compiler_lib_search_path \ + archive_cmds \ + archive_expsym_cmds \ + postinstall_cmds \ + postuninstall_cmds \ + old_archive_from_expsyms_cmds \ + allow_undefined_flag \ + no_undefined_flag \ + export_symbols_cmds \ + hardcode_libdir_flag_spec \ + hardcode_libdir_flag_spec_ld \ + hardcode_libdir_separator \ + hardcode_automatic \ + module_cmds \ + module_expsym_cmds \ + lt_cv_prog_compiler_c_o \ + exclude_expsyms \ + include_expsyms; do + + case $var in + old_archive_cmds | \ + old_archive_from_new_cmds | \ + archive_cmds | \ + archive_expsym_cmds | \ + module_cmds | \ + module_expsym_cmds | \ + old_archive_from_expsyms_cmds | \ + export_symbols_cmds | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + { echo "$as_me:$LINENO: creating $ofile" >&5 +echo "$as_me: creating $ofile" >&6;} + + cat <<__EOF__ >> "$cfgfile" +#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU C compiler? +with_gcc=$GCC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + 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 + +CC="$lt_save_CC" + + +# Check whether --with-tags or --without-tags was given. +if test "${with_tags+set}" = set; then + withval="$with_tags" + tagnames="$withval" +fi; + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} + else + { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 +echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} + fi + fi + if test -z "$LTCFLAGS"; then + eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in + "") ;; + *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 +echo "$as_me: error: invalid tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 +echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} + { (exit 1); exit 1; }; } + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cc +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 + + + + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_flag_spec_ld_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_shlibpath_var_CXX=unsupported +hardcode_automatic_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + $as_unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + $as_unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +compiler_CXX=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' +else + lt_prog_compiler_no_builtin_flag_CXX= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 +ld_shlibs_CXX=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_CXX=yes + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_CXX=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_CXX='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' ${wl}-bernotok' + allow_undefined_flag_CXX=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX='$convenience' + archive_cmds_need_lc_CXX=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_CXX=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_CXX=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_CXX=no + fi + ;; + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + whole_archive_flag_spec_CXX='' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes ; then + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_CXX=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + ld_shlibs_CXX=no + ;; + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + freebsd* | kfreebsd*-gnu | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + gnu*) + ;; + hpux9*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld_CXX='+b $libdir' + ;; + *) + export_dynamic_flag_spec_CXX='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + *) + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + interix3*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + ;; + linux*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc*) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC*) + # Portland Group C++ compiler + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + ld_shlibs_CXX=no + ;; + openbsd*) + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='${wl}-E' + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + ;; + osf3*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ + $rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + archive_cmds_need_lc_CXX=yes + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. We must also pass each convience library through + # to the system linker between allextract/defaultextract. + # The C++ compiler will combine linker options so we + # cannot just pass the convience library names through + # without $wl. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag_CXX='${wl}-z,text' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + # So that behaviour is only enabled if SCOABSPATH is set to a + # non-empty value in the environment. Most likely only useful for + # creating official distributions of packages. + # This is a hack until libtool officially supports absolute path + # names for shared libraries. + no_undefined_flag_CXX='${wl}-z,text' + allow_undefined_flag_CXX='${wl}-z,nodefs' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + export_dynamic_flag_spec_CXX='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; +esac +echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6 +test "$ld_shlibs_CXX" = no && can_build_shared=no + +GCC_CXX="$GXX" +LD_CXX="$LD" + + +cat > conftest.$ac_ext <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + # The `*' in the case matches for architectures that use `case' in + # $output_verbose_cmd can trigger glob expansion during the loop + # eval without this substitution. + output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` + + for p in `eval $output_verbose_link_cmd`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX="${prev}${p}" + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX="${prev}${p}" + else + postdeps_CXX="${postdeps_CXX} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX="$p" + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX="$p" + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$rm -f confest.$objext + +# PORTME: override above test on systems where it is broken +case $host_os in +interix3*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + predep_objects_CXX= + postdep_objects_CXX= + postdeps_CXX= + ;; + +solaris*) + case $cc_basename in + CC*) + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + postdeps_CXX='-lCstd -lCrun' + ;; + esac + ;; +esac + + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + +lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_CXX='-qnocommon' + lt_prog_compiler_wl_CXX='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + icpc* | ecpc*) + # Intel C++ + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + pgCC*) + # Portland Group C++ compiler. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fpic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx*) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc*) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + esac + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_CXX"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:11584: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:11588: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works_CXX=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 + +if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works_CXX=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works_CXX=yes + fi + else + lt_prog_compiler_static_works_CXX=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6 + +if test x"$lt_prog_compiler_static_works_CXX" = xyes; then + : +else + lt_prog_compiler_static_CXX= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:11688: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:11692: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX="$ltdll_cmds" + ;; + cygwin* | mingw*) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + +echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6 +test "$ld_shlibs_CXX" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + pic_flag=$lt_prog_compiler_pic_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_CXX=no + else + archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 12224 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || \ + test -n "$runpath_var_CXX" || \ + test "X$hardcode_automatic_CXX" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_CXX" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && + test "$hardcode_minus_L_CXX" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 +echo "${ECHO_T}$hardcode_action_CXX" >&6 + +if test "$hardcode_action_CXX" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_CXX \ + CC_CXX \ + LD_CXX \ + lt_prog_compiler_wl_CXX \ + lt_prog_compiler_pic_CXX \ + lt_prog_compiler_static_CXX \ + lt_prog_compiler_no_builtin_flag_CXX \ + export_dynamic_flag_spec_CXX \ + thread_safe_flag_spec_CXX \ + whole_archive_flag_spec_CXX \ + enable_shared_with_static_runtimes_CXX \ + old_archive_cmds_CXX \ + old_archive_from_new_cmds_CXX \ + predep_objects_CXX \ + postdep_objects_CXX \ + predeps_CXX \ + postdeps_CXX \ + compiler_lib_search_path_CXX \ + archive_cmds_CXX \ + archive_expsym_cmds_CXX \ + postinstall_cmds_CXX \ + postuninstall_cmds_CXX \ + old_archive_from_expsyms_cmds_CXX \ + allow_undefined_flag_CXX \ + no_undefined_flag_CXX \ + export_symbols_cmds_CXX \ + hardcode_libdir_flag_spec_CXX \ + hardcode_libdir_flag_spec_ld_CXX \ + hardcode_libdir_separator_CXX \ + hardcode_automatic_CXX \ + module_cmds_CXX \ + module_expsym_cmds_CXX \ + lt_cv_prog_compiler_c_o_CXX \ + exclude_expsyms_CXX \ + include_expsyms_CXX; do + + case $var in + old_archive_cmds_CXX | \ + old_archive_from_new_cmds_CXX | \ + archive_cmds_CXX | \ + archive_expsym_cmds_CXX | \ + module_cmds_CXX | \ + module_expsym_cmds_CXX | \ + old_archive_from_expsyms_cmds_CXX | \ + export_symbols_cmds_CXX | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_CXX + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_CXX +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_CXX + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_CXX" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + 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 + +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld + + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu + + +archive_cmds_need_lc_F77=no +allow_undefined_flag_F77= +always_export_symbols_F77=no +archive_expsym_cmds_F77= +export_dynamic_flag_spec_F77= +hardcode_direct_F77=no +hardcode_libdir_flag_spec_F77= +hardcode_libdir_flag_spec_ld_F77= +hardcode_libdir_separator_F77= +hardcode_minus_L_F77=no +hardcode_automatic_F77=no +module_cmds_F77= +module_expsym_cmds_F77= +link_all_deplibs_F77=unknown +old_archive_cmds_F77=$old_archive_cmds +no_undefined_flag_F77= +whole_archive_flag_spec_F77= +enable_shared_with_static_runtimes_F77=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +objext_F77=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code=" subroutine t\n return\n end\n" + +# Code to be used in simple link tests +lt_simple_link_test_code=" program t\n end\n" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${F77-"f77"} +compiler=$CC +compiler_F77=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6 + +GCC_F77="$G77" +LD_F77="$LD" + +lt_prog_compiler_wl_F77= +lt_prog_compiler_pic_F77= +lt_prog_compiler_static_F77= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_static_F77='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_F77='-fno-common' + ;; + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_F77=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_F77=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_F77='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + else + lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_F77='-qnocommon' + lt_prog_compiler_wl_F77='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_F77='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_F77='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + linux*) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-fpic' + lt_prog_compiler_static_F77='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl_F77='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_F77='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl_F77='-Qoption ld ';; + *) + lt_prog_compiler_wl_F77='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl_F77='-Qoption ld ' + lt_prog_compiler_pic_F77='-PIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_F77='-Kconform_pic' + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_can_build_shared_F77=no + ;; + + uts4*) + lt_prog_compiler_pic_F77='-pic' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_F77=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_F77"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_F77=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_F77" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:13279: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:13283: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works_F77=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 + +if test x"$lt_prog_compiler_pic_works_F77" = xyes; then + case $lt_prog_compiler_pic_F77 in + "" | " "*) ;; + *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; + esac +else + lt_prog_compiler_pic_F77= + lt_prog_compiler_can_build_shared_F77=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_F77= + ;; + *) + lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works_F77=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works_F77=yes + fi + else + lt_prog_compiler_static_works_F77=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6 + +if test x"$lt_prog_compiler_static_works_F77" = xyes; then + : +else + lt_prog_compiler_static_F77= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_F77=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:13383: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:13387: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_F77=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag_F77= + enable_shared_with_static_runtimes_F77=no + archive_cmds_F77= + archive_expsym_cmds_F77= + old_archive_From_new_cmds_F77= + old_archive_from_expsyms_cmds_F77= + export_dynamic_flag_spec_F77= + whole_archive_flag_spec_F77= + thread_safe_flag_spec_F77= + hardcode_libdir_flag_spec_F77= + hardcode_libdir_flag_spec_ld_F77= + hardcode_libdir_separator_F77= + hardcode_direct_F77=no + hardcode_minus_L_F77=no + hardcode_shlibpath_var_F77=unsupported + link_all_deplibs_F77=unknown + hardcode_automatic_F77=no + module_cmds_F77= + module_expsym_cmds_F77= + always_export_symbols_F77=no + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_F77= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_F77=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_F77='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_F77= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_F77=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_F77=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_F77=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_F77='-L$libdir' + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=no + enable_shared_with_static_runtimes_F77=yes + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_F77=no + fi + ;; + + interix3*) + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + export_dynamic_flag_spec_F77='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + else + ld_shlibs_F77=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_F77=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs_F77=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + esac + + if test "$ld_shlibs_F77" = no; then + runpath_var= + hardcode_libdir_flag_spec_F77= + export_dynamic_flag_spec_F77= + whole_archive_flag_spec_F77= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=yes + archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_F77=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_F77=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_F77='' + hardcode_direct_F77=yes + hardcode_libdir_separator_F77=':' + link_all_deplibs_F77=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_F77=yes + else + # We have old collect2 + hardcode_direct_F77=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_F77=yes + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_libdir_separator_F77= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_F77=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_F77='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_F77="-z nodefs" + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_F77=' ${wl}-bernotok' + allow_undefined_flag_F77=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_F77='$convenience' + archive_cmds_need_lc_F77=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_F77=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec_F77=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_F77=' ' + allow_undefined_flag_F77=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_F77='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path_F77='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_F77=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag_F77='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_F77=no + hardcode_direct_F77=no + hardcode_automatic_F77=yes + hardcode_shlibpath_var_F77=unsupported + whole_archive_flag_spec_F77='' + link_all_deplibs_F77=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_F77=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + freebsd1*) + ld_shlibs_F77=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu | dragonfly*) + archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + + hardcode_direct_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld_F77='+b $libdir' + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + ;; + *) + hardcode_direct_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + link_all_deplibs_F77=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + newsos6) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_shlibpath_var_F77=no + ;; + + openbsd*) + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + export_dynamic_flag_spec_F77='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + ;; + *) + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + allow_undefined_flag_F77=unsupported + archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_F77='-rpath $libdir' + fi + hardcode_libdir_separator_F77=: + ;; + + solaris*) + no_undefined_flag_F77=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_shlibpath_var_F77=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; + *) + whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + link_all_deplibs_F77=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_F77='$CC -r -o $output$reload_objs' + hardcode_direct_F77=no + ;; + motorola) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_F77=no + ;; + + sysv4.3*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + export_dynamic_flag_spec_F77='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_F77=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + no_undefined_flag_F77='${wl}-z,text' + archive_cmds_need_lc_F77=no + hardcode_shlibpath_var_F77=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag_F77='${wl}-z,text' + allow_undefined_flag_F77='${wl}-z,nodefs' + archive_cmds_need_lc_F77=no + hardcode_shlibpath_var_F77=no + hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_F77=':' + link_all_deplibs_F77=yes + export_dynamic_flag_spec_F77='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + *) + ld_shlibs_F77=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 +echo "${ECHO_T}$ld_shlibs_F77" >&6 +test "$ld_shlibs_F77" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_F77" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_F77=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_F77 in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_F77 + pic_flag=$lt_prog_compiler_pic_F77 + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_F77 + allow_undefined_flag_F77= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_F77=no + else + archive_cmds_need_lc_F77=yes + fi + allow_undefined_flag_F77=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 14832 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_F77= +if test -n "$hardcode_libdir_flag_spec_F77" || \ + test -n "$runpath_var_F77" || \ + test "X$hardcode_automatic_F77" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_F77" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && + test "$hardcode_minus_L_F77" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_F77=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_F77=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_F77=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 +echo "${ECHO_T}$hardcode_action_F77" >&6 + +if test "$hardcode_action_F77" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_F77 \ + CC_F77 \ + LD_F77 \ + lt_prog_compiler_wl_F77 \ + lt_prog_compiler_pic_F77 \ + lt_prog_compiler_static_F77 \ + lt_prog_compiler_no_builtin_flag_F77 \ + export_dynamic_flag_spec_F77 \ + thread_safe_flag_spec_F77 \ + whole_archive_flag_spec_F77 \ + enable_shared_with_static_runtimes_F77 \ + old_archive_cmds_F77 \ + old_archive_from_new_cmds_F77 \ + predep_objects_F77 \ + postdep_objects_F77 \ + predeps_F77 \ + postdeps_F77 \ + compiler_lib_search_path_F77 \ + archive_cmds_F77 \ + archive_expsym_cmds_F77 \ + postinstall_cmds_F77 \ + postuninstall_cmds_F77 \ + old_archive_from_expsyms_cmds_F77 \ + allow_undefined_flag_F77 \ + no_undefined_flag_F77 \ + export_symbols_cmds_F77 \ + hardcode_libdir_flag_spec_F77 \ + hardcode_libdir_flag_spec_ld_F77 \ + hardcode_libdir_separator_F77 \ + hardcode_automatic_F77 \ + module_cmds_F77 \ + module_expsym_cmds_F77 \ + lt_cv_prog_compiler_c_o_F77 \ + exclude_expsyms_F77 \ + include_expsyms_F77; do + + case $var in + old_archive_cmds_F77 | \ + old_archive_from_new_cmds_F77 | \ + archive_cmds_F77 | \ + archive_expsym_cmds_F77 | \ + module_cmds_F77 | \ + module_expsym_cmds_F77 | \ + old_archive_from_expsyms_cmds_F77 | \ + export_symbols_cmds_F77 | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_F77 + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_F77 + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_F77 + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_F77 + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_F77 + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_F77 +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_F77 + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_F77 +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_F77 +archive_expsym_cmds=$lt_archive_expsym_cmds_F77 +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_F77 +module_expsym_cmds=$lt_module_expsym_cmds_F77 + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_F77 + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_F77 + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_F77 + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_F77 + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_F77 + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_F77 + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_F77 + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_F77 + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_F77 + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_F77 + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_F77" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_F77 + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_F77 + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_F77 + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_F77 + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + 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 + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + + + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +objext_GCJ=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${GCJ-"gcj"} +compiler=$CC +compiler_GCJ=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +archive_cmds_need_lc_GCJ=no + +old_archive_cmds_GCJ=$old_archive_cmds + + +lt_prog_compiler_no_builtin_flag_GCJ= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' + + +echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15607: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:15611: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl_GCJ= +lt_prog_compiler_pic_GCJ= +lt_prog_compiler_static_GCJ= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_static_GCJ='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_GCJ='-fno-common' + ;; + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_GCJ=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_GCJ=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_GCJ='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + else + lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_GCJ='-qnocommon' + lt_prog_compiler_wl_GCJ='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + linux*) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-fpic' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl_GCJ='-Qoption ld ';; + *) + lt_prog_compiler_wl_GCJ='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl_GCJ='-Qoption ld ' + lt_prog_compiler_pic_GCJ='-PIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_GCJ='-Kconform_pic' + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_can_build_shared_GCJ=no + ;; + + uts4*) + lt_prog_compiler_pic_GCJ='-pic' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_GCJ=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_GCJ"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_GCJ=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_GCJ" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15875: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:15879: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works_GCJ=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 + +if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then + case $lt_prog_compiler_pic_GCJ in + "" | " "*) ;; + *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; + esac +else + lt_prog_compiler_pic_GCJ= + lt_prog_compiler_can_build_shared_GCJ=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_GCJ= + ;; + *) + lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works_GCJ=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works_GCJ=yes + fi + else + lt_prog_compiler_static_works_GCJ=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6 + +if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then + : +else + lt_prog_compiler_static_GCJ= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_GCJ=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15979: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:15983: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_GCJ=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag_GCJ= + enable_shared_with_static_runtimes_GCJ=no + archive_cmds_GCJ= + archive_expsym_cmds_GCJ= + old_archive_From_new_cmds_GCJ= + old_archive_from_expsyms_cmds_GCJ= + export_dynamic_flag_spec_GCJ= + whole_archive_flag_spec_GCJ= + thread_safe_flag_spec_GCJ= + hardcode_libdir_flag_spec_GCJ= + hardcode_libdir_flag_spec_ld_GCJ= + hardcode_libdir_separator_GCJ= + hardcode_direct_GCJ=no + hardcode_minus_L_GCJ=no + hardcode_shlibpath_var_GCJ=unsupported + link_all_deplibs_GCJ=unknown + hardcode_automatic_GCJ=no + module_cmds_GCJ= + module_expsym_cmds_GCJ= + always_export_symbols_GCJ=no + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_GCJ= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_GCJ=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_GCJ= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_GCJ=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_GCJ=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_GCJ=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_GCJ='-L$libdir' + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=no + enable_shared_with_static_runtimes_GCJ=yes + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + interix3*) + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + export_dynamic_flag_spec_GCJ='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + else + ld_shlibs_GCJ=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_GCJ=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs_GCJ=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + esac + + if test "$ld_shlibs_GCJ" = no; then + runpath_var= + hardcode_libdir_flag_spec_GCJ= + export_dynamic_flag_spec_GCJ= + whole_archive_flag_spec_GCJ= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=yes + archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_GCJ=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_GCJ=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_GCJ='' + hardcode_direct_GCJ=yes + hardcode_libdir_separator_GCJ=':' + link_all_deplibs_GCJ=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_GCJ=yes + else + # We have old collect2 + hardcode_direct_GCJ=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_GCJ=yes + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_libdir_separator_GCJ= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_GCJ=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_GCJ='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_GCJ="-z nodefs" + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_GCJ=' ${wl}-bernotok' + allow_undefined_flag_GCJ=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_GCJ='$convenience' + archive_cmds_need_lc_GCJ=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_GCJ=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec_GCJ=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_GCJ=' ' + allow_undefined_flag_GCJ=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_GCJ='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_GCJ=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_GCJ=no + hardcode_direct_GCJ=no + hardcode_automatic_GCJ=yes + hardcode_shlibpath_var_GCJ=unsupported + whole_archive_flag_spec_GCJ='' + link_all_deplibs_GCJ=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_GCJ=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + freebsd1*) + ld_shlibs_GCJ=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu | dragonfly*) + archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + + hardcode_direct_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + ;; + *) + hardcode_direct_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + link_all_deplibs_GCJ=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + newsos6) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_shlibpath_var_GCJ=no + ;; + + openbsd*) + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + export_dynamic_flag_spec_GCJ='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + ;; + *) + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + allow_undefined_flag_GCJ=unsupported + archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_GCJ='-rpath $libdir' + fi + hardcode_libdir_separator_GCJ=: + ;; + + solaris*) + no_undefined_flag_GCJ=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_shlibpath_var_GCJ=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; + *) + whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + link_all_deplibs_GCJ=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_GCJ='$CC -r -o $output$reload_objs' + hardcode_direct_GCJ=no + ;; + motorola) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4.3*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + export_dynamic_flag_spec_GCJ='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_GCJ=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + no_undefined_flag_GCJ='${wl}-z,text' + archive_cmds_need_lc_GCJ=no + hardcode_shlibpath_var_GCJ=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag_GCJ='${wl}-z,text' + allow_undefined_flag_GCJ='${wl}-z,nodefs' + archive_cmds_need_lc_GCJ=no + hardcode_shlibpath_var_GCJ=no + hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_GCJ=':' + link_all_deplibs_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + *) + ld_shlibs_GCJ=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 +echo "${ECHO_T}$ld_shlibs_GCJ" >&6 +test "$ld_shlibs_GCJ" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_GCJ" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_GCJ=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_GCJ in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_GCJ + pic_flag=$lt_prog_compiler_pic_GCJ + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ + allow_undefined_flag_GCJ= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_GCJ=no + else + archive_cmds_need_lc_GCJ=yes + fi + allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 17448 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_GCJ= +if test -n "$hardcode_libdir_flag_spec_GCJ" || \ + test -n "$runpath_var_GCJ" || \ + test "X$hardcode_automatic_GCJ" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_GCJ" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && + test "$hardcode_minus_L_GCJ" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_GCJ=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_GCJ=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_GCJ=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 +echo "${ECHO_T}$hardcode_action_GCJ" >&6 + +if test "$hardcode_action_GCJ" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_GCJ \ + CC_GCJ \ + LD_GCJ \ + lt_prog_compiler_wl_GCJ \ + lt_prog_compiler_pic_GCJ \ + lt_prog_compiler_static_GCJ \ + lt_prog_compiler_no_builtin_flag_GCJ \ + export_dynamic_flag_spec_GCJ \ + thread_safe_flag_spec_GCJ \ + whole_archive_flag_spec_GCJ \ + enable_shared_with_static_runtimes_GCJ \ + old_archive_cmds_GCJ \ + old_archive_from_new_cmds_GCJ \ + predep_objects_GCJ \ + postdep_objects_GCJ \ + predeps_GCJ \ + postdeps_GCJ \ + compiler_lib_search_path_GCJ \ + archive_cmds_GCJ \ + archive_expsym_cmds_GCJ \ + postinstall_cmds_GCJ \ + postuninstall_cmds_GCJ \ + old_archive_from_expsyms_cmds_GCJ \ + allow_undefined_flag_GCJ \ + no_undefined_flag_GCJ \ + export_symbols_cmds_GCJ \ + hardcode_libdir_flag_spec_GCJ \ + hardcode_libdir_flag_spec_ld_GCJ \ + hardcode_libdir_separator_GCJ \ + hardcode_automatic_GCJ \ + module_cmds_GCJ \ + module_expsym_cmds_GCJ \ + lt_cv_prog_compiler_c_o_GCJ \ + exclude_expsyms_GCJ \ + include_expsyms_GCJ; do + + case $var in + old_archive_cmds_GCJ | \ + old_archive_from_new_cmds_GCJ | \ + archive_cmds_GCJ | \ + archive_expsym_cmds_GCJ | \ + module_cmds_GCJ | \ + module_expsym_cmds_GCJ | \ + old_archive_from_expsyms_cmds_GCJ | \ + export_symbols_cmds_GCJ | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_GCJ + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_GCJ + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_GCJ + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_GCJ + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_GCJ + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_GCJ +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_GCJ + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_GCJ +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_GCJ +archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_GCJ +module_expsym_cmds=$lt_module_expsym_cmds_GCJ + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_GCJ + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_GCJ + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_GCJ + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_GCJ + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_GCJ + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_GCJ + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_GCJ + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_GCJ + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_GCJ + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_GCJ" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_GCJ + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_GCJ + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_GCJ + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_GCJ + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + 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 + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + RC) + + + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +objext_RC=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${RC-"windres"} +compiler=$CC +compiler_RC=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + +lt_cv_prog_compiler_c_o_RC=yes + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_RC \ + CC_RC \ + LD_RC \ + lt_prog_compiler_wl_RC \ + lt_prog_compiler_pic_RC \ + lt_prog_compiler_static_RC \ + lt_prog_compiler_no_builtin_flag_RC \ + export_dynamic_flag_spec_RC \ + thread_safe_flag_spec_RC \ + whole_archive_flag_spec_RC \ + enable_shared_with_static_runtimes_RC \ + old_archive_cmds_RC \ + old_archive_from_new_cmds_RC \ + predep_objects_RC \ + postdep_objects_RC \ + predeps_RC \ + postdeps_RC \ + compiler_lib_search_path_RC \ + archive_cmds_RC \ + archive_expsym_cmds_RC \ + postinstall_cmds_RC \ + postuninstall_cmds_RC \ + old_archive_from_expsyms_cmds_RC \ + allow_undefined_flag_RC \ + no_undefined_flag_RC \ + export_symbols_cmds_RC \ + hardcode_libdir_flag_spec_RC \ + hardcode_libdir_flag_spec_ld_RC \ + hardcode_libdir_separator_RC \ + hardcode_automatic_RC \ + module_cmds_RC \ + module_expsym_cmds_RC \ + lt_cv_prog_compiler_c_o_RC \ + exclude_expsyms_RC \ + include_expsyms_RC; do + + case $var in + old_archive_cmds_RC | \ + old_archive_from_new_cmds_RC | \ + archive_cmds_RC | \ + archive_expsym_cmds_RC | \ + module_cmds_RC | \ + module_expsym_cmds_RC | \ + old_archive_from_expsyms_cmds_RC | \ + export_symbols_cmds_RC | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_RC + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_RC + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_RC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_RC + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_RC + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_RC +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_RC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_RC +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_RC +archive_expsym_cmds=$lt_archive_expsym_cmds_RC +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_RC +module_expsym_cmds=$lt_module_expsym_cmds_RC + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_RC + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_RC + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_RC + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_RC + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_RC + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_RC + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_RC + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_RC + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_RC + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_RC + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_RC + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_RC" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_RC + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_RC + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_RC + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_RC + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + 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 + +CC="$lt_save_CC" + + ;; + + *) + { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 +echo "$as_me: error: Unsupported tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 +echo "$as_me: error: unable to update list of available tagged configurations." >&2;} + { (exit 1); exit 1; }; } + fi +fi + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + + + + + + + + + + + + + + + + + + + +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LEX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + echo "$as_me:$LINENO: result: $LEX" >&5 +echo "${ECHO_T}$LEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$LEX" && break +done +test -n "$LEX" || LEX=":" + +if test -z "$LEXLIB" +then + echo "$as_me:$LINENO: checking for yywrap in -lfl" >&5 +echo $ECHO_N "checking for yywrap in -lfl... $ECHO_C" >&6 +if test "${ac_cv_lib_fl_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lfl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_fl_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_fl_yywrap=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_fl_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_fl_yywrap" >&6 +if test $ac_cv_lib_fl_yywrap = yes; then + LEXLIB="-lfl" +else + echo "$as_me:$LINENO: checking for yywrap in -ll" >&5 +echo $ECHO_N "checking for yywrap in -ll... $ECHO_C" >&6 +if test "${ac_cv_lib_l_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ll $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_l_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_l_yywrap=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_l_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_l_yywrap" >&6 +if test $ac_cv_lib_l_yywrap = yes; then + LEXLIB="-ll" +fi + +fi + +fi + +if test "x$LEX" != "x:"; then + echo "$as_me:$LINENO: checking lex output file root" >&5 +echo $ECHO_N "checking lex output file root... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_root+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # The minimal lex program is just a single line: %%. But some broken lexes +# (Solaris, I think it was) want two %% lines, so accommodate them. +cat >conftest.l <<_ACEOF +%% +%% +_ACEOF +{ (eval echo "$as_me:$LINENO: \"$LEX conftest.l\"") >&5 + (eval $LEX conftest.l) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + { { echo "$as_me:$LINENO: error: cannot find output from $LEX; giving up" >&5 +echo "$as_me: error: cannot find output from $LEX; giving up" >&2;} + { (exit 1); exit 1; }; } +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_root" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_root" >&6 +rm -f conftest.l +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +echo "$as_me:$LINENO: checking whether yytext is a pointer" >&5 +echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c +ac_save_LIBS=$LIBS +LIBS="$LIBS $LEXLIB" +cat >conftest.$ac_ext <<_ACEOF +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_lex_yytext_pointer=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_save_LIBS +rm -f "${LEX_OUTPUT_ROOT}.c" + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_yytext_pointer" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6 +if test $ac_cv_prog_lex_yytext_pointer = yes; then + +cat >>confdefs.h <<\_ACEOF +#define YYTEXT_POINTER 1 +_ACEOF + +fi + +fi +if test "$LEX" = :; then + LEX=${am_missing_run}flex +fi +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_YACC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + echo "$as_me:$LINENO: result: $YACC" >&5 +echo "${ECHO_T}$YACC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + + +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wall" +echo "$as_me:$LINENO: checking for -Wall option" >&5 +echo $ECHO_N "checking for -Wall option... $ECHO_C" >&6 +if test "${ac_cv_wall+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +char a; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_wall=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_wall=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +echo $ac_cv_wall +if test $ac_cv_wall = no; then + CFLAGS=$OLD_CFLAGS +fi + +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wmissing-prototypes" +echo "$as_me:$LINENO: checking for -Wmissing-prototypes option" >&5 +echo $ECHO_N "checking for -Wmissing-prototypes option... $ECHO_C" >&6 +if test "${ac_cv_wmissing_prototypes+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +char a; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_wmissing_prototypes=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_wmissing_prototypes=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +echo $ac_cv_wmissing_prototypes +if test $ac_cv_wmissing_prototypes = no; then + CFLAGS=$OLD_CFLAGS +fi + + +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wmissing-declarations" +echo "$as_me:$LINENO: checking for -Wmissing-declarations option" >&5 +echo $ECHO_N "checking for -Wmissing-declarations option... $ECHO_C" >&6 +if test "${ac_cv_wmissing_declarations+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +char a; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_wmissing_declarations=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_wmissing_declarations=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +echo $ac_cv_wmissing_declarations +if test $ac_cv_wmissing_declarations = no; then + CFLAGS=$OLD_CFLAGS +fi + + +echo "$as_me:$LINENO: checking for main in -lm" >&5 +echo $ECHO_N "checking for main in -lm... $ECHO_C" >&6 +if test "${ac_cv_lib_m_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_m_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_m_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_m_main" >&5 +echo "${ECHO_T}$ac_cv_lib_m_main" >&6 +if test $ac_cv_lib_m_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lnsl" >&5 +echo $ECHO_N "checking for main in -lnsl... $ECHO_C" >&6 +if test "${ac_cv_lib_nsl_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_nsl_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_nsl_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_main" >&5 +echo "${ECHO_T}$ac_cv_lib_nsl_main" >&6 +if test $ac_cv_lib_nsl_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lsocket" >&5 +echo $ECHO_N "checking for main in -lsocket... $ECHO_C" >&6 +if test "${ac_cv_lib_socket_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_socket_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_socket_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_socket_main" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_main" >&6 +if test $ac_cv_lib_socket_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lipc" >&5 +echo $ECHO_N "checking for main in -lipc... $ECHO_C" >&6 +if test "${ac_cv_lib_ipc_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lipc $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ipc_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_ipc_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_main" >&5 +echo "${ECHO_T}$ac_cv_lib_ipc_main" >&6 +if test $ac_cv_lib_ipc_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBIPC 1 +_ACEOF + + LIBS="-lipc $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lIPC" >&5 +echo $ECHO_N "checking for main in -lIPC... $ECHO_C" >&6 +if test "${ac_cv_lib_IPC_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lIPC $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_IPC_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_IPC_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_IPC_main" >&5 +echo "${ECHO_T}$ac_cv_lib_IPC_main" >&6 +if test $ac_cv_lib_IPC_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBIPC 1 +_ACEOF + + LIBS="-lIPC $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -llc" >&5 +echo $ECHO_N "checking for main in -llc... $ECHO_C" >&6 +if test "${ac_cv_lib_lc_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-llc $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_lc_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_lc_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_lc_main" >&5 +echo "${ECHO_T}$ac_cv_lib_lc_main" >&6 +if test $ac_cv_lib_lc_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBLC 1 +_ACEOF + + LIBS="-llc $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lcompat" >&5 +echo $ECHO_N "checking for main in -lcompat... $ECHO_C" >&6 +if test "${ac_cv_lib_compat_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcompat $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_compat_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_compat_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_compat_main" >&5 +echo "${ECHO_T}$ac_cv_lib_compat_main" >&6 +if test $ac_cv_lib_compat_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCOMPAT 1 +_ACEOF + + LIBS="-lcompat $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lBSD" >&5 +echo $ECHO_N "checking for main in -lBSD... $ECHO_C" >&6 +if test "${ac_cv_lib_BSD_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lBSD $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_BSD_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_BSD_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_BSD_main" >&5 +echo "${ECHO_T}$ac_cv_lib_BSD_main" >&6 +if test $ac_cv_lib_BSD_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBBSD 1 +_ACEOF + + LIBS="-lBSD $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lgen" >&5 +echo $ECHO_N "checking for main in -lgen... $ECHO_C" >&6 +if test "${ac_cv_lib_gen_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgen $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_gen_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_gen_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_gen_main" >&5 +echo "${ECHO_T}$ac_cv_lib_gen_main" >&6 +if test $ac_cv_lib_gen_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGEN 1 +_ACEOF + + LIBS="-lgen $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lPW" >&5 +echo $ECHO_N "checking for main in -lPW... $ECHO_C" >&6 +if test "${ac_cv_lib_PW_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lPW $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_PW_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_PW_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_PW_main" >&5 +echo "${ECHO_T}$ac_cv_lib_PW_main" >&6 +if test $ac_cv_lib_PW_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPW 1 +_ACEOF + + LIBS="-lPW $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for main in -lresolv" >&5 +echo $ECHO_N "checking for main in -lresolv... $ECHO_C" >&6 +if test "${ac_cv_lib_resolv_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lresolv $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_resolv_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_resolv_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_main" >&5 +echo "${ECHO_T}$ac_cv_lib_resolv_main" >&6 +if test $ac_cv_lib_resolv_main = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRESOLV 1 +_ACEOF + + LIBS="-lresolv $LIBS" + +fi + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6 +if test "${ac_cv_header_sys_wait_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +int +main () +{ + int s; + wait (&s); + s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_sys_wait_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_sys_wait_h=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6 +if test $ac_cv_header_sys_wait_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF + +fi + + + + + + + + + + + + + + + + + +for ac_header in fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h netdb.h sys/param.h sys/types.h sys/socket.h sys/un.h sys/time.h sys/sem.h sys/shm.h sys/select.h crypt.h sys/pstat.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_const=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6 +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((pid_t *) 0) + return 0; +if (sizeof (pid_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_pid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_pid_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6 +if test $ac_cv_type_pid_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_time=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6 +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + + +# $PostgreSQL: pgsql/config/ac_func_accept_argtypes.m4,v 1.6 2003/11/29 19:51:17 pgsql Exp $ +# This comes from the official Autoconf macro archive at +# +# (I removed the $ before the Id CVS keyword below.) + + + +# PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3 +# is a pointer type. That's kind of useless because then you can't +# use the macro to define a corresponding variable. We also make the +# reasonable(?) assumption that you can use arg3 for getsocktype etc. +# as well (i.e., anywhere POSIX.2 has socklen_t). +# +# arg2 can also be `const' (e.g., RH 4.2). Change the order of tests +# for arg3 so that `int' is first, in case there is no prototype at all. +# +# Solaris 7 and 8 have arg3 as 'void *' (disguised as 'Psocklen_t' +# which is *not* 'socklen_t *'). If we detect that, then we assume +# 'int' as the result, because that ought to work best. +# +# On Win32, accept() returns 'unsigned int PASCAL' + + + +echo "$as_me:$LINENO: checking for struct sockaddr_storage" >&5 +echo $ECHO_N "checking for struct sockaddr_storage... $ECHO_C" >&6 +if test "${ac_cv_type_struct_sockaddr_storage+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +if ((struct sockaddr_storage *) 0) + return 0; +if (sizeof (struct sockaddr_storage)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_struct_sockaddr_storage=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_struct_sockaddr_storage=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_struct_sockaddr_storage" >&5 +echo "${ECHO_T}$ac_cv_type_struct_sockaddr_storage" >&6 +if test $ac_cv_type_struct_sockaddr_storage = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 +_ACEOF + + +fi + +echo "$as_me:$LINENO: checking for struct sockaddr_storage.ss_family" >&5 +echo $ECHO_N "checking for struct sockaddr_storage.ss_family... $ECHO_C" >&6 +if test "${ac_cv_member_struct_sockaddr_storage_ss_family+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (ac_aggr.ss_family) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage_ss_family=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (sizeof ac_aggr.ss_family) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage_ss_family=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_sockaddr_storage_ss_family=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_storage_ss_family" >&5 +echo "${ECHO_T}$ac_cv_member_struct_sockaddr_storage_ss_family" >&6 +if test $ac_cv_member_struct_sockaddr_storage_ss_family = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for struct sockaddr_storage.__ss_family" >&5 +echo $ECHO_N "checking for struct sockaddr_storage.__ss_family... $ECHO_C" >&6 +if test "${ac_cv_member_struct_sockaddr_storage___ss_family+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (ac_aggr.__ss_family) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage___ss_family=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (sizeof ac_aggr.__ss_family) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage___ss_family=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_sockaddr_storage___ss_family=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_storage___ss_family" >&5 +echo "${ECHO_T}$ac_cv_member_struct_sockaddr_storage___ss_family" >&6 +if test $ac_cv_member_struct_sockaddr_storage___ss_family = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for struct sockaddr_storage.ss_len" >&5 +echo $ECHO_N "checking for struct sockaddr_storage.ss_len... $ECHO_C" >&6 +if test "${ac_cv_member_struct_sockaddr_storage_ss_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (ac_aggr.ss_len) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage_ss_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (sizeof ac_aggr.ss_len) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage_ss_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_sockaddr_storage_ss_len=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_storage_ss_len" >&5 +echo "${ECHO_T}$ac_cv_member_struct_sockaddr_storage_ss_len" >&6 +if test $ac_cv_member_struct_sockaddr_storage_ss_len = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for struct sockaddr_storage.__ss_len" >&5 +echo $ECHO_N "checking for struct sockaddr_storage.__ss_len... $ECHO_C" >&6 +if test "${ac_cv_member_struct_sockaddr_storage___ss_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (ac_aggr.__ss_len) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage___ss_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr_storage ac_aggr; +if (sizeof ac_aggr.__ss_len) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_storage___ss_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_sockaddr_storage___ss_len=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_storage___ss_len" >&5 +echo "${ECHO_T}$ac_cv_member_struct_sockaddr_storage___ss_len" >&6 +if test $ac_cv_member_struct_sockaddr_storage___ss_len = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for struct sockaddr.sa_len" >&5 +echo $ECHO_N "checking for struct sockaddr.sa_len... $ECHO_C" >&6 +if test "${ac_cv_member_struct_sockaddr_sa_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr ac_aggr; +if (ac_aggr.sa_len) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_sa_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + + +int +main () +{ +static struct sockaddr ac_aggr; +if (sizeof ac_aggr.sa_len) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_sockaddr_sa_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_sockaddr_sa_len=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_sa_len" >&5 +echo "${ECHO_T}$ac_cv_member_struct_sockaddr_sa_len" >&6 +if test $ac_cv_member_struct_sockaddr_sa_len = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_SA_LEN 1 +_ACEOF + + +fi + + +echo "$as_me:$LINENO: checking for union semun" >&5 +echo $ECHO_N "checking for union semun... $ECHO_C" >&6 +if test "${ac_cv_type_union_semun+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((union semun *) 0) + return 0; +if (sizeof (union semun)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_union_semun=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_union_semun=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_union_semun" >&5 +echo "${ECHO_T}$ac_cv_type_union_semun" >&6 +if test $ac_cv_type_union_semun = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_UNION_SEMUN 1 +_ACEOF + + +fi + + +echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#ifdef signal +# undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_signal=void +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_signal=int +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6 + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + +for ac_func in vprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +echo "$as_me:$LINENO: checking for _doprnt" >&5 +echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 +if test "${ac_cv_func__doprnt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define _doprnt to an innocuous variant, in case declares _doprnt. + For example, HP-UX 11i declares gettimeofday. */ +#define _doprnt innocuous__doprnt + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef _doprnt + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char _doprnt (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub__doprnt) || defined (__stub____doprnt) +choke me +#else +char (*f) () = _doprnt; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != _doprnt; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func__doprnt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func__doprnt=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 +echo "${ECHO_T}$ac_cv_func__doprnt" >&6 +if test $ac_cv_func__doprnt = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOPRNT 1 +_ACEOF + +fi + +fi +done + + +echo "$as_me:$LINENO: checking for wait3 that fills in rusage" >&5 +echo $ECHO_N "checking for wait3 that fills in rusage... $ECHO_C" >&6 +if test "${ac_cv_func_wait3_rusage+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_wait3_rusage=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* HP-UX has wait3 but does not fill in rusage at all. */ +int +main () +{ + struct rusage r; + int i; + /* Use a field that we can force nonzero -- + voluntary context switches. + For systems like NeXT and OSF/1 that don't set it, + also use the system CPU time. And page faults (I/O) for Linux. */ + r.ru_nvcsw = 0; + r.ru_stime.tv_sec = 0; + r.ru_stime.tv_usec = 0; + r.ru_majflt = r.ru_minflt = 0; + switch (fork ()) + { + case 0: /* Child. */ + sleep(1); /* Give up the CPU. */ + _exit(0); + break; + case -1: /* What can we do? */ + _exit(0); + break; + default: /* Parent. */ + wait3(&i, 0, &r); + /* Avoid "text file busy" from rm on fast HP-UX machines. */ + sleep(2); + exit (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0 + && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0); + } +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_wait3_rusage=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_wait3_rusage=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_func_wait3_rusage" >&5 +echo "${ECHO_T}$ac_cv_func_wait3_rusage" >&6 +if test $ac_cv_func_wait3_rusage = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WAIT3 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking types of arguments for accept()" >&5 +echo $ECHO_N "checking types of arguments for accept()... $ECHO_C" >&6 + if test "${ac_cv_func_accept_return+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "${ac_cv_func_accept_arg1+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "${ac_cv_func_accept_arg2+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "${ac_cv_func_accept_arg3+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + for ac_cv_func_accept_return in 'int' 'unsigned int PASCAL'; do + for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do + for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do + for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int' 'void'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +extern $ac_cv_func_accept_return accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *); +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_not_found=no; break 4 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_not_found=yes +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done + done + done + done + if test "$ac_not_found" = yes; then + { { echo "$as_me:$LINENO: error: could not determine argument types" >&5 +echo "$as_me: error: could not determine argument types" >&2;} + { (exit 1); exit 1; }; } + fi + if test "$ac_cv_func_accept_arg3" = "void"; then + ac_cv_func_accept_arg3=int + fi + +fi + +fi + +fi + +fi + echo "$as_me:$LINENO: result: $ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&5 +echo "${ECHO_T}$ac_cv_func_accept_return, $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *" >&6 + +cat >>confdefs.h <<_ACEOF +#define ACCEPT_TYPE_RETURN $ac_cv_func_accept_return +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define ACCEPT_TYPE_ARG1 $ac_cv_func_accept_arg1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define ACCEPT_TYPE_ARG2 $ac_cv_func_accept_arg2 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define ACCEPT_TYPE_ARG3 $ac_cv_func_accept_arg3 +_ACEOF + + + + + + + + + + + + + + + +for ac_func in setsid select socket sigprocmask strdup strerror strftime strtok asprintf gai_strerror hstrerror pstat setproctitle +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_prog in pg_config +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_PGCONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$PGCONFIG"; then + ac_cv_prog_PGCONFIG="$PGCONFIG" # 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_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PGCONFIG="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +PGCONFIG=$ac_cv_prog_PGCONFIG +if test -n "$PGCONFIG"; then + echo "$as_me:$LINENO: result: $PGCONFIG" >&5 +echo "${ECHO_T}$PGCONFIG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$PGCONFIG" && break +done + + +if test -z $PGCONFIG +then + PGSQL_INCLUDE_DIR=/usr/local/pgsql/include + PGSQL_LIB_DIR=/usr/local/pgsql/lib +else + PGSQL_INCLUDE_DIR=`pg_config --includedir` + PGSQL_LIB_DIR=`pg_config --libdir` +fi + + + +# Check whether --with-pgsql or --without-pgsql was given. +if test "${with_pgsql+set}" = set; then + withval="$with_pgsql" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-pgsql option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-pgsql option." >&2;} + { (exit 1); exit 1; }; } + ;; + esac + PGSQL_INCLUDE_DIR="$withval"/include + PGSQL_LIB_DIR="$withval"/lib + +fi; + + +# Check whether --with-pgsql-includedir or --without-pgsql-includedir was given. +if test "${with_pgsql_includedir+set}" = set; then + withval="$with_pgsql_includedir" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-pgsql-includedir option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-pgsql-includedir option." >&2;} + { (exit 1); exit 1; }; } + ;; + esac + PGSQL_INCLUDE_DIR="$withval" + +fi; + + +# Check whether --with-pgsql-libdir or --without-pgsql-libdir was given. +if test "${with_pgsql_libdir+set}" = set; then + withval="$with_pgsql_libdir" + + case "$withval" in + "" | y | ye | yes | n | no) + { { echo "$as_me:$LINENO: error: *** You must supply an argument to the --with-pgsql-libdir option." >&5 +echo "$as_me: error: *** You must supply an argument to the --with-pgsql-libdir option." >&2;} + { (exit 1); exit 1; }; } + ;; + esac + PGSQL_LIB_DIR="$withval" + +fi; + + +# Check whether --with-pam or --without-pam was given. +if test "${with_pam+set}" = set; then + withval="$with_pam" + +cat >>confdefs.h <<\_ACEOF +#define USE_PAM 1 +_ACEOF + +fi; +if test "$with_pam" = yes ; then + +echo "$as_me:$LINENO: checking for pam_start in -lpam" >&5 +echo $ECHO_N "checking for pam_start in -lpam... $ECHO_C" >&6 +if test "${ac_cv_lib_pam_pam_start+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpam $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pam_start (); +int +main () +{ +pam_start (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pam_pam_start=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_pam_pam_start=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_pam_pam_start" >&5 +echo "${ECHO_T}$ac_cv_lib_pam_pam_start" >&6 +if test $ac_cv_lib_pam_pam_start = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPAM 1 +_ACEOF + + LIBS="-lpam $LIBS" + +else + { { echo "$as_me:$LINENO: error: library 'pam' is required for PAM" >&5 +echo "$as_me: error: library 'pam' is required for PAM" >&2;} + { (exit 1); exit 1; }; } +fi + + +for ac_header in security/pam_appl.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +else + +for ac_header in pam/pam_appl.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +else + { { echo "$as_me:$LINENO: error: header file or is required for PAM." >&5 +echo "$as_me: error: header file or is required for PAM." >&2;} + { (exit 1); exit 1; }; } +fi + +done + +fi + +done + +fi + +OLD_LDFLAGS="$LDFLAGS" +LDFLAGS="-L$PGSQL_LIB_DIR" +OLD_LIBS="$LIBS" + +echo "$as_me:$LINENO: checking for PQexecPrepared in -lpq" >&5 +echo $ECHO_N "checking for PQexecPrepared in -lpq... $ECHO_C" >&6 +if test "${ac_cv_lib_pq_PQexecPrepared+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpq $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char PQexecPrepared (); +int +main () +{ +PQexecPrepared (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_pq_PQexecPrepared=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_pq_PQexecPrepared=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_pq_PQexecPrepared" >&5 +echo "${ECHO_T}$ac_cv_lib_pq_PQexecPrepared" >&6 +if test $ac_cv_lib_pq_PQexecPrepared = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPQ 1 +_ACEOF + + LIBS="-lpq $LIBS" + +else + { { echo "$as_me:$LINENO: error: libpq is not installed or libpq is old" >&5 +echo "$as_me: error: libpq is not installed or libpq is old" >&2;} + { (exit 1); exit 1; }; } +fi + + +for ac_func in PQprepare +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +LDFLAGS="$OLD_LDFLAGS" +LIBS="$OLD_LIBS" + + + + +# --enable(disable)-rpath option +# Check whether --enable-rpath or --disable-rpath was given. +if test "${enable_rpath+set}" = set; then + enableval="$enable_rpath" + case "${enableval}" in + yes) rpath=yes ;; + no) rpath=no ;; + esac +else + rpath=yes + +fi; + + +if test x$rpath = xyes; then + enable_rpath_TRUE= + enable_rpath_FALSE='#' +else + enable_rpath_TRUE='#' + enable_rpath_FALSE= +fi + + + ac_config_headers="$ac_config_headers config.h" + + + ac_config_files="$ac_config_files Makefile parser/Makefile pcp/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, don't put newlines in cache variables' values. +# 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. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *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 \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + 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}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ 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[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${enable_rpath_TRUE}" && test -z "${enable_rpath_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"enable_rpath\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"enable_rpath\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $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} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; 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 + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# 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'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet 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 + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +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=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + 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 +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "parser/Makefile" ) CONFIG_FILES="$CONFIG_FILES parser/Makefile" ;; + "pcp/Makefile" ) CONFIG_FILES="$CONFIG_FILES pcp/Makefile" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + 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 + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@mkdir_p@,$mkdir_p,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@AMTAR@,$AMTAR,;t t +s,@am__tar@,$am__tar,;t t +s,@am__untar@,$am__untar,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@EGREP@,$EGREP,;t t +s,@LN_S@,$LN_S,;t t +s,@ECHO@,$ECHO,;t t +s,@AR@,$AR,;t t +s,@ac_ct_AR@,$ac_ct_AR,;t t +s,@CPP@,$CPP,;t t +s,@CXX@,$CXX,;t t +s,@CXXFLAGS@,$CXXFLAGS,;t t +s,@ac_ct_CXX@,$ac_ct_CXX,;t t +s,@CXXDEPMODE@,$CXXDEPMODE,;t t +s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t +s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t +s,@CXXCPP@,$CXXCPP,;t t +s,@F77@,$F77,;t t +s,@FFLAGS@,$FFLAGS,;t t +s,@ac_ct_F77@,$ac_ct_F77,;t t +s,@LIBTOOL@,$LIBTOOL,;t t +s,@LEX@,$LEX,;t t +s,@LEXLIB@,$LEXLIB,;t t +s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t +s,@YACC@,$YACC,;t t +s,@PGCONFIG@,$PGCONFIG,;t t +s,@PGSQL_INCLUDE_DIR@,$PGSQL_INCLUDE_DIR,;t t +s,@PGSQL_LIB_DIR@,$PGSQL_LIB_DIR,;t t +s,@enable_rpath_TRUE@,$enable_rpath_TRUE,;t t +s,@enable_rpath_FALSE@,$enable_rpath_FALSE,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # 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. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;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,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + # Do quote $f, to prevent DOS paths from being IFS'd. + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #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. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # 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. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +# Compute $ac_file's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $ac_file | $ac_file:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null || +$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X$ac_file : 'X\(//\)[^/]' \| \ + X$ac_file : 'X\(//\)$' \| \ + X$ac_file : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X$ac_file | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'`/stamp-h$_am_stamp_count +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`(dirname "$mf") 2>/dev/null || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`(dirname "$file") 2>/dev/null || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p $dirpart/$fdir + else + as_dir=$dirpart/$fdir + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} + { (exit 1); exit 1; }; }; } + + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# 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 || { (exit 1); exit 1; } +fi + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..5feccce --- /dev/null +++ b/configure.in @@ -0,0 +1,185 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT + +dnl Checks for programs. +AC_PROG_CC + +AM_INIT_AUTOMAKE(pgpool-II, 2.2.5) +AC_PROG_RANLIB +AC_PROG_LIBTOOL + +AM_PROG_LEX +AC_PROG_YACC + +dnl Check compiler option +dnl check -Wall option +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wall" +AC_MSG_CHECKING(for -Wall option) +AC_CACHE_VAL(ac_cv_wall, + AC_TRY_COMPILE([], [char a;], ac_cv_wall=yes, ac_cv_wall=no)) +echo $ac_cv_wall +if test $ac_cv_wall = no; then + CFLAGS=$OLD_CFLAGS +fi + +dnl check -Wmissing-prototypes +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wmissing-prototypes" +AC_MSG_CHECKING(for -Wmissing-prototypes option) +AC_CACHE_VAL(ac_cv_wmissing_prototypes, + AC_TRY_COMPILE([], [char a;], ac_cv_wmissing_prototypes=yes, + ac_cv_wmissing_prototypes=no)) +echo $ac_cv_wmissing_prototypes +if test $ac_cv_wmissing_prototypes = no; then + CFLAGS=$OLD_CFLAGS +fi + + +dnl check -Wmissing-prototypes +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wmissing-declarations" +AC_MSG_CHECKING(for -Wmissing-declarations option) +AC_CACHE_VAL(ac_cv_wmissing_declarations, + AC_TRY_COMPILE([], [char a;], ac_cv_wmissing_declarations=yes, + ac_cv_wmissing_declarations=no)) +echo $ac_cv_wmissing_declarations +if test $ac_cv_wmissing_declarations = no; then + CFLAGS=$OLD_CFLAGS +fi + +dnl Checks for libraries. +AC_CHECK_LIB(m, main) +AC_CHECK_LIB(nsl, main) +AC_CHECK_LIB(socket, main) +AC_CHECK_LIB(ipc, main) +AC_CHECK_LIB(IPC, main) +AC_CHECK_LIB(lc, main) +AC_CHECK_LIB(compat, main) +AC_CHECK_LIB(BSD, main) +AC_CHECK_LIB(gen, main) +AC_CHECK_LIB(PW, main) +AC_CHECK_LIB(resolv, main) + +dnl Checks for header files. +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h netdb.h sys/param.h sys/types.h sys/socket.h sys/un.h sys/time.h sys/sem.h sys/shm.h sys/select.h crypt.h sys/pstat.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_PID_T +AC_HEADER_TIME + +dnl Checks for sockaddr_storage structure, members and necessary types +m4_include([ac_func_accept_argtypes.m4]) +AC_CHECK_TYPES([struct sockaddr_storage], [], [], +[#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +]) +AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family, + struct sockaddr_storage.__ss_family, + struct sockaddr_storage.ss_len, + struct sockaddr_storage.__ss_len, + struct sockaddr.sa_len], [], [], +[#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +]) + +AC_CHECK_TYPES([union semun],[],[],[#include +#include +#include ]) + +dnl Checks for library functions. +AC_TYPE_SIGNAL +AC_FUNC_VPRINTF +AC_FUNC_WAIT3 +AC_FUNC_ACCEPT_ARGTYPES +AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf gai_strerror hstrerror pstat setproctitle) + +dnl Checks for pg_config command. +AC_CHECK_PROGS(PGCONFIG, pg_config) + +if test -z $PGCONFIG +then + PGSQL_INCLUDE_DIR=/usr/local/pgsql/include + PGSQL_LIB_DIR=/usr/local/pgsql/lib +else + PGSQL_INCLUDE_DIR=`pg_config --includedir` + PGSQL_LIB_DIR=`pg_config --libdir` +fi + + +AC_ARG_WITH(pgsql, + [ --with-pgsql=DIR site header files for PostgreSQL in DIR], + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql option.]) + ;; + esac + PGSQL_INCLUDE_DIR="$withval"/include + PGSQL_LIB_DIR="$withval"/lib + ]) + +AC_ARG_WITH(pgsql-includedir, + [ --with-pgsql-includedir=DIR site header files for PostgreSQL in DIR], + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql-includedir option.]) + ;; + esac + PGSQL_INCLUDE_DIR="$withval" + ]) + +AC_ARG_WITH(pgsql-libdir, + [ --with-pgsql-libdir=DIR site library files for PostgreSQL in DIR], + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql-libdir option.]) + ;; + esac + PGSQL_LIB_DIR="$withval" + ]) + +AC_ARG_WITH(pam, + [ --with-pam build with PAM support], + [AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])]) +if test "$with_pam" = yes ; then + AC_CHECK_LIB(pam, pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])]) + AC_CHECK_HEADERS(security/pam_appl.h, [], + [AC_CHECK_HEADERS(pam/pam_appl.h, [], + [AC_MSG_ERROR([header file or is required for PAM.])])]) +fi + +OLD_LDFLAGS="$LDFLAGS" +LDFLAGS="-L$PGSQL_LIB_DIR" +OLD_LIBS="$LIBS" +AC_CHECK_LIB(pq, PQexecPrepared, [], [AC_MSG_ERROR(libpq is not installed or libpq is old)]) +AC_CHECK_FUNCS(PQprepare) +LDFLAGS="$OLD_LDFLAGS" +LIBS="$OLD_LIBS" + +AC_SUBST(PGSQL_INCLUDE_DIR) +AC_SUBST(PGSQL_LIB_DIR) + +# --enable(disable)-rpath option +AC_ARG_ENABLE(rpath, + [ --disable-rpath do not embed shared library search path in executables], + [case "${enableval}" in + yes) rpath=yes ;; + no) rpath=no ;; + esac], + [rpath=yes] +) +AM_CONDITIONAL([enable_rpath], test x$rpath = xyes) + +AM_CONFIG_HEADER(config.h) + +AC_OUTPUT([Makefile parser/Makefile pcp/Makefile]) diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..11e2d3b --- /dev/null +++ b/depcomp @@ -0,0 +1,522 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2004-05-31.23 + +# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. + +# 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, 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit 0 + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit 0 + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # Dependencies are output in .lo.d with libtool 1.4. + # With libtool 1.5 they are output both in $dir.libs/$base.o.d + # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the + # latter, because the former will be cleaned when $dir.libs is + # erased. + tmpdepfile1="$dir.libs/$base.lo.d" + tmpdepfile2="$dir$base.o.d" + tmpdepfile3="$dir.libs/$base.d" + "$@" -Wc,-MD + else + tmpdepfile1="$dir$base.o.d" + tmpdepfile2="$dir$base.d" + tmpdepfile3="$dir$base.d" + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + elif test -f "$tmpdepfile2"; then + tmpdepfile="$tmpdepfile2" + else + tmpdepfile="$tmpdepfile3" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/doc/load_balance.odp b/doc/load_balance.odp new file mode 100644 index 0000000000000000000000000000000000000000..236b949703e49fbd2cf01542f8792357a876ab0b GIT binary patch literal 14614 zcma)j1y~%();8`gL4v!xyE_C8?m9sRcXti$?yd>$Zoz{)ArRbxhwwwPxtrZ@_x`u$ z>7JUd^PW0&s=BAE-a3l1;1C!f DMkDHaEqJ;4&|9rqa9o7JAQ%5&jQ$t%@D}b?~ zBLHZ_=xk%c05o&}I4}ThO>Ino#!l9zHjWIo_NER`-#=s&|DyCs&wmo`Q%)3UV+JsH zvi~9Kz{2S81afjPGPGy>iGz8n`q`NOfSxjx|9~?zHa4{~eNqFoXEb)Qw|}<6)!GUi zL{S#{*?17J=hIXAcXP0xO8;(-nHA8`(e#%w&-lL^^G}Vi1=>2`$ltuP8?#(CWXV2>-!KfVH8ysRN@3z|q>!*5SYO6Z{j{ z7--}8M_(N2j>auFVXp4ds>+y3ho49$FEb2YeJm(Da+Yr_XIYd}A}iQQA<-n8eKYpT zBw6)4(R$3puu%so)`lpEeqKxN9O=1;H5e9zt?hAtKcrNL+x2@GiD)Y62dXxL(L6SS z+{q|D!3_QA&ecaEjZZGX$5V>5F;6UAx7b#l947P?st+3{Fft)~YFQrqdK8;#+Xde4 zm^|qlR7AG&9_bR7zC4I5;k8Ya<{ac0nzNha%ZEs74_XvI&&NP7#cTe&9E16+@^Y;Jv~Z zeb<*_K8$8?h!#=QNx~`X z(a$d!1#XT=!8uZcbAU=*NjtXs0d|@}n8{vh=$p7EsSsx_(SEP&W{CP?8uYfSw!1S% zW;P{a-3N3^@6%NlZfCT^m>76s#z6LA2efMcA}W!5|0$9+5Db^V5UMjD@ZqkJ;P=!WC=b=}*mEIkhIdZat@#X#V_`MtA2HU};p z4L^G<0Aj>ub@7lOyrPK;G|{|5zzi|`!Ti@>7pNk{40SS(CFwLo(cP>&XMnMd@+9(e zCe(j0!aHx%bgVz^E%OZwDUzZcgpYIXns3@j|MXf;fZf+riB*f~MdGR=N2}toUrm>w zANR+gq=N52UMhu^jLR>8dUHpg$Lmh-#|gnelrni}&B-g`eX!2A)ihG%$4 zA#62oY!XE{vF8uT97^yU0;e-7lr2gfzAmGRM~;3>){G zqY|iWz;Dp@YpMZL>3m5~0(DbeaZqxKNjzL1aak{A?>TGM2H4yz1n?G{*vuv$HZS=4 zE#!p9pa>9C5JkVgF(AM}dBI2|X3T{l!oc5@cpcRYwtj3-L6ZBa>s177GGHGODar~0 z>}#mMkzN)<0ElTmA9```!{DuH7Wsz8=H*T2;bPji*Oo{3~F zjBjyG1LIX;iSI&FQ+}&lF1^UzMqh~=Vcnu?5LIdu?%T&0y!BRs`z$>j$Z=etS9i8W z>Sy6;BVSe2!G5U`3f$5Wnbgo^oCb@eWJ{f%h8krIs|a|7$*7XoI9&-fsmSm}jl$cm zopPBVC*+;9P>{08;22m^Ij5izu043-@CoFW(~**dmEZA%mkVOqlublwyd#ds1IW>~ zhLGQ3sI11-q_B-VCO;|%onzoC;avvBwLqnAOL8QfHzsHgPR47ZR1TrSb&FPI$E8p% zAEso4-RR7Ev(hY!&W^n=ZM$3k0-x&;fRe#Ya^gqYVqv#2v|610itt#{=hoiGBX@|H zI`7brq{!kte+aozupWJz{QCRV<){1mS6Dmvac=trDdrJ(v8*S@gV%z(p)QJB01u)p zgj=i~-IVzWz5wWp$Zvdz>dE}Ot3h}ZB$61xLt}XbQ8+S`tUN`6Wh#F9S?+Fe)q~-5 zZ_;$5+9Fpg5a|P;ba2AVsCo zk35tl3W(9Z8L=rT-StnS3v(8p-~W>o__QzOM%V=|2I1q`gt`|f<_ zo_yvPvN#5{xL4r~YI(U!?`!?V{omLwhJOZ@gtxCwk(?{uuTo-`RF~%@QC;p+rdM0N z*5|daQxl{g&p7Ot`xK1BDj!!9S2`;kPyaerzW)$x><~g;5bl093f!^=CjGs4gxRI$ zwGENhqH!mM$5mJwU9H_Pg;gTuTzGo>OPj=M*R40^5$>W#a=7d$ijk|r%Mo)&$WV9^ zCU#8X%SkwQzM*+81NG$J6;HM1Y`Nd{2P2yX$zlwKeC?CQ$IA9Mn*Y%&I3DN8gVxr%)o6dL<(4p+k4HA@T7mV!+!*O5=R)%kJg)y&&G zCJkgAKpXZdXb6Rex_yHExqstF-W=-a%NK)-t$Po(9farz)HMrEOExa|CNzmjNpF|e zOM~RM=bFMQS!w`zX3LpfPC)5K35D${e!yjupC#SV=Yb_X0=WkK#oo(FJ7mD-qQgaJhC(%l zSBWk#w_=h3Yn?mP;!i2fkXrwkhLe=$HFNN83BH9xR;Zv-+ugjeL0eLq4YSaO*l=#q zk)bj6>v$){PUeCtPgIus{rlMpuf2CB=`<8CiLMaBKZe503WGWfWbvw!AJ=^Iw5qY% zg=2*^c=c)rd337Q)Lg?#iKOTZ4F14NI*+^*O9!{fH<}TEr897-VuWiE>wQ&Xl^rfO zRiquZqmiS9 zHG*$RdoHA^1l6SJ?_onjQk^pz^WVkv!I2V>dH%2vW>6HplsJI*Is zjG)9rlIdPa8siw+cquF;n}D$+jU@lEa-5R8C0Yaj+Zm()V{TKM{S`KHVfGICNBebA z=Rwm~jKwd;Pd@fs&|4m<5+z^D3|}&3e)j>YV|mAk!Coc~?z2WYI^V`Baa^2o+}ajN zq02kdinm)8q8PkEzP6CWg!3VfRxd6F`U=gZ8oxW_km=C1mRg-SxH?i#E|bW9d*ZI> z%{WobcYjIMALa^2mB_CvCzz9(UC+jTghK?VB*MQ{S(kSdieHc%G_WhJgSH-3&pQlP zyuX)g)q8mwDe0baG8TWb#xZqaRQMikdxmJS*Pa;>U(f>F{aytAQ$4qlt{Vi4ZxQQ` z3=1HjFf_cw%|Y^e6q*He6@({d5uwdS0pNQ#`U+s=n8nDk_Y*;gd20yxCs}cQ-1X~9 zJP{=`dRqcipta|BL?aGbBs?sBF~5*>;SP2c*0uOFKqgyAV?x))$6!Hm&7F{ogi1%$ z&FED=|3@Z7#XYl)aIH>0Rzm>=6}{&f0?~P922(&M@DciX%6Of~m|uzj0>T~kYs&af zGf}vw8IFUao0X}<^JMc#S2p_70BXmsIt<+5OX`jS;z3?xt`Izb_L{CGp(^@1@+sL^ z2{_$V&6ct|-|lwx z=ea+luWU;{CVAulseQSAX8`|cxvv9JI}N0G}Ua<|9jIo7*_3-Pc0OrV!h$ZUkeB_}S|SLHdS(bmSz?jQ8l z4(w4X&C5(RS(Vdat;~;lbhl$)zvT}g=;MqqFRK`zZqQEgZ8+a-Xp{PG(;BE`X(0qA zlaDLGBq1NuvcRyc8+sD|t~$iY^1xkVzRLQh_k7X=TMDg2I;7i8&aXYA(s zc{1k{$<@ftnAXc{@Qq`_rjj-bTJlS2Cxj5f6g0;|l)R|wDj3ERJ`R=FQDfJ!>0P0g zHk=%de&*(((91NFio8z2T2iN=>7GT`bC+6{QA=~!u&1kYlb;$gN?96*nvI;?v+s2G zZBFzJ8T}85-J$bgZv{KLSHDJ3!ClS3vaBsbV;%dT@~z1yhOtZ~gjG%2n|NtsCQ8#V zEL)5;&MZFA@*Lqcf$>IjU&7LBgBEAn zF5&sFB-ENkYULo6VpS(X2n>3OLu#k1!~6AMdI+rDvDXrCP==8ovt|$C*at@vR9E^H zMQm1Juh5#C@m)dB9i-ojrd5E^D8a236CrF(=smih@APJS-)}Pd6m~lF%oI)I-l6Py zaz^>npE}TsaMn&8`hdhnBxm>P8eMA#hL{DyQeXIXuKBUk_zO_i1Y~B5Nkvw#zg|U4 zr95@RdAyi;b<%midw=5X`S@`ClpRzuoT2S|We3)1nmThAu&o16=egut*7d;`5Ig4u zK8;(XpmkQxsg}1Xz1KbX?&C<6Qn|)lo?d;0bfLZGQDbzp_(L5Jiw9CeT6%tI>^XXp zyFV9b2RMnjy9w^Q^|l~%AO9V_QzU)LQ=JfZB(1;?Yu%$UMnH#tE2wWe#6Csn7wY2u^s%mL1$2!0IIa{A(w@=B#8uOrlAgR+4q~Ym>KuUEMErVVfa6 zq1DnqdDvo(5=o!(D68#utNB~XV8*tt*|KBIBiasW?eZXH<>=%FdU_(D?=e@Kbexyg zv8WBJp6atTnfM$u+pQ&I$prv+a!n`mqY6KdUl_3DCN|;Gi>Tbizm|5@cHn%tCiF>} zYaY%+_KXO=Iht|Cah+jcNZ{c#{tlZ8D!=8dD8XBV;DV|^J{>{_m`2NcKMgaOpqCBo3Vi%NCMc-q|c?#ev8 zUwkPtka!0umkg|$c~ve0L>bdh%HJu|WMeOf569I+b_8OCRn+#dVHntf(8~4tdQu~@ zpPOnXbce%6)%v~fEThV1vdWFlmk+Be$LsgIN72z037CYRC0PSgt1_;Ut>Id%Y@#7C zs|)jAbth#;%C;A{l#`mb{RSZ;#*RZSGOFC1M}LYWRd|Lyp%fdA@6VLSr<^F^!9lZk zxgh5U8!keQk#J|C;fgUR-J%$CBf}!DVXeoja25=eUuf_~^>b(vkEvxE3a{U?EqF=y z8HZSl4;i$_sL2n?p1e&lmQ)5M!|?10UvD%M?l*Y@FW~Pe4YdkB_`7 z(19ACiHYMlNm+Q)D704j?)CbikqK^15=BRbvlB1v9n-MG{0%io+?+1IlY0Dd2$V`) zYBW8}A|>rIaxAslJP$+gV6gGZ50iuXM{0p6$4Sz^1KDrj0M$3xnR&_;aXf(v_0l46+(n(e}#7ZOudFyDUMlRNViTgz)4uuKSkJDMQ;ehFO~*R&mdm<@=14+8&I0#*vSsTi@% z5q6>F?I--v;h``ZSAy;fm@LUtKL1@*z6tCzRKDm9H;4&VzAzUBp3p?a4InZ;fhTXv$erJvId>n`P`qA^@t~pnLPWr zRhKUI!Y8lI`gZpm!sgrbz+MPSZKNt@oV^LmK*4fn?t#}hfV?11LGJd9gd*Qsom>}?{n5qgzl;O?}l zFvXxywUX6Jwic=Oi}7t#?~7IyqppF6Qa9#6n}HEh9rHkyF_H`;;rzwUYb)W0S{Ozv z2Of}!nx<*0WFN`CiORK{^%Xhq!TZ}_T@es@vSzk zwq3buZL5X0g=1x?cT?!>wIemVy2mx=ZY{%%OxZ$5_h*S@?$%DrVq_|p!$d0?6(V1q zsw$d(_7h-!<;n^gAbSGoSo!jcJ9^^M3&(b-udglXABoR+CTVFe2%7~^9rLj!FKu$( zQR46VRb7I(haFmy@sEmahUH9nfUbUlaz}Qq>d+a&Y8MhXfx49^^q9m#xRYnhVQlfU zxvGuqFqj%D*Jz9Oh zg5+r>P!xH=7TuL9D`T6+BJFI|5nS=6y*G}(0$7Vz$3nR-+1HuPGkrA4|UR2E5c8_#>62PnO4+}Z1RQfY%qQpu^83cJ`ffRNh5}rMLdU6 z2*e_GWD0SHbBEK40S5K<);pk|?$r+|7l;L;(w3FAVyjSQk59*vN8abj&ny#Lz7F=Z zOE(5=dn2HXa2ZRZX=UgC08 zr*$&FQY`nv7L$fpDbTzl>&x zC0%T2X5UCN#b8wIvU}XAhdHwTn<}e1IR9-abbH!6GE$E^#l=Zb*aWm>PmjVG>LMq$ z71w7YSU)TNXVJC?RWi zPbJ+{W{@|Udbk1E_!uy-IEqU*h#+z+cm?B;=L?FIfVEW^9!F7iE z(yZ3-#q+6SCD`qCdR8w@1ChcImKcEAjc41BQYWz5^+ui$Z>o}G%&7}ZZQh~U%X*5! zi|O_9M+q)5zxhdjuVhTh;<(rE@(3_&lUT@=3NMBsoN!(#GkCFjtf^NF-pcJ=v=$!{ z6OC6HuvC+%D%%JvqtsElG*gBGr*ZQnF^xRUlFNpR054QpRW*sDy=TangGP}_A14eA zJc!=znFkmqz$t8NK}B0Z1zTlpL(-E~Ptlq{y(}WNZ<;#<8QB8?Jb)K4n5d{N=OmbB zI)cd1f+gw}P*%Lpjg+o8vDAacl)vI0%=v>&*#LcQcjKy6#AvApcM_4rGSiXIWS* zYS@@EyVSc+83@4|$t-_gHoCJ?HoFuM0R4&K`%iio}i7>K3BJJ+p@aYivPlcROZhjo@ecuyyNC{l> zW%p!T2T2u(0RW0BO7kQ4Ux6KfUCl-=z^K<~y1|Yb;WLzRGYv!baM3%1c{GlV3-w+9 zoLhd+@XsVe0s&$9@M~`Qi?9nbx|(?j2?Fwb{GeP-9SxsnmVAOwCn9H4dxs~|m7j!} zfr*63)W#TS0F<>q+5oKo zS2fSFKS=VQ3jXNn--ZM;iNLS^e|D4r-w$`0o7((j#RXnHwd&Q6@$s`&3~Xd_02?P) zqQ4gCKatRHOpP5GIk=dtnOVq0oB&oP^xQ059DIy_)A+LnfDOPAVEEKTd(&t3T|m{) z(ZLBwB<)}U0Q>>@yU0)A55UuSrZ;(_*ae=v%tg=4M9<2k%FM>Y%F4sc^auK{a(pJn zJpWwPZw1dn|3@o34;woVGZ!D@ufm^Z*xCc0C~6aWBe#Dt{kPKJ#Q(3!>^!VbR{!$R z57bYgpD0t4CnwpM(;K@PKP?ssu(JKpw!dBftFXx*+ad%MRhgxjS>&0SRsIJ1kHk-) zlY^-}y@{zAz{b>s=tpNg-{brwI{`tTb83m0Nf`ea75^VWmj6|d^?wy)`;Xv%o=wj? zJpc}l0OOyQ0*#(W-P4WYWaG$B!p->%_~WkQ`8l3{{rZoFAD91qo5=G%2~`UxYa<&& zfRzKI4OMYw*VH3ZLFc?<6PY>^6D61X-#Fg%JXAzAE`t%>ZOkAhK#wd>lF-T(G9quF!JN-K(2&>rnrX-thWs7T$Sbn zI~{am%h#@BhsBu(O&Et^;=mQUFYN+R-qn{r9a=u`kpZ(XNylXlxq3M+ew^U?s8;9` zb$a_^z8yn+MZN}H|3e%yk>!Ir)`2jciwV9!Ko=)r91rOfln=ng7W3>Fri5BpOJQ|O z&9x5EPq4-D;+{_-jyq*9>$1j8b&R%H3)v5uL#u?DI_>4*ohdvo@A%D#Wg`b3S{{Ak zMwow97yVZ&|4MPA29^Q`b&rN>-<@Pl52^e~-7)T_*}NC&25i+nxMy&3X_e#MZvE6) zSh6;vux$T?;xG1DwN$Cz4C{r(un?O#edVxZFRFM`+5JO_uGlXR&Z+kfnS+c{KJW> z*)?V4-5YI>?}tKL_j1F9#Vz&X-DRONTW}gPGT$QEr$lH~7j1x2g0@YTwvjs$B@2_A zORs$cy$cF+!y(CWlq?&%+V7Plpm$o9tP&U&nADLjn51rkYwVY?Vdf_` zQ0Qsd2A*pLJ&}%~HuusBV`+Vmc)j^?KbTw#Q}N&dBAu6KV&1;a75%V_i*=_cNqHtE zke1O(3ndCaSpIDQ1h8jg2cV$89q2#0VPr8js8Wm;5fG({zRysRF1L1Jz6`;GC0{@J zv0NVxHNLq2H8#@Y<(*vl>I`oH(4z%+!8%iKZ%z$TZlZC=i7T6ZPMVyS%hc;pyAksk z3zw^pD9Nfjb(LT*2!O+#)zDr*22PgH=Pp6O0&~w{lK>q)rr6P&di%6miD9x4Wl`*Tgdg1-ik1CkIv8!uk5rKP5MOFI~XmzmBmTVFgnkl+rK zodH>tS8OmlU%`!KU7OuN@<0t`a&*|9%}#y#{%gdi;9-96FdC+z6CC!vPiayG+kyp; z;JjyWyiQqpK@jSlH5DGv*l}$^Ta(UNRj|?ORR{r&q*?)oyVPoehUxf5vaQl~vJ3nm zvy11fX*35$X8JA===r`7$R(83v9xmRy(x1fWL&NZ1-UY}UI?&~FDHf*itzDxV-R9y z;$gcY((LxHb~96psF-k*;4y=!AHK?w3EF?Zu0@3LG&!Luu|Omm@1*@gn*X)F`|@jp zcJ>Sy4VdC9ehD-EB_J3}MJKh=gAvsJxKF$-qQbF14rko;wuj|cdg*n+W7=|OuGo_> z-#Q+PN+;nd!d4nW>4}Xl0V6gf`?^hxKApJZ4=7&F#_wh6YopbjyU(I|gBUGskmhft z&4zazY0xUHI-O0*Zd#|{Z>i5Q2KqK***Bojat|d`%oPwyA;|cA99rh}_Fp)A` zv&P)2Rf)Vk2OziMk#4btcE8dtFEOLe8ZV8XGhvrpxr(iN1A+IVG+60&q|lHt3TGKr zWWIt*A04L7CbazI6B~MsS0OO5_eEtBJZO#m6**CIal4wyphfvNq9tAFE(P?Yh~}|< zxQC*X13u}F6AIU#zbui+_;{Sp&|uJ;951hm(`lsifVuMEnWGe%3NVF4= z6a^&UxK!t{YOaJ$lx_r$?<7iEzRpS1RZE0gFp=D#7@fpu^brX8S%<4+BWQk%Tp`AE zw34e3K-^tX^zT|8qe}f!g4j(>oHw?g7p3~D`jQi`;G*>E);8r(ZB-6;*6L6w)A@~b zJZljl-;g$IPDEpI5DJ{x2jmmzw{?)Pp2))()(TUv>%%q;$^d1h5Q#&Zhe=iR%Au9Q zV#O}BUvc~OqDxl`x%q>FV+ep5AI0yl7>s6v`!7nJ`DiQoxEjLv`SqYhXn#~~5O`+r zf*haHV{F4Hkug>6qRQx6yS;CFgQ^q4Hv7(V3kchzdT&36+i_2|`bA-qq|6)5Cb!R) zSG&>0mN6B)wHf+7@w%VMS_D63Pj={akQJG@bO4{t5MODglQw$I9yC@bM{=n2S+;0% zI$;Xp@M~QI{f-r<(UEw``djJl5Pjo_XvL$0s`=x0j%RuVaOujURHl!S1=O5O6D8v3 zGd;Y6U)0q+59sm6MQ0rd9-8IiVw2@7zT9KQvO($}e{v83xX^xTJT5T*HZrR;+|zAf zpvCQq{5D_55${8l3c zA9t^1ikCJ>k;Iu|GYjmo_%vje<9IxOENA%U_kNc^Fzv0O0XbBA9U&ODK7P^%8s0ob zfpGr^bV;UdVu`O!F{LSzuQ-mPC<4w@b}g&}SZ@`|-(6jm30?0ivw|Mp)N$5-!zt+3K@ zs`tg>z?6K_P@hYiB$^U`$aZ3`*Y&)JG?>jCwQ#D|Ffw0V&EB))JiCAo`MfaRmJ4{d zlF~6i-3|NcaDm^KFMG>H5O>aP(C88vsbE{i$LZmEPeS5kx&i-AcA!&=r>eL^{^#A9Pl(%`F9F9{uXSL!*83p%P>(kVC2E2ZUEYiq#Lk zC7@I#xO#Q>gJzCYqKOZDVv#SOj(>lXed3`(984XbXAnP#=2b0Shb1lyuXX*{v%}uw zLlh=yo*?NjDb>L*V7g;KfIY8;#FO~qbVPl;$iX$iIC5Fm_N)kChNijITjpCN=Q|$W ze?9GY8RE*@9%o{NAAlr7azagA#pxAhy`H*Jz5SHb(MANFq`MD6Kt?i{i&6*Q8Pf~P zSk1VO14?QN$F*e&#y2$DL#;v>cT{t3b7C*nV54ay_QGXA2c|P)BE--YM^9IoV>G=` znVL{{)%g-<8x1aWXk!M(W$JpwK@SlJF`w*cH*H;s(kNQV59Be z6;){ehTnb4juzQu2OQ)huA(qzhJpIX*?`qQl8l9lD)ISl;G1o_VBanIA%`cb-3IqN z#TJFA?~yvp(E*%-dg~a4RxNz0~6L>5*{{>;lm45z7!a;AI+d z8<6nIdDmSC&LHW;J?}`BvaQ7oNcwS-_6+Y3dGdx$jCbhxX@GfF6f?b`ozQ*#G1^=Z z+B%?->(wGk;>B?ZB7vE4#JKs_+3^Gq#Ap$w^87QFU~a+;6oZ-~`jFf85V zBfe%iJNg8UB&efah-zi3dQSQ1)i(34kg`z<)Emok>7%C5wU^5IiKtU4`Sy3gu^vBN zt^5>%v=o7bd(dFI(ZGC;gK8Gklj0F>)AO~dHan}(&q+|aklwF1UPK$^imqBYSJR|f zJCDe19I(acRTys5LD^E{GRS;52e6okDW-$71bDRwsF^U~za+&vCou8C9pKee`A}x6 zM9>iA2x)Mii(|c?cJ?mlSlMo4%VDEzBUiYMPl3MuvDiHBE4;%uIs5$TK1&QHr1(n4 zFEkN8-O&qKaP8Ffc6pmi;T91YR!%e)h{W?FZEWT`HLr6JGOjXqye)$%qF5a^zT8!Q zq-e;A*v(1*E=^AxZi#3|tX7j&%F&CE>N~{8+)C1M9VV z)7J{2wn10Nm3M59SLs|#5!=j^uGNj3>8B{J`g)EtmW#qz`O_ew#zd3QwbBbkhoNml zp*~cXG{H|81Ymy1oYSmmC9`{Gmodaf*hC2IpHGJoQWvUOQshjQmYW&qA#Di3lF`~2 z5ysUV6DfPCO_V9!h^~k#HJ$dPo7s)KvX}jKO%nr2q6MKqNNYR!0A&`abSCtrOdrd^ zlzHEG@7ua8x#Q0;Q6fWNK)*>Vr7}M5ppV$~nPlj*nzW|!_o{rjk{;=5d8E{5>pkYA zJ=ExYT+hG#%Jpp%zE}W>_cC8Mo4(wb-fZ7e)Jv7#(x#lS>RU}a+P;s?i-Csvir9TP zzI6{tV)J_Cm%miM< z_TP-Y9j1?~>C2J51{$0x&?7869UL@iY|WH2Mhur|fn4^KS>EQV=orm=Y}KugUxo=X zAj#s7`rvWgT>_LA*?^If4{nI+yYX8yAd#NmYAi6eG1#)L7B_f3wK{jth2Er`(>YJ% zp2%F1UM6z-W<^I+sLmnPw3?^_pDtqr7F;Qz-f@>Hvy7AfgR6liNI$!&z1+8u+#p zyK*XACd+8o!`t!95;7XLCUOwlITvAZiGyazS&qpr`76g~`kU@ZZhY|@x*9508`ZJ^ zb*+G)It1x28Pi`&3)5zG)gS^8!*kI1f>VsS;hNC|f@<+<-F@6;+Ho^PYGyYEN>LTt zaP4V~)CMyTPp+ZN1f7s4f)6aa*X^5B6ly4$FZbnL&t@LeZe19ryTQiaItjgLh%j#- zv-y-*OZA2A^Hj7$?=C$ZN@B>F&Qj3L83ThL=yNBykZ8q=fP#Q1LqB%{C>RFFzsE#9 zFWmo`enm+A9rdRK2*`81(4R@|Df{=Bqu)cIe%Ai`*0W!6OwU13f2OFX?BDhLOGwmz zGwylG?9a6Ql>NKXKLeuv>X<)Ke{Ul0lPmwO<@W%of7kOIBK2od{wF7MR>`WZq$DN3OrzDERsKqxZO;-5hvm=7Qj^m}+H5a>-QukZ@+ z0KrcBt0M@6+6%P)H?bUOTOiQVj&%TZLIY(0&Lj zgMvb&qucQRpc^=35p!Y+q8+Kf50oNyFj8j_VR;yfW?; z!8>@YDe@*%DIcF-i8IL**ixJn*V^_ecz6VH!uw%TH}fEHT_~T3m;5iMa1ufqviV`$ z3JO~wl1CBvHs0(bVp^Ywqa^Z+_9-Y99+h=z&<3GAJuw?>_3pQ$zp50j1|!aPW0dHZkROa zE+!`N=i^?b^GG%}?xIJIkJ<{T)?hBd4R|-V?mXvm$(f1W3;$ImTk1%|DtcD=y{Q{G zx~;z}`+2kO=4f8%q7MtPTsz~EhKcF+=0+Nj4$hCHr2UlgxE=%W6oq9sjTUj65S7=RSCZnZNxkZiq(sJ5jXtg5 z7qul?&pd1C0E!;kp@+-5a$pwy|$3Q#(&SWGr^flk(;~f844PpkYGWMO*F+ z`w@>>P8Xy|Oi(3o*9DE{c{8WspoR|(1tlvhyAYj^wP;+1@A(I+{IAhL@eAI8@XjO8*eV=Qe8)|u!N zSIVyHbN|GLDigIOomJN9%qXmEX%w3|d$xV!zQvj=!YX4n;`to=O&?c?@zwdmLm`e) zu1p&0zS4`PuI9(H*eUqkZad53%ZB0Cl*1DRYERE6c}R31V^$iAs{5z9;H3uZWw8*{ z=4RsGOQuCVFWgV-LvRYieR_jFMr<5+mpN7j=a~$pe#oToGFq0>OAYRdEC;NV$xYsldsXz-x!%_H zCo~b)Tg;Uh^ac;tb21Voy|qqvEENWnPe<^IkEce90f(u!nVE^2`#1}0qltJIVTJth z{MRi`+b<4#VXXK$O-*fSG;Jz0-RM8Re$IAyJ!-$ai+?i`@bEa~ZQ2^#xKopo*-5-> zVvvliLX2D?#pCBHS2Hkqil7_474%&udOq)1=i6-mu-)1XjXGXS8*x9>haA1$YX;LI zq2F7(N{TT&_5vj(0w%RwGR+T&Nj~1cwr^-$gg9uCFJ+MezSOY|y2wa0iZk&$3DplP zN+IrsiA+byOPZlMAPqoIlU6fp)3XI3_U>4@f3H)FkB>K<%w#a8G(rj2Y~Xj;`L05u zBPLCUMq92z8`K>|MuQ9{ObBUzVZGf+ z#KBecDpqzgk{@Z&8-7X>wRxz>mHZv5bgcs9B zWwf-IT>bTQN!K@E8QsqkiX@d4i9cGN3|e3A^1$&_0YVREC-F+0U)%1Y5wNs%6SH~1 zx2f%Ig=;>qXFNPQYu>Fh-!3@QCfA#8&C>HPH==yM#3UaqQOEWS(a~A7nN9m8>3$H3 z>)}pKbkZShI?olINE=Q^qZq;XxURF#&;lt{Y{L1y*wPN#`oQ~4J z{zSyx4Cx>D_TR4WKV8lL_DFE46Si-SGr*M(N@Lh!)z(&FM(rZ!=!wfD>$ zQw4GYYwjWPqq>+>?}FdeQNY(G&7a)-(P{Q(>pcEv9`uc+XUOR~LG(W}250}BB!?`M z5qW8lK%)-Ey@mM`@&~(Qhp601&r5BC1woZDNF}f1o_wBUB!9hx;)dXWa0- z1k$8Vj{SSD?(XiOpdi_@6i+F(dE!eXXk*sTpE>L&cxLzs8Je}5JzxzXw;d|!~64V;<>xKUsl9u-J~}|&YLF4 zjx`MVVC|JEN9Mk;Ddt7T(tm8i4$PNIeYk%+;9P0_vyA=mF6QudKf;sKK1kbGpKo02 z>ZeLkDyQ|Ii6XomC-{3^$@Iqn0-F4pX7ICv21)WOS4)rm?c20=uOWNevG$irFO3_D z`-O_l`1PeDpLGGbP6iW+EfX2w1jc)Z^zK8oB9W_lzx8$d!}xk4swQUPQC@F+9P{EY zv_&^8M)A%Z!~j5lhb}}RitsO1c7Gsv%Z?iwpfW;Utr0;8+O@o@t5kF%#gquG(wac94 zy-e$5N`NYJ2G1o6oKY&*%EX)BZ!-6X^)*l!$<+QNAqh8kAfOF>D*c*MUm843HXD0G zuzuf#wY;XaF_G#X@d+>Ccze3WH{9me3ZzlJ^k%pTSyN>LHf&U8jXS7&D$ec|ndK`Q z1DY+#dQIGiPG8dZIPY3TW+>ME=6!=ihG!j-mmLy?y9!%VByxLyUQH(a_&_ zGRCq!`L{zG#N#qDF~MB!k!RRMtHu3`>pov=sIwSC!{uCPfzPxN-+M1F-EYrwJ}ZA! zp0E%kZf*M2XuDpn)!1@HD~lcMa7zrIyFNO^a5lOu?eb?UE{)RQa|JX1S4?C^MxO3? zF2PZ-{o!TGI_&c1Lu(U-TS)$lvr7sS?-92vXGi-`t+|w!FX2f-JR($UDL4Ll z`sXStKQtMBI3sPt4VwPheQM}nVw{#PTIXOu*t$=#okd`(O-X>ssAy>vTc+%e5ej2} zcxPcjPSc2V)G<9c8baK3uf6?NKx6_t`0+$ZXXUB{M<$4@;29qa%W<;@ zw!3kbJUI8~Bwin)SiV%+aA9>X1H#&^Vv#Z?Dgth>baX=#F~*MbW|Y+untat&_{Qx7 zz2@@q$@aF2vhwD&o<3<$5ZO$g_4EWGCqp$a#a#mFa{Th;k3iz+FjR+NK7pksTN#gh ze0MLCr6Vo%!v4-`@Y=be2?+_S0j8|z3PGvUZBUDth4n}fg!;CS>UVvO+Thxb^T>!- zgB)wkJ6~eC>E@DhB%hq2fV5BJyBF8wQRg&j7;XtA!3U4;o4Sh~aa(dPat37?jJt-W zfMYI!5gDw*VzuA;gd%%o!D=RBC19Ux8;-;1vp_VO^vZ7W%UUi;_an{S-B4_#lECg| z2@HpB-GP&~_Vv@f+~ZC7;}#N0ZORkPnH0@PbMHI)(C^pRgr;!27BR80OYM&-mh)jF zqak(XSNEY|WyYOTd2M$rjK zqvhswE>G?acBG@NL$%QfKs`WbXh_y4gXu1477KB!gIf#_*|O=%+L&uJ=ts!qCEG zFFHI=Lc*d9dv)EPS_70SO{q}`vnDc9c=L76_NiQtxe^+gnbO^0)y1F!P>9HDYA?O} zA1{gEf*DMsRWggV7phDrOnn&frk&Rd6W0Vgb_@D}STN%k8=cK!l=T@?b~VN_2fyPj zM?IH{m=TZn;B6Sy5du6SEfYfukn*L7b-0wy$?nyiaoi2+5a_<_h>Nbn?HU)5Z90GE zBJ}Z@7&67uXnJiPnYOp8@=M3}U@j$EjX~j;Gd>>rP}!@po+nh(Ri$vW1&so2__&+a zptr{$*69*fcyV36zmVQeu(r_d-Rz%sz)3V1%%JPHsNUk%?JFIFQ7LKkxO;^&^^#;; zys%-A)3X%2#Dvz1F8$HNaA#qo#p&>~fq}tnp~Bo+Olomi+1TWy(n-0Urb1|Bi}O)Q zI|4@%F?6pg*0%t4&vBFTECnvi?%AWI&g^c(t_AcqsDq`&>w!puEI}{L-{ovnv`Ktc z;ldP}50I0zq$J=#75vII%hM8#(k=F@kJx$0QbJ-ePT<~YqO9B6kts{3?ubrH@~MO* zs0+RCaiSbYuGZzYnq<%gQM0A;yL_K><@j??N`D?$;Y)*;XVO#5f+s^uEga<6-

;t z-PnIlf3@ONF(AgflMnyMN`}CXBjC%41nT1_JwF3h7b`n+ zYblo1FSIoRNin?ntGjHSv++6Cg%5yB2zS|wIC&?&7jxeaJKtp9=VZuVtYup_UoRPe zL7!XL7d&wB9*siP#Pbg6F?LN=NvUSqj72R=e`> zz)J1EB#ujuG!M={HrMJ-kqqszG6__s5_ zP&KCcQTr3Lbi>LhLDN~<(`a^P6Cp>_%eQZ(#@B@l=|^M@TZ7vnIzLaqGDPxx!-4AX zhmZq$W_b=~PWGDFPmn(c2F`!_T@doPz*=0Ptpq(W?H7fA0qzpN!Exvm(EV zyz%n5ze-p5z&YK8ez@G%jy(x!;8$_pr~XHw8)aNAWUb8Xq%h8w#rgVb_+ zAM#Pn2T$g^13DBgXTDlZEkAI~;UxxHuTw3N{h&m_#M?>4#al9;A6aXZL2|+&7zjrc zIasE+%b~iqj>BM((8QhB5Z#|qUN8JNTIHp#bNN;M%=dv{g}I^^Kz`m?iR9SEZ;2CY zT1EUW8F=KZ?#e!PwyN>sd*B?N+-w?##88S^&TR_vXw+&TJH7ErtLs@yLH|AHM>{r( zfEu2>(yA+6K9q8VIt#l6p4X{5nJGVMbxhh>`&51~Fb{(_E6)KT#b8)*&a??X@bgQ zg*fZ%x=iNK2ywfOS^I+f*d%JQM6uoJphTfo_MNQY3xn>~oZG!TXB*QqR$7UzZw79| zAdnk!N5-uCX8>zF;^;_xYSI@^^4+Mai&UHZW{*dQN&^3Z5)=XGv+5@B3SF#%A}{&5 zq5u;Vn@6jyOW0+mSsoxutZhYLbumJyP_e6Ywid#X`KIXX2ak;Wk&)5G0J@7=yG$iC z{hb5%pZt?$9UGEm%VlYCC|a%~&%NX|ws|7XRlHm}xZsG!S%T!ZC7{c?ezj&QS%}qI z5pX)OTf7WfpB{l9hWwCxh)))5&9tN8KQCV0ASFM3oiiKCcX3r2<&!~)8UKl`mIW7l z=)bQ?(ZOaLmdnHOhK*J{Sy_59$;Ev| z-|2rAlaj2~xmdI6*mnB|kW2kWLy44DdOZ)N&Rnh91cI~7b&4rmiEjZgaPB9oWsA1k z1GLrNv_LJvOdlP0d;3saQ54F3PD3B2pa7eaGBz~uWO<$6E#?Vpc^TyF9QV%=nXvb|6j9{4~>=Y`}xwQ4g=>4`k!rx)DCjI zwX>rp^n86bDYzYVCboy%x*c_#n>&rfhJ`Hf}eZc^edHC5C~ zo4ds8i;)QcU-@-(Os;x^M+@Y{o}OOPnf=Bh(zzyEJ(3wC#q@oVZFJj`Dc`)u7XO_< z>-6FA0mfEy6diA)LQB`{M$?=&1+Ue3^p9AGH1BtKTWdjq>bw>Q?)xuh)9efZ%So2b9bDleQd@IX-L|J62<|J=5C5JN!= zgZ{g{GvZ8hey}t8pA!35g4=I{7p1w|#C8@1 zGq5US!w4hX7OG{oF>)Wf(1m0}9luC_M-289V&`m1=f%4)YYQvb?y_@Bc)v_*cG&S@ zjj*=yc4boWZHR>3zGYj?yZ+VHezeV%^)SzSdw~x)Cu10|Q(-kT3l#4A+lh27HqwN2)ix{leG4~CBo`<5upcaT@t5X2S9c49@Fm~^9 zRr2_NmKW}xGLGOykZ&s>mFGXbR4wDsE@>j7X#>KQwH>XMf_daAf$oRFngI8zf zq{P~8ejfoQ@rVi({}bZ^9K|@=wZBm%ACQm-bjf0iNh^V{!)m?8ZXdf_Z8}d?A^ffD zlx+l2+UMWTvbxla>%%y1-UG6n`-zjUxoqaDF;3k$v&Y@igMQuTh%&t8L6R9j{NT zQD_3Dt!;fz#KgqjCrcbDjdQ~Jw`TQ}x-foze*OLZHn!PEP9%73HTdh4PC!CoOQOdr zP@wdDSrZqR>%UUw7#*dUheQZKQX_|xQK_9d_e8g8guAZdL8LaC6Ri#`Wr_m2ro)Sq zD=AOiBBxq$aO?`pPGQe@|ANL&n#`iVA`#;OOVv#rW+MGA*^gVQn{wNK-*j5vD!}uw zJYKp0bvB8=Sa;ISPS@lVyI$|>sk~yFDK262+kK7IROx9ftv3>JE9mQ)gJHmjQjRoA zuUBHcVwohrZhC?W*k#7)P{H29xOs`zia3p>%DB|pL$p|q*}No1%@B*~lV{eeiys}{ zFMtw${jV5x^j2fWJ7I;Z2DKs-I+eob+|d2&&l8J!$I2W==w5@#e6KWhPOCMW`-H*a zZmX9h+?UoH=s4k_z&ndr#(c+xHvzcVR1=$_#Aydmsn0;3hL<3{==7fXX}8EG>v8cA z$XM{1oaH=UyCz$?;_g*QT0)&`jhyDygjLLFxt9Z!9@m?rpaU?D3E8|9)Hsp^27~7B zlV>y^elr~k++AO05RftBg=Tbeq;*If7;Ec?0G&Ob{6z47TGHP>L_{$Xq)i1Vjn*yJ zb5KwOw&A>c_npb)Y$>Hfk^bl#IV?UKvwuJU5)u*+4H#^ZiKvKMB~^_HxNo-xGA_oG z0C0feqcMq)PfJ&E>-gxa=>-~M4n}Sg%uK86ne}qR&vtA@W)ppMg)~k9=RXPCyLEnA z#&qVJ!H#yq&NVj1jAFLY(J4YtM!0J%#5|Aa^nHyh~s0c)995D z962A~YJr+#cTA-xp*v5g47ZbIOx|v=H(&JW(m|^6Sl5O@YmE!5 z#j>1da2g{KBenTzPoT1sg3&d`5s|HH+G#ieeaU~eF0nAbQzCI2Z5m^cGbH(NC~7B< zb8>9AwaRuqhc2pb_WdLg?BU8B+p^gd>KKCL>duh=9nucR(YgI{8ZbD`QwP@soLK%V z$3;bqhH^jN?SkD?3fKd27`3_Wx5R_Ew2`6290}K4^E1d9GJaO*D7AO?l%?n)9n}O$;`hHlh#L4 z8dan527x=b{okuXbBsh#VoG%M^mA)4gN@Aba09>8*14>vZN}TG-8C2^0-OqKKXmQ&dm(nJS;zNVn z7h_|IfIVv^l4rjL`7Xs@wj4j-6p?B)-M_U&Nm)4!Fin51oPbe!_g6e&I zGCOj6RK=jgqKOhEC$yAwi`rYW#&d3$XT%LETjO+>4wf{?p~Uov65&hxSzq-s7QJwe zzi#Dw_n$V_OYzA-6D2x{k%N&b9ZuIrtr%%X8oiLh!?ye_uPxpuNit$&=V1=@LRNgf zy`~klKX%Fp_?F-%G2%rtd8A}Ivd-RDwzt}B1QGJy*YW9H2$tW#G!~-)N*#y z#Z!u5G3|MnlB!UGPO7X1;*{vh@qBa$-ZZ>)-6&JaGUrkfe`Whfl*pJNsM~l^?&KlS z6JM7!14s)>V%NPb9xh^DRJCh!PI~8~lqqY%&&>!sN=q zBP(GcBP>VBQsr>cCvs=YT=AXym@GNGcImfMpgXC~FnU~SS@Ol)MYF3A`kn^*Uqh5oPO4Du3z?79 z$|7e>VMn^)`xn^H5+SLQfDoB?Fk2l=m(`I zmzvTT2gUiU3@fhX?11!h^5Rq?G8nCZJvtMcRz|S#jgs{jq8r)p>uyg}h^9typHdE0 zXnlDrZ8+A2{*hB4lf4cQVWvTGSCv43jhr4Zf_-5`REkm|-fa*A_cSvGgO|=cyw;V_ ze%B;pl5iHh*U~#s{LLH&khqL&qWSM^PKkSs5JjJ(?f&>-@rU1zPJ->Gt+%xoD7MW4 zTt|djy7OuuQGhpM$DE~}_I;?(=07<(nQhq)u+=6Mr&{pzn1ld440)GK@6h6ySnp1G z9k^hb9_C{?$j%iN4fxiITp5(43mp)*wpT0lSR_SrngSMpWA-@z*{hqT6sW5h%{-^W z&F^}sq5BYq7;gX-V6d-yBJsUKY2puy#zDd~RKO;O=u{x62#=GQM!kPVIT4{w_-EIY zrqB8h1}$Pf7x|NN&}s}1^UB%Ta-l*R5F)iUqgbVS(d0saWE!M~VdbmhX zN7F@g3Kv|9i@ww1JPG;A4Jmx1z2TwXWG7a7vRt51?Ir_i6{HzC1OR6Y$E+jflhtRy zvCoB-WH}y=3bd1Q@m;LG#uk4+ z!eBYcc;*xQGUUZgf#ADw{vAx>-BDBH|I}o%w(zW1Mupu8VANH{#~h;K5K+pg75`|{ zeF1(rd@*we-FwIvAH6lU>-Mp|a35j-vN%VA&vnct;PBb_`Q=pW&#%sukF#FqO(!HD zDTIhusyoz;yjZKhjbM@Qm*cLh)eU!Ac@n&OJN^98+3=aYAiY=hCu?5a9NMn zx2Lv?Us-XmTaGf{gnd3g)tn?;AcWXs7cKtaDwgZ+IyX{VSQM=AIGi3K^$-}#duGwB zw{YGW!jKT^F(A=UO%Xbr5U zFr#B{#9TlJtRCjCb4I^;fmu~Pzu=)_z|MDR=!0$X<}Omi7c#^%shn}PIzm;Phl2k^ z$IOq8t+@N<5DCnhiE>Vjm+0sxGBS`F_u*0Ui|Lr%t`4GAXs9mrEvZC@(&GG=E4MbLCdKuI$?^c?55D+@n)-u=OrZ|A% zvlrVWXzx{-C<5h6F|qr~R$JHKGwV-Dk-*+R#1)fbe1kkZGCG~snT$U?9J%_u+#6Y0 z0p&hy9Hh__E}uJtfeIb(wY8${E#9{Ky%!Af_YB%@CR^h5jlZgP&?1g$RgCnCYXAD* zn*g|JlIGa#=VDS5mm|)0OAS_g0FehugxPg+nfe9?KYrQR-Ie&<*MD~hPce4~WpJJRC4+wQqLI@jP>Jaq;bKd`sR?8T5DyGtL?uuziU2jmz8_>@)1h>p zoyIq{rt=8MJ1?@jPUC+GFWv_QcW%5{;;`mQdf1DgF1iWJ)Hl70iJM7 zt6yxtxpMyPALAD9vAuhMX{vIQliDV^g2x7WzoV`HvQmK!ZT}q7wjT_-72;|JE)1moWA zJHUa=`U|%Q$8~k-N!)if=Sqj8C3bg7hy~>x1{#?)qV=GW`8B z#&@yy2nH@LG<|DpYsZN9>Rw5Z$L@u{{XGUZ7+|ioUXSZUXx_{!!CFbJdzZEEcazy2tDDj^3^7+SjM&+nvES^V!_J z@o-dBs%EmO{a|uDtuhg_gRXi@EphQO9?xWXtupo6q$GqBG@ieE^UxFt?IN=E&67W) ziGeOm;n4$Zs*oaDNBOX869fF>Ddg7ifws!U6$L2n#0y$p7DpHYMP4iY# zNs`4iBx_V=I**&ElY8XF69sO8QvMxeflVre_)iN}_aA+d6J*GM+V4M($IQ zy7ql&hhUe*-$lm~;oQsbzB#n=N@7ad+1VKwUQwzpvQdZwMCr{QWV8?H2`$>I<)n z-Sk0bp%Rv)5oW62=$WHi6e?9`Y;&ZG$t0 ze-Sg&v&OBn-P8-WQ6N#|NqdEdM^wvw*1;k*b&DF^PyIbcuzWv_0q{uU4}pyPVC*l; z8_LP#t4wUAp735KKWF?$F`s(7{X_swp|qj?_EWNYo=mkZuekl$Z{qgiVv~`yz(ySH z0RTDjy*w^Y6848#o&g?q!=DB4Lzk9xK~dAjd#$)JclTaf3Ysz;B%R)S6KADT7@MUMSFuTlx$XL9BUiPHw+B{23gC*ti+$NUk`}u5Vd`7(=83(>Hk- zT^9sjA2$ON*NK;3)kaa#zJJ`qMNa@YZwb*+gbN)NUX>y%dgaNNeYrXsI(KG>v4;9> zJ;trYbU`m;zvhAHL$CAs+lWuc&*eLHR#Q9A!o}lpo!~ww_h*C079e9Q7)94$%;Z$l zNE@P;!P}|dSV}~YYn0%!czOPD8!Ye6QDVT>Vzlqa6zfC$lokQU)0`jyuDd`O$g@!fv9 zY1-pM+&m>1X(2sEGj_)r054X!01QP*w;4N6g3s|le9&90z$)Lm6bjryx`WIi6HU2G zs@ip>UCKX<_FF@s!(+#L7r~i4h}85TqW6nv zvF`I4}ej^0Y-T}K0n{s)|SrqW<+FyIpH5-gN}2a z2SDwdNax9e?19{%hOySx)V#R=$>DLf{~BZ*b5Cz?xjH>DFA@i0P0%2zDc*R!W#ZUpZZXv0u?uS1e`}zDH8+R`@6sRzc%E=9l@v=mk z0;~b8yIEry0P7^jYJ-(N-q|-Pu;tOx)E){hcgi92ZztjrBbp)D*fplSwiAMMbQP@Q z#6O8(N-ov9>O34ZQi3nHJ;eE0Jvi@A0G#yY`le_#lMrimrvYs*YHKedP;EVBd<`fm zGpuS{pUbhq3ia2kx4Ckd`>_1_^f?s+d$-`KgWI-bX<5$tZLk5Gl=Hc6$LpCl9y^Uy zY+x*Fu`|F0Z$_%(B3|v>Za@_{LD8ZuAp5MXZS`tfjuFGg-?t0Ly?i6nLt3djH%xW- zOmZO4Sv7W^wBGnStrp_k&60ZDy(=Dro4g_72$GDv9|*jl;$rH-l7- zvSEMu1A-xtFz$Rq4RIx|3RG#d0sId!l$c^ zB#eJ%(-6t2A36%T8kqa(1xa=?RE7>N%JS)r{42mIOy`x50J4mT#6y5dEvJ=F=applb*xM0Y98 z;o?B|I%@JxcUnyc=3HLJI3^I|Um9mUS6>zIoq{PM78btLH;VcYx~yZ{$|NKuQdGXg z%EtsME2}?T2CtW_Z$0m}UP(`UKY6d{t=)E1lC;Rbr~5kJL0_-)S`E#2*oRcRR{zZK z`FlhR^Shw*9O|GTwfgxn3&@Y0q9uGn4;Y@ub5*@g-`dXSwvB>{la_0e%!f6A8dN0U zXzFH!e4;(z#T}=o&wSSI{o=Rd48S`xytHHOthZO4gf_&CA-*PLro!W*%UFynk6Anw z(Q_7*2my6;vj6yQ6)wV}=t=Tn@|$hL#r;=6J{9V!&?-0XB|&<|v!Np+Val#)!{piW? zBVGFKQhESr(NLN*`>Z_b zyD#}aTyN7~%);vwipp^0vJ6yQ%fXQoXg{%swQ8=ql7@u3BfHCI8q(VhQ8a@8Mq1}+ zy6Y@IMBOH*4FygXVZg^3NsCV#R|q>K&lib*N^v2?bP*;n(GdaH)s3UcqQDO#BH}?Q zpH_h-5Er`e9D5&sq(C6HiKC&Xm3_YZvO3V1TCtuzrjUn{l!`Bj!T#xQHegJdLP%xKzo%P{ zjPojC!L_@7^`vy#nk0`K*lo}Z>U6Ja93 z&6x4`<%U4&EHUTUKy4`f!tz&gv6x=RuNoEF81AjZdnT^&n>KPH6QCHBvjgEj`9yp! zPk%})hhR>$RG@hXiBOR5s{2PmNcY|oze&+!B;42S0^ql;Ih1cdTkcg%ZnYk>1U5uN~T_a@5? z1lT|P0`_5mdNf(C4D0ft|3c5FE<$nAdv9U~t>m+a_U%&HEC_p<@;K9bQc%Dd-z#tK z+XZXdqU`w>3QGNSK{VkB-}l|)EJ;le?@OvQLGYF-Z?_!YD3xGbGqvsH;OJty`)iAk z!EPhucj&thxDm5O>^sQNJymk3&F3Ha^@Mz8lHq?6B{o04Pf7m8HlivJ_ZbK*DTD5> z_Y_&P+8R0+_$Kk6OHe`4*ik@ATB>8lMq=ip%+E#nTsB8JpBBqQ$RM8socd#8_3`#_E zKJN~4@pS$z^ag4xMaRSd!&xrYir`qnkgpuoH642HPnM(uSP0}~nS`74(7h!%@UIbq zfpu!ERmnAc88uvLeLRF=GFT90^OxEN`U5xr<*`pt9TGXf`RV{WXa4ZsG4%ZA#(D3I z4Tv8>)cRwTT!&s`lp$Q!1jN9gBVgfTa0HISWD(6Upw9+llv*}X&DVQ%-DsT&4py&G zK(*<@yPv??{K1d`VDG{_PS;QWpowUvfZ~A`7Qu52b+{k-G>R&)k8Is}cchKApN?(* z-A+pD!xcUKh~Apr%FdIS+`9qoI8Y+fxSk3qR_!{dS&TKd~qjX35eq-dWTB;IZ!>(JXFrrF5tTe80{ z^gngfQ3lXaPOHJN_(5z}aU&6MPo%hjopdMB5FAn20wt zcbm%n@owUAi$7zMz;pO_8JRUwg$cuAn$Ss38lepXV@MM;f|&9U{-@d|{yoeSBA1t) z&HqmAGVg>b(z4jI&F#B6cwc4!r5lkAJFxS<78bI6o^Cr1-;8B3sdWX=_z7?J0qvT% zhK%mS4#7F3ZiEh|W0Y|S-%{(oO^Q+r%^+|N%}hV@*&I!&*qKqqX&ww!Dt4a;^8;db z24>IWnM3PhBBj|KR;MK);;Hh|dDIP9c=~Yyo(g@X5D@rws@a{BqAu^=vsrI{O;;7f zl2ixBBS!o3^1{Qz(>-T#e0As~Wi&<^Mgd%N#DcRF`zNOQxZs__FienYzSDNoKoVjC zgEpW&Be;WH5aV_9XRfsK<)L(m0IC8wAY_5o5|Eyg4UlzzSL$`PwP~NAyjlFKguu46 zi%on&6d;jsIjyN-t#5=)0K`q$lPm|9%mo=i<2+5GKxf!k;2!BYx z^9a)z@&U|yn80e0p?SpKYJ>ziZZiCkdYCp%X*fyIL=_vyx@0{6ni*-x%48t1DX4g1$$B@-pJ1I^t zL|5TY@F&Ic03W~7%%;c~yd3ckYKek-57W&z$}xB?O0R;wu6c6ZoVJ5B7;?DZ(!I=~z_ zyaMeYE7)CyWg$&PeEQy@nDQQN;85kgLom+piy1#wDh9F9a=!3~3knKk2{O}zfLas` zc5-%!H0r{-X0>elA^aAK1$2>M5UAjg!&IM8U&M9Aeo#s1S)A%WK=pdAx1b0~E*`OR zd*3t;OP9+XnMIAGkFi)=E1jtn5dfPcF(HA}0OX5Vm&V49W!$w;ibszUz6!cA!Y(fwFlgcai6b$4t-smipjt9@n0i+W~v9b3n zEeEgQ!!IW*g z-T|=oPyW4^yrW4CItcgY>HTT%yPn0ydNLcYu)GGonMoP99edDN`ja>tGVyZlddeCu zb(>oMa=_r~Y&;s1qA~Gm(DKqJ5XW5dQetg z6m*$K{b~liz-3enkU;9|>)YE`Z%e%C%6=!rMR~!3=g6r>^dQBwBCTuAN*al9DJx}{ z4?v%lz`aG|(JI&#?I(>D^q#TO_JB8depOE}7P|S|9Xh-LljPaauplj!X<5wUPP)?oDjJ8#Lt5xL7cW z$=$T!Gu))Srzd!xQRHblWtphRP^3Qe${>T!V@ zl5^w<7-ZfC@r?ytD^_WA(x%T8y_DTZ#gkYoM(qKla^PPY;HupCdi}j%-s)h#sjy;xX z{{`i{MrQg8z9jk+5@;ZMG~G{GQ78KVz8>^R?BJtmRmf~8TC(P>w5K;6X7EfCtX~Ee zvWzKD020e^Ol8leoBxIk4Jbrvk>~EPXfLQT)RHhrO>1%c^VJyipOQ zLqJ+UKG7grMo*6X(gq*q`SMNySuwPZO9U~NvcVif;n(jGbKQMUIPv`9%Z;)YPG80)fkx-5;dOCy< zmetyyvc`Llj0A>6U&X>krPbP;Ly6BVjnW z2yX*GU7Z~-a6Mh=XlZOz2@HDbc6LnBm8LEBq92u67d0OSgtO1gJ)Bi^UW>MdcCdLu z?H{Ds5^G(~H`FV{(C{1GYNYM#pg#~#sKV)YXjH8jc<#SCF4SnMitRAZaV-Ow4A-q8 zo`uxBW##1LuD$)FM?%NaQt1H~qGEL5CHZZqv_Ie#x)#t$8QR|4#gJ$2>iWQD9Bzh} z<;k+6n6&q}xt~rJniHaxcnqc7=czpKc-%G5T4=a$p~gOR6;y>!647dAXE&;9sjGjgj?Y!568C*L6a%K{D^k4^l0)o?zXZS9H&6F*ik{L9M(CkeTqn*8x?m zy-@^&+;M~lc(j^M4lC^d;R%Ip#OGipf17dXdI$)#BsG%QwZ2Q`<*gYR>P7Y8oc5H? zLCIBY0ezdi*K19i0|W$28|uc!lU0ig&{l*39oL`ba%0fXT70{?skR%TaXB(3CLKR; z>;^#dVcIuuW4ye-aiSXus@AiHd_75IJiHGx<;J=9`WzRd z*>ZL(Aup9k3+eVJL$n3ehnskv`x_Q2Q_MNz=v9*zuErDy7qubmISEXS?#IF>wFi?r zmyJiQ03EX1*q+loQCHOdsQp;~0xMjFL?A)wcnG~a&4b>stR{T8DB`ggv1RGN#C&jG zLt}(?95yxGPJL$94AD1?nEY1Ci1J`udX#%#XOuYBn$s}w*g{!pUdLuEkXynX&q`*y zRn>{^8=z1^Hu_e#xFSp_e7dS=^8pJ&4~euD`67$zyq@$!kA?AoMUd5YYrpDrg3q(V zoop%~|698dhcyT7#{=`rX9tV=IS1l=rbU)WulcawI9mgygt$UO9a?pS4P`THWq8P3 zM$Ik`%lGJywc%)3s~6i$+qrKb<$Ti#x+SXl!O^(^Ls=>avha`r0nUF14*XvO5C89d z`=msb+QbrE!Pe86zY(ebgj)R#P(A`x|3}|uq>t|hXy^((dgaSUL`+XwT+S8am%ftg z)AC1%?B9S_-AUOjwTGLU8Wvgq-oyLlzb?PkgQSMfeFYA>5(wX7{QeNu`4JCPW(Fb{ zU(EJSlikpF4j+tqqkxU5TOU^m3C2-SR_l%;9*xA3%$wA9O)*xeMU0&`m@aKg7ab)R zYx6-E{FpGM*BuTQ&!#g|q$A{VV;&afu2C*_Fe2R0)c4`>gj8a!^sdhCZf9FM*4FbX z1su#SXP}=V>>7{+%y1a@%~^?v*l6pr{b>aa!oQd7WF;3y{R%Y>r|;SYDCGk_mza$R z=(gx4D|$He?7}GpIToZ~%HiZo@^QRdTws>un052`0nf| zh4X4pRWtN0CesN1-lb8MrJz5O*Cp247<`E#vgm#(9fT$P99At~c|@K#2=?YGA)Yya znmzS%XVyd!-8-sPEp|A7rGRO@<1j!>>`G$nSYX`rL52e4Gt6_2omnvSOi(*(!Lunr zL#^yTP;O(2LQP}2tl<6fvcG-U+H4{2Bbctp>ajaP=6<_yvXj^J6K`^x_aXJNgSEHs z&Sq;UCN$J_!DZL`>(fc-&F*XnkHqgbD0CZIeTanLWs%1XJXFrjH+HQbg$`$%$)oYs zK=7fbW+y(U+5Hh(F9mdsuWN`d8vDsLHD`^g;m^0m&Ge3L&L1~^)-*VbwMAZq)(^4$ zg~Wv)k`w5Ao14SD-PMoFs-HSuC9MC*pnxs8)kD#)9%}S}UV7ZeN^O2jjMJFEY;CV0 znsnfv>v-YNRycV+_w)eNiXf3%KSDy{*esXKs|vOjljpHH_eN#tuwH$UiDk6!3>HDa zj#5AOcC353T3QtmYxj*tgigy&y(SzC0ow=_m&0m*2FV*P?^F~Q7VNz2zPbPOH)VNmN_OmJ-pHD;xtP#>frt|f94r*|GRv?G}SHSsyvUR<<>gDCf7M|&= z8T84zVvP9#T$r&~m74HgsBC)g8U^;BNYsD33BCW?v`@AWY2SDwfYQyAV-yIX7x;PY zcb9NVFk%0DR%?iDwsU%gnCmYz+np5Wi3~p+Bn04Vub3HAM2IoT_f84_31Sm|l!5Vj zM9|=Hw;?H@%Jmm7qwR&23p|ADDSO)+D?RWBgkA7b4B_)*GstUzbH_e4L9X45?*}Lz z$a{;ny5FHQG3yR(v!N*KBV)u7eA3JhZ`ba&uoOt_RtRM}^ZSD+iOFThBTe{%m>zLf z0v%;XD(P!NDqj6gq+ri@(;XCQYh&{*4-*Tkr`iCbu@d=~a4Z(oKvM0I^Hh+#wI5E7 zj{|~(MJge}>>A=LE$mbPVKjBN*huWB7zYeUba@5z)P5gZ;60vkzUtd4a0&i;=fb@Ew zKQl2gbznz8@qd+B4fL>d;pB!9GW}<~&NjmMLgRmk*HQKK!rPSnqZYrWfGW_O#J4(t zjEad_0eZ&65{Rdgf)6npKHcj3QORu0zH#4WUyuqo?CA1d9U$9xW{0^^9;dur5OKpsk)}Q$k@#V3B1OBwo z-NB^GGl@7P*Ia}~N2|1HSPn-8yaN&#zo>sgLQnC$XB zCH>pE=|O#?z8`#3uW>o4dz^9u4=%_*B4{K45Xc$2zjTm^K}c@?Ed=XN*q>*y3Zd}? z@>Jopf-^X4=b$^esFPPDI`tHxNQ?Mox=BxO&_L?#T|U2g*E8cFDc5R->ynNK`>^U` zYNbzuoBRVu_=bZ1wH5A{An(N1?u~6YUiTU!yH`0Cc20^zmve`{61VTO~}A+Qk7Q?Jm5wO=}zNHS{I4N6AgWJFFb0zed^^RkfB z6e`Df+T~dlWJ$?M<}<%QxQ2-NA)af)>^|b7Rs8rj={-;$hn;-Gt@}pFOQ6t@bou#Z zJ>5Wj?k@LP=hxNI?Pu|AT0g1~9m%o9@$B?kDkbe&D>*t+xM|RAeB(04nz){hQysmY z#GQlZC+h~~xE+il&-X~y?xn4L_kU=7zAh$$m`a7%w*-O-M-a_kRKE znazT~y0akIh06bZ|Xe zLlh*&Ec8LZPU3X@2x_GeKtQAa1#s5(_I7}?<~9&R2-of1#Z+WL#cueGQ_Az){Cq`M z3==>$OMeLuFYk&0X$IiwkBy#4Dig~mkk?q?Lbgy`{}fE$U6z@RFQmmi0Tik!Ciw9M zR7l6L-%RP|%t!!`vpkhGlznC6+i1NCr~CBzpCnHU%R5BIWHjDl2GOoEgJ4tkC>L2lZaeFG3d9PS9KKjjqApU^I?RiRA3lT*Rq?Bd z4+EmnG?3U+4BjOEhG1qY>`A~`ZDcp7ak#^3a_7Ziid{;bl7 z*Y{1|iSo(5b0?*}We3awePleWEM#{!&)E*Z&+6uH`qpzVjTAH8|%*N=rmXz(^15Zs14b+M56jg$5t_!34s@U6R7}vRq zlfRCx@u9(ZrCwLPq~3Ews&LD)!^XA!HH)HH=aEG-x#2h`qwNlT+RocM9n*4(%AfGd zR+g=5n-Bd@^YQjd9*Oa%o1NU*D2@v}%2HL20sV!?#-{1yd+i2>1)au-1;eQ^pb%3n zYDZQLNCq~(qBXX-ju&N)B5YW1dNIXynFnEKt7DRSD2RyX!$$yC11yGAnN-0N->$XL; z3xIYpw)){UVS(l^7lrq!Cb0XiC zf6(4YBrA949^z#d^>{%PL4jlxSGoPF8{a*th~p{NYjoOsH8Ve=uk#DQta<5%kyeO= zb4wHEC-y^?z`SQ{;{zu)W(M?PNNjM^L$)9iF2sJE5PCzrne`Xjd zLgnGZX~67bdz>j1|BJ8ng%tEuRnzD<5sRuj&j)$^fa`?jT z`19l*k?VSoTI%iLVdHvN^KQm(Y?CwIs83K%t#0E5p3V>e$jFw`08CF7_gu_^-vI7j zMp%i>O&PB{^nEwZTGgDZx${p)S5$!%TDIB6kyMy{fQdVZ_MgSbhB|v3__<^aJ~??rUDREkt7G9K9QE&O2EV&Vg#lY>)4>vb~Nwc zO?`#C(YcWfv4&(yKvMqG!+Pt5QfmApTgYM*n~1M zOBep;z{N^2MSpw)4ln_|O{MM2`?II#P0Jd7lMS;NFb`aI=En-ql z8neZlPrR4(YlvEnE zFgZ{ip`oK8#<17J4biR+L!t|`RfcD`+mij8lHn~lFcc9%Aya8Qx^cAJ2AZq~oKzwj z>-X8SK@0MAPgJfc@moRW#sc@5-wMBXS2zBaOSb!TTdQ%f<8skX2g6Sc^bRE#D?ZJV zRSvYnNKYN50rprXll6dv1N8RNbGM)hpAN1NEN$$~`EFjrOA&)Z{IO{a-q8TiVjR44 zFfMraI$Gm+vTK%Hwdm_XEW5-n3yx^R3+!nvB){@8xoQp5xYemGB!HtRy(3zHRcARLO%7??jV&nZsB$kKZ;v&kbs9R{w+COTwSyRNiUZ)2tn+}^g9 z%{28U0siA^Tc+|CY6EKBSF-L}pa@hfS$I6<3`XF`x+h>N8b;^rwi)_JT`v0b zC|VZ6OZeQlEzFEyl2i{g`p@c5gVc zMnYN_4&m%(bkfT_RNJ6{1UP2{@S7=S;x#BHy*=e1>AkVKuLjDP#Eq4Jg3(|!IUax_ zM0-c6@uh@i`}6E2ZUSRA%cTWdnCRPT&txTOrzB=@rFGSt`Jt563AHFD2Zlq`|p2?A4BS7KIOFldzg2AKitGIJ+{BihS?@Z*Y zDYV)8_Oelx-Re&Z=?h=yt=>LvsFPJd#>pzW?l!wf0$Ax83$NcqFuGgsn8#1;`?L0h zR7U{BcIEU(IT81;B8`2AlLQ?=@7CA4Bg|*Y+1*~t@I)^g=mWa6f?s3$=v%nA7fsFp zQTJ{&$>KhJczo6X#`sM0v7H|lybmpwdME*<*f_j)nAQ+UO3F8qH)(v4($Ahv(@5$U zym^yGlAY{@knJ@6E6s{us1Q5zP0&)Sym2Z`CZ73>M;2l*gZL=*Lwhs&e(h=}gB zSKIZ@g9*-?7b=x;O_UltL|jlBDqevc47mer3Pdy}2wbj0R`87A5NbR&6@uC}b~-2b znc&Dz^)nTw5qS@&^M)^J+0DG(-TTSOnVmwqUvb=TYHw2lkkl(H>TNTz1nV5jLs7wD zW@-Q_)X7OgB5>yEaFoqv{+c*p4Vo&I+1B2rr&z6=fa;gmL85ly2ZoV1ojF4;()S)k zEd(>Rg&9>p-P7`Qi(k(?Z%1q{K?h(b;Wvj!7Q^$d)1ZOGo9^D;+hJ=-sl^JjGbo+s z-RZZ~eFL*AaYv|uzwc!wvf=)H5 zFs(G&!&HIf$wp<|K-mSuB31X+p#Amn3 z07~^HA+7yrOkVJF9|x)eo8~T#&ZvhYonmJDcJAT?~m;XnT3tH zoaBt#fE$&f>q$80Or88@MxBj(Gua9grQ>S5?GeWXXVLwVY9>A3x{?i#h+SU-e!{-EpbizR@yD@f708z54m8?yG6Z$hoc4Jf8`onMPr7xt^IfTQ-@djb zOYK_2gk`*f&IHVI@0exsH9>LxYSI$Q`w#bmE4G)cb?FLotIX`^4?Ex%w{?3^X8G1;=+RZ6z1-@LbMQyt$csC(661N5Gc?6xv{bydDQXZteFo|- zF}L?bbNGEFTF7S(MV-n`laI=^NNvA=grfxtv zo_L~(M&G_#4u^*`V67&CL#FWeO&qD>BVjJ1UZ%tK(IaJn>fyev)c^}?>EjlbiGFj+ zuPSgz6F7#a#U=wLW`50?uBEb2QOwEd?;C0P!KewmN@Ayc^@`k9 z-uPK!1IT)rZery7jT9-I0emkmGbaCI?~#}8gy2Dfq)9vd0Hh`IZyZQz4pRL)Z(G4=cao|kjVM2&sOF~ zG}543`^*;|uY7&d4J~=}oh>b82tunl+qVAr|DG5m z!W=Dl$oHt~!cgD{I!D_}F3Uyi$Ow3}otybDFnuY@ktvsh7CX}An(4V=3UBkYGw|tu zRE8x>P)%gio{1b*^xd;lu^|%zn=c2X30Mt-Gh-dAnN1~XYjlp@7(jwcJ)k!dgiL#y zpfyWlD~(PebG+&VUOne{1#17h=%K_#7PM8Tw;zWDYfxJ<)rhX`$;kBM*=_dy6g7KY z8A*{Q)yAivO(_k$!ur|vD2+y?)W_dfH9vzQZA&FK!}CZuPezaYzPmZ?LlQMOuM@tU z?3qbx{kDF4x@I2bVXJ@PwRPZ4&T2G05%=|d#p{`dbf51rFdv2n5;@!2+7tj5N9bRv z%5JD%eWR?+&zYO}u!5EdUlciUBnDmmHKwB)YFYg=)RwHld=DeauSL%YtTLoiLQG87 z^~H?7^FVI?c-7a6)(p-^g_#8EGvD&`+zuswNyaC%B6>RgwX-0`( zGs^hjTi!7+iZPMk(~5!*z^(+xz^L}xythP%DU-(%CRP&a^NP>YX}Ujbil&|Z@#6=V z>qWjfXUXqhjx{l5HrdV1&H4G%!!KUG6qjVOZF6|{Ee3|o@o1?f+2bY$5F=eL_Hwpd zk$|U4d(~o(myvZxOK|Ldmn)`1I*DBL&^L#&!E5iBcflFCzkb; zY(1?Bk)`qq3gd*|Zb^Zw%*@Kta2BdGN0w;!-6q1v`dR0K$XM4>dzI>))xc696H$|# zn6!`;AV-F{k^jqPtt$+$c5}Jm*+l!iZcl3mTAyRqCMLW`kr_nS3J{&fb8B*kMlel? zIliv2T9x0(-1(IRCT;m^49;Sxa|kJqCG z$=lBxm7cb*b`v!kySR#)I&>vOBIPOy0$@B@Lj zpG|B+%vhf1mn#W|8-<>Y3jG?KXXp%VlSR2>@7b^p#Lz5rw5jYS{6q^L-fZMku8m~k z^&;i-TEl|dYmQ$nRe+ROh_jQEb2H^_Kpm45Cuv-z2XJLM4R5zg<=T2@JL#JhU)d@T zA?x{ahK7)e@PAtkS|Pvm@9XUjpOh7+)w*K2FVQgd9sBvPc16_bDdu*tVBlyMs8KDh zp0vBaiYJ@y;INVDtl?3xqNA1h^=Z!=gX+lAZ*XrNqGpm#Cy}x{?U5P#SfkqQ)qoST zwjREyC~~W`nc0OqkB^cb!J!@;$JRW(ILEuDYr6f|8#S$L z0v-WDl<5l$F?Cn+={8;M$kW)#VEa=`i)oQ(KN>%8;5EuU`_T}uTt)Ml%tGy5`j^18 z&|Ff3l#|k$u}Wf;MA3k$kj?XodP2g8i9PIx#5=wQm3ye)vH`>VZPg*?T#vha&+Lo8 zcY`XYp;FT|f&6F9X!QW`ZF!9~R0UVIgxhNzH1-2en~^ExuOQ4qiZ!mED>JFUT}So? zMmmlX9*2Oy{mN=PG9DC#9z{jJBp3R}z})qpB#cWQ5+;n1lJIWk+NJ4fZoUDX$xR1D zb$VGZFhMM^%9dz^aoau>%#u5fm~=aBY%E?FT{ZY^AA2F0O>gNJTc5`}TiM^ts;}gq z{n+S_5BjRK;gw2i@F7@JAA`2DHDUa&U~{cEZN+B=&OQeEgf%820mM zX5(p^zEqNAlv_wA5i`$-c-#m~E(z;sC!BB594F&PYop&b<#We50(uU}JLiY+Sr-H9i!ogFaUOCmu3?Q<;6WiLQ6OZ1VQBj* zl*Hh2W~AqPTk=12u+{h{Ws_OGcwLFzw^bGOoXX56rA0BcVy9;(QI&Tdoj06^uA0ob zlkgFXv?PAR`ga_G0?N-A+DfWBGhCTC4Lk6Ey*HiUH`ijSa$j7=!wRmHrPV&U7=r=3 zucsC%%?x@c$1s00xZ@ba#gJL1O40(nrSql*zSCdn$-lVRk=aT-Sj16`rP?Ot{BD>w zBfRSzMbeY?5KmV3BK?a&wHoWc+$rN@GHOfRU*DFgrZC<4M zTbLTuVi;OcTA5w^>H40_IX-hyGxk67QiD$tG`@w1P1fy*(Q?D3@Zf0Q5;+}x{rs{r zGP1c*&B2=XSe+Nte{)deeCQzMz|^KHSPr}Ce4o=){ASS#k9bqUWp;{!8pXR~i1m$u zQDT24w|<{m4izym|30x%^g4T9sq*6U3HbPuWs2dLA#SOi^I<=CrJ|-=e_5?AsAHOKgxSb;UGfWQwe*nr1Gq_GB_&tZcs$8canf$-rj{@UaAhQcsE%!FU^vUH$PUVV@0H@Ios{WREZMvx)sDnD^J zCgW|3x}3RCP!OQ(DzuW3le7sRlg^iihcBN=-8KAsb6J~kED^D*afh=jcxzj@0TFi&lV3uhj(9%pwj56KK`Zsmwr6H9&5#wIXfVFiHrRZ+?f%qEb|ON#UR1+oZ8cYEX^7y9o^Rlcg76 zTPi9ay-|c%z0>nGW#U?H!G8r21>bmTU=Q;F*rkGUvuQ@qWkpWD0otieLSVh{Y)WEu zoh&&i<`f6kbCZNcL;^*5d3h_~o-}jUNcGXXT5^gmDt_ct8thSDwLDX>oUQB!`mRNj zocgj5N`it;M5;sc&Fc6bk=>EyA_&dzI67+G;6W`oxQ{7PFt0|(V|G|u~a&YnOL z1Z^4G_V5*j-*XzS_vIRjjF(C8%KW-rU0YvgH?xCKau&2BQf;PC_6)F7Q7Cdp&=rIx zslR?(0}C0?!Dli{^3HuXyOIB@$i*OzR+atr6ChzNOJnek5l%@iSlduPH@}7)VkJBf zjDs8pzS>z(R_ams5~3L#q37$vo^7pVLPnk$T?bbduXerA%}rwH>0+{w!f9y1rFRyd zxSMa5WGWwu@0%FK1(RKlPso&?;2k$a!~BlgMz!^i&tUl>udcCFl}FlUumzOR)4Ha< zzx{v>b^;l%WC_C=Z(@}_csB!-hzc_3{G=0+bM0_?<+KD}eqjR!6 zrcQ6Z^E}@DyZGhS%ddwcVjcJwerFf+WxQ%4;C^RG+VNvL{^O1EG4{`d{4;&mLac2B zVI#CdX}8MVjY)Dk@!C6q=$RGk|H!0H#6UT(oOM$1AQz_XDoeqlndB3*<$|Ug2h7v# zKIW1MR=O-ZCHd7YSM>^@Pgoc<&_+sk8@QE&BQLt}r?*puYr+zZ)ROc(=q#;sC`Sv9 zi%uAs&XUO3^0UewzO4+)FzS1Mr@oqS+7V>DKfhfxymRV?QA@EZldRIaD(t5$c5|gjt56rNe1a>M0Pxn_aDsE zpry+T2QHsNonCGGOa&NGJ8dM1n_l>_8R_;Hvp5Zs+^QhGvv2hr&sAb=!uE2ta!S&5 zQg~A)%6bN$xh)w5qu{`5jM0z}a$q^iOeZb3fOz6u;jX7uxq&VpQxH}=2J z6rUj;e*noHg7>d1Yi3MJI|-edl?1(J$Xras#_xL$fk@Q|ht~{Rdl_%G^Qv6^;7O4= zmSIvDtuC&A!1t@M2ZK6c!nNbd9Ton3!0?K{O;x$gXTDWMPB`s@gh)~&TV#pzAbbKx zpY+)>RFs}val~ro$VusGCPO9SLXcqvi9&55IUrL+!Y#^-0S6ar=ZL z`pzCfpr?x_Ov!$El{nI_u94Wb0TvWazim4(jik<^Rz^*i-`-WK_KnZkzmXgDk^Y=5PgxA=4LwkQ!P?St>S97t@~A$&=EKWo`V4 zOWs-g?m|fr2deYw1D8bM(3G?5wP{<%NX{!;q~5<2zOsUSfP@w6cZX$+5<%ooT_4r7 zl{fZszHKdUYu$We0M};yBw4SDbAm>drNk2WMFW{|u;9;|Q#HvA#1O$r-DRn$JOdZ) z1WdS2?nsVBnSnKu%a;3&lr!wu=axe(t<-H9*3}}|NWWkeA4^2OXmn?vnW5V}_d^ z${H&~zs9g{3Up&uRaI$Qs$`NQm3lnZ-yp$DNeqHV$H#K6FOU@{5-@FLA^1J!pGC-Y zKNt$@!88xgu^IsPk;DCL)A~^93#7b_?DKQUB^W+TS{%Tn&IJW8NWO5Nl_!t}2eKn+ zXz1wSQBl7ytRU6&dcN_+R>4{SQsM8nKgotvKn1FPQ!nB8s_4st&|oL4uKiVpp;_ zU^17MjQrCvA)8j?F)&70Iz~%>G^q`ad~ntOG|5zRV+Y}&H+IIZ96s~HsQ%JtWnXx% zH1;z+%==#SgI<-zohM9TM+rk4DUbHCdsJUsrh-cqVVME@wPWd7mK7`^E#t@8>YfMK zRH1zs2>J;k#H+#|bg-D#@b$gWs;0LGa*U$OxF-F{$vnp4GwG0}O3gP0TkN-v^KlPQ z%br3l9mLnDnCK%`+asidJb37+N2|%63zzq|b;)igB_X_xF%hJen!F4p#no4>SH~nP zBF~@SJGQ^T6h&?}ujcDR#jU^D*)I83JV}H)m^)P3Q4}(nQV7Y;;nalij6! zCfzoCSfgq~D)D9^gm>X`!8MvfI+xqC(dq7Du7;OF>V?ZXCYt2Tc%F*+0+;dXV&~6M zXk^;{HPlfF4!POATBHvZrfsxsH6qz_Ad$mg^yojV~`R8Oz0rc9~DW5j;^ihi&h;u;bD%7jL)(%BZ--zRFc`)^+5

$3l!!=M${QsS*mnagdVdB+vkooiJ~Ve`-PAj)WJ%#vxz`Pzd#`5B&3*FptPtIN zOH#)HSnK^N+S~K_u}&_7aV)pV9_k(y-KIrQMgu8+xv)6}Ma?-{#?tDHjP6o>lC4~N zy-Sk&d*O1d2ZW4(mMx_`_@E%X$y_q1&e7#D8uw;dsStIDYUx^>HXW{v=f!k)Z}g_! zc3NH1sd&Wq6Fa@2P}B-f@|0GvdWy#vgiW72m-^!$66kfo5}u=D2q#=Qk7b9#BHUCO z9g7rco1hGdw+~Bj8Qh=iPtbqr+H5Gxk_zK&;No`VzRoysiQ1@_tECH@4`fz}Lw^-A z85r2USSfa!p>le5BMfvvXN#8`dGArTi(U|?mDMIE#@e6tSt;~Z^K2X@Ar8wi!DjlARUl|L_Z^>p^tQOV>$Fs-IGc$LUIUIP^g$<|Dcd4wB}tIEM5TV0NlMm~_As z(a{;h7W{JHx;*sc1y3ir6!|F>{4l=MvV!_P*s<63EStsCBX4NPGRb8p3X>{082|nL zTI?XNXSHz9wCe@+)`Ya#wesP@%Iw@z>G&Qh>)8gVgINUmD2JWwF-67n1Vs{R$O=`# z6&3n1UmRI9_PoUCx}as<{ze>&y{B}wq$P6#pUhxy9f!We^7-g$m7m|{?s@ubrP98r z4YtU8MpiJ%o zDC-a4qp2f0l6?E_^h%DO%fa<>o&|;HU1NX1{(59}lfFUYJ@k?mm+9>Y2}2mISlQZ1 zn#Q&g8a-E$Ot2)z0eag@yZ0kvoN8kYbq{kjHbyXB@N(>fs3AIu?4yQl&%tbsd9t&q zJVP7~9YmkVmKWx#)T}A>O-{b@pa@PfaD2VAOGVhxqUZ)Q39UeP?Dc~AIj3h|&-K@u z-g{VhuKxT}Vd6ell)U^0i+m`4EO$Kv?Wq-~$)6v5yiM^~G`U(8JGPDs?+a2e{n(Eq zYv$uvs(gJCySqZ0K0L7New&ha>qv6CoYzIbzUMOeHBIpQ2N6-}Cw?P7uPJTqfZMB1 zB17y~)h$v2WlNuoqvni;_m`_bm@Udb{>1q&O*#q0I=bV6O3t1zN$2 zr}C?M)93K+_4RA8)i$d_`nAgSn$Hj+7gk?)fhWV|@00a&U3?f&svdgqS;1i%BYYy; zQ^JtmE_|QLd5sFlk zUh)5b@qcxC7Qo|0OhSO_EW}Gg*989Y|5hz~BuSDV=N6e@D@4vJXEVw=$rI40C`l);{v@rsMFA(nz{n45-vK-axDzmFqbu{Z&zQWzi+XPMhKHn|M`eNwn;>3lHsjsV& zUTFcnnkrcd4?i*)=h@WScs z;fk>;Uvu|xI(Te`kjxNOkw5;@Z{Z-G?a3nGNzz2!R&`vjil?v*hZMk8L5T22E4lOBTl^Q^w!axjtewiO{wOI7i$NH~LY>6H;fy(=E;t3<8I zg7{+F&4-m0+~=?XQsiG+zV#+xer5f~m?kPrweXljXD-L`qP1j?6hWtbd%Lo(E@+ko z))Ez}a&meY=pR~{qtH-W6dgUS6>#t0%$Gv|_(BIaFX7vuT`tVVdN<)+94mTyfT0l` zJx1qCvHrSsfZsc}Ki<){KQ3*5dpYc4B`6R|1GymX2UBt7=MWb5Gn$5z+aceGO|3Ft zqs^D9@!`Iy&5sQMneeEa;@YKQ3%i>yVp987zwh;Mqkc!=w=|NnI&>&a6df;zO-2_? zd!f*vr!O+gTu9#;X%FMp4P_4LAor!Di%Z|mc*#$^#rr>aeyb~l*GFv#Dn$pLH^!Ow zgb>%iu6yo{mS4keH^n;P`{_{kqoX$Y&#UPnJ&C*_xJnbqAb4P?qjKi;O*Xw5=?K7( zW^+wfq1!fIRj**AkcrZPR_ipC`oer5G6v0;5QtCMU(4%#zOFy`<;&dhA3U7rS+A%s zXE)}FJn`phD@a+Nf z|Fym(;sF^(@Nw6qlrm`~vf6ZqANrxNQNJ=(6lbM;D^yP=Q$*BYzk4i~PGUONHMz^n z;i8!Pj_gJnVfD9m(?qLTthzJ3i0iHUT(vrorhd(DYpg@fxZ|iti?}!}FuFvc?8tInD?7_84X>&80pz0!WwNvp|iJ<_A?p ze^gFnWCdHmbZwPVeZyf*5-H3K|Km2NorDOt0xfu*jWN$JK>HFd1VE_e{TB;gZVh|UOfY5_UbhXw69Dn!}FIr zRub`;>1T^>4OukG^iA|PAJk9Y9`;*_M`{vJ79SKW6aK0_z%R!5*QJBVzW(=L7QCaS zrIm9<4Bpt@e(xa#@(sQYCIe90H+u5#9t3ygVqFxH9lVMN*?jZ3AFK$&Hp2E&8UK0# zNuht7VF(1C^zpO*V=ooKfQ^@pf!d9&A25$8kP$?_x-JGtGfhBST~-zaoO3lBcuQZt zSPmqM5QqdxKV;01b@Wpd0tA%4z(+yg+Ym2FFf8V;nF_$dCW6fr*OmiDyR-v5OF_!f z3ve-b88}|bVnM&Vm?6#k*3F{&d~q<@B8{(Ce+rVFq#tddWQLIHab;vZBZgSn;~&Yr z1j{%;>Vv~x+l5s2<6G!K(FY;aCy@PBFBEY6U_EBXOe(s*Uy?3$a;PIUV)*cgi1C3#KSOrDwy}}R z`4&=)1Lu~a35K{&Y4>q%xZHC93Wy;EfPpYws&8XcI`bJO#a>%m`{8D?>HakN;q?W0 zU|0?dA@UWUFc|2B{9QtIdMx*5p#>_3&6?Qd!93{Ib=v5|!SsXSy9NDL$b?*~fP&W> zP1no)@zxIc$_pySH@5~?yinc+ zGe5nGkN3gpO{gDHagz(3m5ios*sq-Z^8;tqALYr?N1<q$I-(OW zaHRcwnZI)?DtBzoBo@IBaCiu85=mU2FUg)vT30lN2c~zLSIuwin;)`aAzv}l?t9sW z8l<3G&#BM8oEM1iup^8rW>}w0#(2IsZKx=)d7my?ajMfeSRE4{`AAzbI5Veo7~!Pl z0a(&Y!I_0=XbDV&N}PM|8e!P|SAMz%*P-57!;977n^sfsRO0dnzm)_|+37Agahju} zqtIDk-yQ%}qSBxrcX!cZ7RK{$z#J3jcP5*96I(p*BsJc*Cva{bz!sW|wH*k+UfbOG zqVMm zw`}Wn7*Bz!q13X)klMUDqvRXi5GVBp<*7YsijHCJGfq*3q$gh@=*7mrfu3jsL5#axoHE-p~(s z?6$+^JJUKJ-IB)|505U~eFL&YFD*S&O^-$_3!Pk?gG5a)KGm*I5*3IoG!?ARm)H!p z-?pyuvTIkUBSkna0%nv}Fzo=vp#Am>F4-5?xuYK_cCCiOTF~I`>J#!e%xfj~{|sLO z5$VPG-JEEbiK5wRrCsC(`$-ksb$uPQ4@@cJN@B!x^U5>x zbh6p5R&R@}_4|dZLy+&HY$-UbrqLR#Hyu#@zb8XOY5brQDW_rver?<`d~!pk(lDW+ zi1`@WMRZlbdz^GF7r~u;O+5(;rwU5OSr5LiC!C1|sZmi9-18cj1$RN}gr;=&TWT#O z@uAI)3M(h2I9LvKZ&?m1E}x6MHk#ia66CsU4GQ}RtzkCl@i39R;|-SPxGx(zvYYNM zg8aMFUv7J~!*untmIp6>SRC_}Mq^JXQj6M?JRJWT*mUAsiT1}%T& zWk!Br6U797%v>!Sq9APpf2?dn)BcS{B_kAvb}96Xd*&DTomC?yc_175&t`tZhM3x0 zUN+W^n32M9XiCA7-5xBCcOb_g_>6mlR|FCMc?E=a-V0CZt_em8Gwt86PzP6mdgxXR z7e=UaK%&7fnBT{tacNYSYIkd)dAZJeg>`~VODMlkoY6?CT9X z@RS7j28>)790HaPh@YE3m?Os8&N43pPQE=^VWFX^nNV4I(g^%m z3bpb8AC1b$BszuNvP=0V&vw8{u4oPnZeXISCsF+C0t7G)+y1ls~fszBE@}CKg0Ha%5 zThGqUqGRG});bgn2@t(m$q4^JU0`j@wF{;d?(RNm%UK3DyVkIxb&hNigt7AxPf<3D zdh3DlWp@p;FT*cJH?=iOVVhI7xX2HJn@#CJ2C#Thxxr!O7M7iDkfjxKWUS-|r#TOe zg;gb!xW~^-m-O_Xp1kK}y66PO=#fHO+tQd`^yfu<4mxW!(aCY3^7;vUCl>RwqEvBo=+Px<)uws(_E#P-qW4{R?DP3Wj-yy&;Ex#N< z?K@K2Q-;{hC|Ukq;zbzcNU!G^Tr-`qV5=@JoFg5kSR65Hz4ya2L4tVjxEC1~;9b3P zMO=SAtp%s9Vwm2`cEjd$iyoldw=I%Ej6A8b^zJaj1AA*S?{4UCGv|BSmjczI8J;@* zpi%E||2X!_sSLh531TYar7|5EE^vpja3Y$%XM*vP<_=RK06#GeM+w77L0!bBf}Kol zK8*sAZSi9J6${YC4tC6~xsu}vj@fd{+>?#5*sP1#qrKua-qEUreb?>X^HR+BCr&Q8 z?cyb@OaYGWXV;4f`N1U^yI03YMOU zt2ugP0bHLwZ7y#fCMBNhq^nk3Yt5Pb4YxE?S;n1fmiAY=2+p~xs0Oi>uyFbGkqf%R z^5yCw;Q<;O><#=(7ZR8Hl@f_N-ERBsp4auDE?5BTqnIjgJ;b{v(yUw%6kR`3x^z8A zJ|ENK#{jOu0p$8pejAE&ympR7PZ#@uT*JT}4jb{($8?yrIk`%6-}i%E3pnb&W}f0g z=DR?lNr|oyIqnxuVkZTQH|LH%uAB|k=62>P=fdFxQqCu?Ot9od>Uu7fuJ|Kzj`XR< zJ;M`FMh0zwM|aK?LZ3c*`^&d@BrFh=ke3eyq-pc7&sQ}jBg-dNBIoY!+hmXnjqZgT zHB6l+4JYwG;aTb{y`p_pYK7GzVUURICtYn}`wT*Vdu;T{8R)}y+t^fPUzqdkcKPci zC+|>KmuqY5;7bqC7vMF}xmbgpurJc{wPvYi*wjHZyUHiNS+dd| zS-JzJM|+&Fek*zvkex{BYh%g!M_?9k+DwNPM5T8ppIJ3vzePJ!x^5@y?a(ZPS^VU}k$WD7 zTZ8^p;t9Vcm+uB>L3iklI(#PHnec&`XC7~8Sy%g-7HuTluu+;=#*+JBAO3~OgVXJ$ z)?54r#24K)&<#yozv-hazG%HFvZSz>4!wG3c|yTDw|f(Xi;VCa| zWkPGk=L%Lz%ZlYZ$yvBZ8Z9loyW7}2Xo$8QC+^X)x$kwKCGaki2hV_PHDF#YgCyti zOP*?j2BMl_N}jc=?~ZMSu4g~Aac|nnItvzBvqsE`w#3v<5Ba4ncXZVI9VU|U6!dqp zM&hCI!xe2$Ft6@Dd|nBudZZfbXY&A@Q3{+fIDxr(B-gzUv@qb+ya1Y&SlM1TqvaXp z;M{4_*9C@~+V!j5coB?`%M$w;?T%L!w=Zy2O&ec>6DhqkTuYs%+0;q8y8-fb^4Hb& z3wHZJbp{ai>c`A5IBlbOlt!!xyT*V?b&5sA6wkQZ+f;mTq`PtN;?QDr zZ3UW;5bQb7*=pW6AD=4h{T+s%<*uQe70ZlULX@aB? z8W0`+5bepgP&7tBV{{rdEvo?Cgvc|4klg7FDXd9SmC}(Y)&9}W&q$unV3?NZkt8qI z4K@*YLnUHxG$cTXNX`11UZ0n>srJ@-sDf{t(MgTg_#Pj;x1t5XcRyzO zRz7fN(mgZ-AP31(#Cozr)n8(>mKsC*nGC!)d1wdY8^gn$hP3L+y81|`ul9{A?FVv$ z?nv&8rVtb*(z;9-NkBnSFt!;H5s{ee1D!oqkob7z|oUN0`?sIduV2`mOddp23 zls~^wS6?6T?b|ycp%$3k$B!A4O=#w#0LR`QlDEnNhfGN;fEbq$Y6#_7WpAHX}Oa%b3_M4;JPuqU}yt`p4G8qh)<~^aB z`R^>k>KZh0Fz>C^3`WElC0*TjLC1LtpRxUi@KY_9u^fl%u9KBO5zv?IlKeb1T)NOO zgOC7WLs|CH6wvqzc%!fz=*V5<^xTnaR z;acAHJj zC38|2hNw=Bf0C`Q>+MAQaQ2qa$^=u%sH#roQXnfc^9L7kBPIC4>2n+NNSwcFSEU-4 z{SicO>Nf_$VRD_PMpv!=N^ii4Pn)OBbfszI3Ge8f^W2in4M?wZp!D6wctA-+h`dzv z;IZl?0|{$yC;3t&>cW--7L=Aa(K^`&G;exK-Vqeo~SGg$*-89d6V6OviS?n}wF zzHYMVEJ-lsC~rjUbn)Z`KWw(%`mDL~c;o1fEylD1Bhy-x=S}MHS||C{TZWQbkWKJJ z;)E2??r@j>Ha|-F3UreSyj7M>&uU+ZZ-ZVj&|3U`QUIzDHo~K7OmFcNN z7uE7zaJ*Lu$T6&(|1vZ*DgB-A%39kV7>WL71tea^p@`^*a1o8xv8vaR9xLqp@e5p_ zm7OC9!N;Jh-&rI`iw!UB%lXoKB`V28@;#A#<3)R)v{Q)%(4?GA^#(Yo5tuM;{W=^0 z?UrE7HPq!K1w8q!w)7*PF+&&+qCZ(n&yK@e!{T>jovHjKK7y{AZW=Jh^S8wKbXdJT z`2c;IZpIo({rU^QX#i%XQOu^al+;hCzy~S=Z$N%J%0$e*{Y%7|Ta6%BOyj$1MN-t1 zcXmU$)B827`WY9IIs6WKos4Pap!`~I)E=Sv5dSX6#U@psUyU$`owtL`K!napI5R{ zei|G31!R;j+0%z8IE*NM7A=t3qp;E~2F3jhgPm+aDLIJpLF&YQmzTn@8u%%O4RYQc_Zu zmPjC09VW$70^cV{4g^zca)BK65i>joKb6AS@PAt^}RKloTbS?H_*k4 zT{tyAAsqi`sRr7^P`_se5Ft~+g^ao^od-_xj#6nxMstIUG#*~qU|4N$tlIywopWyw zrM^HFf2Lm8oA`NuRZYuh_?A#X3{YVVhS#L8Z=IHWOraOhBl~%5S3b6}HM2 zhxl%rR8>KPC#>RM;FTVoh{2X#++pU~nf0DVVtARSw(gejbEnsB&`( zarQ_b<9#C4#u6K*!n^tILp_XBbyhH|3qN0eW^&~ZhR#+ncr3Jm@RcXG%_YBZuZFmhdj&wSQrVb(6Q_67b;FMs`V zuUeZ33shUsZw~xK04Z{srKXkuTKeW_F$icDCz5lN1b}m@NaOb zeJXhY)vZvIT2rHj_yo z<7UwEN@D*U*~>h$555i3ygimA17$}*bJltOzUw5M&7GaCq}c6V)k?_9W-o#KD0LoI zv7q>qJu3p#SC?qXQ47>h-n{V|rXdB5|A3E?(Rcb4#u^kK`@Ja2^}3K-LqUOt%dOQn z8Qjq80TP9^mdYE&0>ht|vpDzL{@R)1SsT*M$R-S&ic@J%gkQJ)513xq&@xa~Z5mE4 zREpX}UbRk5@xFNRf{pDE&|u-=;ih<)rZ$GwtV8?dHetFw6F`l5s%Neh?mMnnm~&2|G} zMK4YxI?F0d!-Id9qX;rhSt+S*;8hsMZiaGBTd!72NF!d^Nfxy?HyIId7tu+Vj!uJE|NAiGjrAivcee=kp+xD zAL<1FLG0}8e0*+48zZ2>b8;ntSB#Jdu@WZ(k`5Hhf#85EUuOQwcUyRS)A$52N`e=r z^_97*2Pg^6Px}Fv0u(zV@Exmozk(iNIaEat5P1YZs}~zfLP)3r6t>r+UhYBpK!!M5 zY_t;*oO!@9Fa1OJm-Dr35yYg_7dp_kgdk%loEXD2rDfsxIWGf=;@sCdH_#hkI7I75Y6CJQoB^-i9N z)A_+)Ja6Rr>6+Ic`Gh@eyD3{cn248+Dt}ahYYciC9TgN5jE&d#mfHSEPjPj4!QJ)3lbJ2AgU_IFzK^j&nvZ4c0m`-sM4DV}*ZMij5-R0nR@MH0ah`Knam**$%7Q z&DxH?h;_J!c^j#X=fAllve>GY--W;-=WPAjLb9P_fA{cmvFDVX6$2;4v(Kte`23xg zc*j-`ZRU1}KrwK3n865Ta%|L`L<{lv_ZO3v#=*nWu6HR1MQ3w>II5TtWKXrdbnyJ3 zntMY@eE@|@2)1;&A~;pCwa@>NrqQj7-UOx3zbKP;$p7M(o`J*HSXtj~va?Lvg24I3 zQg={sNVW_uC_g35%gd{~yBiqN{r>%~yzSOFpslP(_Q&2fQsNdc(+?48YH(lw(hj4P zI$d-uC2NN9aHqqDKy?oAGdKU{QtZ^YTT2E`F#nc4R<8jC9U-4>A4<}?4o1Bo1~$^K_zl*9Y9>XNf&#Wa+g*$CaS3B7znrzCLM-6)cz~_R~sL`QTeKT#VMUhdQjCxAqPdWjeB6MELn9;{Mi&lWW(eM6!^2Sfx}dvtG4 zj(@>><*&){5m8U~(FSl~{d&Mj=q)RhU<1cIxZg^O=~;JP{hY zK=~9b*ms;NPzCLGdI1PykV5JsJ8kh1yImdwPXc zQo}Wajl_kCRk-qp592LCM4Q7uSZ!Ckfw^#^peI}eM>67; zl|ERcURYM^nG}GHpo^3|r=|FC@!Wl(d@(I;isvK%xDKGI+#gS8W~SO4_f$;)@5#~Q z+GFVq=q7N}ff)+m?+TF4^Rd-b{?X6v@aXHlGm(zj6rG=`5`_S=69*<_;@}5DCSR?w zt)AvsUTmf#GLJ;zB-4IQeC?#UXyG8y^m}CFscI2oVL|@fdW@TU^S{<&tXD;a6j4FB zLh*PIwvhb5^mTuKi%Vx;;=>jxIWp zz)+TavVPwO^HD?Z?%`oBiGopkw<9#Uzb$DGIHLTRy9_{R zVNJ9D2P}@g^G@-V^hjS69`59eG@n2~Q9^P+5JiPrgFw|7)b29c)|SOTPDe{Gq^h96 zNcXYVDBC`B;`7|8tI%>!U7b4+FU#}C2B0A#>(KIRgqllDiinldWmd%Xh*{iBmFXKD;TsHWlT?qw z%Z3jkiwiGNcbAl!spR1tRvjLnfye`EdPTC45yqhHSm<9usHW_HC4MWw?@w^AB5v3OK^O2>8I%L<9UbzH zN>-#z_dSMRS{}FUQ9;Qryp#?rgyRbp1~h(^H5cgi`TFR8JF!RvE*txK3Rh|abOl|@ zs`iWVt|0sj#O4L^x?hEXGRH@wi~wn~VYtcQBrH#}=+mauq-METXsQ|tB@r!cZzo1Z zJ|-n~0qi6gAPx%D>^~Hy88-Km?|Dz<^U3Kb9jX`=HWy4sfD{EZs1(>M*5g5)ErGp~ zLiWUYDUYqPb(>ud{9k1Fe}Haa$sB2HF+xq^V}@!vtxEa_y0ZTP?eyEhinL1LWVW`~ zK|eWr(+t*hD{kV$$E3PtpG>aQgu0G3qexvj3uX@|Gb$>+HZim?sNLa6R_S+k@Mh$MirlhQW0veD&Qg&&Z0Gg}_K!{4L zKT|?!{7CAg;)7D=IZ%(Z@a2;yPrz6P28MhPqc024e82-LTi>o$6bz_jn2C7CzrAav zIp}MU_xw1jXuV%e%d?`xf&v&i0gi@7UE}th6IAcC6^pN`YtW8Au$X&^i&5AM!ey75 zsG2a$epO;9Fo}H#Gt|vKNEbLHbws$1vd%yY1mlV<$$ zfmnG*MLWbWy5zB{x{aC_tK-Sa{(xJk9U1kgv=9KZqn6+EYPau5|LN;x?t2^UK<86; zOC5D3AWQ5BJUv*&YnALkv;UzWIQ9VSIX)$cy$N_^R>D{+ScU5^n4+sl8oDOs?|aHA8y~_ zM7^V&RCQ1ad5Ew|KbJE|n+@Z882d zU8f@AMrClBUS_;*r&i|X=D>n1j7pG_fPmofW4rbKr)};DE5dT=lV?nG(PoE)rHNTg zT0LU%pz;J-=Um%bvahXyk-`*jtssZazC@|(&!4jQ0myd;1$S|AanQ!G$jS5iwZirS zqyiOhqbmUvud3qO+x|G;_z9R9DLbs;)>r-RFY_Y}le(+}z68R&WzdM`j6;GY7iD8S zurf4d&ZO5C@WG-#y1EHW0ySm8-@(nU@@6olL7LcN>C!S75tL*cZ7oEmIym%08G7J@;c!YXpgZ{EBy zG&BS$sjhA+3P*!}6XV27#s@zcn3($FdJ-z`=BE8eUGO3_))R3V>+C&chY(a>CRTyh z|IgN{$5c-N&3GHNkmg2F{iT@bsAiyk!f#k~T^$65J<#tK3+fh4(ZB@<@MT{o|5eNT zO)2HtS`U}B>;nx>!(vhrm8R1b|Aw$#G@PuG@dSo5@c;y6kc0jWfQvPx8p3xeYBb$K z=!Fof(4kV2Uis9Gva@Q{>_gKBnw7tn%Q3NvR{AKML>J2IKs9wttKnxYAc1u6ktupy zaqI3Tx{EyXcaKBr+JuSSG^Rw)@~^LKvtH~O11JPE_B;n`QN)Qo^Sx%w&x+I^d%ow9 zc!h;pEyff9m|MELJ8L3wx^@=6-by(<+mig7f_sCxF_u^Fr+^a&s080IEldD|kGSeR zF`!!(Q+n?S>SbNWhSBAI|B1dfdgd8ZLgFq8Nak=GRmKt|t|j37toXlBjV~2>3f{Ey z*abeP{GK-yXQ}x$nr4N#Bs7fgVrKNjE$_79T5Dmp2lk4LB0kDPK7(Fy_G%V5Lgr&t z-^|S>HVP~6+)x>P@VSRi@ZbyGu-JVd&1jG+l2m`Crq1c9;8N?LIMmE9MK9LkKKJq< zE>ket<_7~Kqw%AjGEX08mMDhbcRs$yR~o%hl}XIvZh|z$ULCpZ&Ref`$J)Xhv2AA$ zuG|`oMBe$`H?qZ$h8ng;U2ME_#u6*^`h+1f)4FVE^&AM2tV}RwC~`A!K_!-SVqEp2 zr!D^4;YP=K#b_u05Jvhf+IDfA(bLrV$4kq3guy42sKj;Tys0kt1{bT-EE>He^V#Ig2Ad(gt9QlM_|@nacmPJowJ!>zBoyUadahpZW!E2cGs zjQ08S-UMz%=%dGvo68oxR)`r(a*u{{p`}9{`v=jkPwVQ)>g$dg_O%AzSS_57BPrU< zCcQsy1%{bjm|TCRrW=-+*;LK##SO{_gY7|!GZ7)-cQEGzaER4U1gp(*I**9d+6o2he3~Z(V083gm@YJP^WQ`;Ite~tJ_jH5N@HE!3a)h(8?#7 zW0bp@o*C+LU7$UCML!#A!9w{_QlR{$YP;*{W~BMCAdE( z5eUY$&*Ylj)tMuHwN%TgwXc?X1{Bv3Z- z^^GIN!)jb*Q2*F6k2TyG{EI-`j5WjO_vKJWSjEu+EREq~F7FT3jLrfH{o_}MC#w$b zoXU&NNaWL^d`a=h|A)h?JkS5pzxkgI>O6ZC$nU%LR_o zRF5O}d*w}fQtM$ib6ep-Lw1H+JwsD#qg6;IoM0LEo0DEQeC}B>%JW9S2<(c-+eFUd zH(0FYCEymWc;X(j1`uulp(3X3^`$n(6u(-Jhy_}|Tsfhd{OvnKO3At$JcSyaqv=e1 z!?~w}cPevp$!>WY!W{>0ryP zJPXaaIWGa%7(vzRM_qR*LxG`PkQW6$b zJbPBp0z{9u+wZ(-(DgaTj~8)nqYRPIDP4{f<-~lt@45t09Re;4BWhNt5k$ zb-D0gS(K~^;EyYs_Uy3{OmCjeC3F_DV*m!2E*tF31BJeeXvfcAy+V!`>jUVBKp^(^ z_9`rKxBLkTpP0;MR03;e$KA*%N5S3GszPZOym(S#a?78eY_8SZyWn)+2;tLkmy7+3 z+MdLRW4CMLYC<@9Y2S217=({L1spR!#`{UNu&@A{eE}E*rjQl(8afROc6U0?Wn5}a ze+zkppl5a&@V$1J-Adg%5a78Qa~Ku4$!Gpyv>Qy(#*0Tj`?a-etMo3G3^3))X$_v3 zAp1;B|0ZvQkdV;#%a_Qgs1Z1OibA-uJ8k{d_9@=tQ^|&^zh<`f+uO@}x}b@Ca+CuL zDr;v(Q_}-2C%!J-@@9>*fhqIT;Fh0}a`D#I(3O1N?5Emhg!-PHopG3BlP3;P(+}PB znZ+HB_KXjg>Gez!B@@?w%)ahiW)#gjtd*~>=ex-tP_u6NJy3LF8NIqXJ9K6VqC@=XVt^lrKRm6$YLo&hir5`KUmw)x4J`qmj(S* zPa%ftI3aj-BQ{~8VDv8nE8}MDss{%cstJ8PGVY6oah)G=$WM0*Lf!r1W`4VDH$ZXX z2Wfv7S@(xkexk)`2WcTOd>MMi(z6E_S%qU=6KFaHj12 z^rhj>_s+mTFpTAwIQ^1~z;h1ZJuzt^`CL1hS}WbzVNXW;=J|b5JN9uy07!z)vh#9t zDJl8$4!p8)j+r>kkNZzQvt~DY-12V9w%{@^`?3G?o$h*&8DZ$U%G?~funI&@`|mA@ zR;1fYu~-gY2~keJ=(_hz%VE_6;ii=Um)#&S?~h=<@YZg1guT?Z{&70!qp{?ANS1WD zpArK;_BZNZr|CdP4gT9 z=;Q06`zGGO@q}%lrayj)lK-dZ#<}qmEPphJ*F6xMOXC9dW;RIp2(uB*Cm`UzP$jke zp(^qW_H(PN3)H0*IXh2!!Bl$2_igqXAhg#(XGP%cW~iMR-TO78H%G>`HOXXL9FIdw zTdN0rl4a^1K)Uf&YICnz}Q8-hj(!Wf%B zznx>h8rsS;ghiSg@x1s<91?jmx>>- zZe)y7(@B=DQRjii^t!sb{{DVoLIaQ@p;14R?(PK<=SV^Px6`w;*sBjfxe@=wka(;S zbwnjK{eOOp5g0kbBo8CsrXgJwH~Zw}&{@)vz?B+WMH_g5BIcOYzG9JNT_!VqP-Kr#W!YbkjUwpe5I2r5rWlZC|k+J%KbA-Qt3CP zgyNgWocjlyHJSA|+x#CU!b@|I>fOd_)-o4po?-`h%)uW1RP>IG=FKrJ@d+yH8Z$eQs$@mW`oB7mB2t>yq zl$4c0{`S%8p>7*)W;WbafuVspMLKWX)u!ZHJD#`pFDW(q!^R{|?d!4Wndzb_fr-S8)s^HMZbt(Nmx^Tp@) z>cpkXO}iR;l?=qLALj}kZftMD-D^R!d~CF>-m&1)np;e%n|X5Q{{Gr1a_T5K7E^FG za{o9Cg-MRjR*pxeqG@MljQl4Wuu6mS=}ce$3Z^ZfQK_ZibNUH-Xh=v%wx=rldV2}y z02663LkB*bMd)MJL&5X%=Jr6Cz+~BFo}ToPeDl4l(!@)ZEdW}b1oYQx>d6QRwQHV? zdX_I85s;|nk}W;`-Fk|Yj=I>}-6wPu?;5J4BC{=0*&5XmELpA$quUuYW&;@XIU`trQ7l**{!%|N0ug5hvNL+Mq6C7&hu7B9xUvHYSrP? zQVQ;IXnyNRU?dnsA7*w$k>(s4m6 zHmDCl!9`;qBV2_Vi`3>sDuQhDkdW$|j=zcx4;K?TXI<8!x`?uGV6M(x9FBJQ zjz5lg!-?JeugmxohbQskrC4>6XZ}-Oso6jd>h{ZGEJDe%YQsB5HW06+iJ-b#f*AH|ues)2!z=g|BaRq{;nqOx-_qRExAZ+^i=v3~|!iFf+WQ{D_ep z9zh>m(!?FUom~sMY=!DVQM*eOgJ=i|7>h+=d9;O$ITt=HU4F@#7r0Y$F@Oz)Uqg z3esr6ZPCq~Vi_LQlzKN;1$R?zY%x z!gBTtk%UMUO$IBBkZo z4hE)7Pg(TG$X>(3$6wQ>*$+-)pMC1l5OL-?Z|S_sIztln4FTzVvA)i!lfg=n0eELnNtR`Qg^UgJQl7@C85iqHCSF;s^o z3aE1yC5bFUb_QThB_ERd>nDbf=KL?^l-0QR;3>i;cK};sK36@5E-Pc52e0b1#ruMg zWl(Y1?p%g4`u0rsb6g8p+X8CqciN;y47*M1adO7(*Kmy#e-iMOF>pJ{+DFem3}EI8 z^l;_qBV%>fP|*>44+x8<J)m34K`zFIRP4$B|h>>rGshk0KLTWF5 z%kIzQGVM{0Za5%jIVgCd9}|%BT}tddLzF>@Yi+^+-5`}M(03AKKEd<6Leg`^hbV+n zcy7Nakcl8+hEH&>f0hxgM?GfzgL8BVOJ_Qf_Atrq`13Rvj=d4WPSoW#Y}EE?$}F#dI2 zfKoWbWBl?rcL-p7?nRLg9K>ZgdOcs^VVAhBfVilU`V(miRhxdQKE>}$zNxhvOjr9Yq; zlb%d{8?n6fQiEO_8)_N+E7hl%UciAh0QH7C7<#@@?b+3Xhc6OxCcaP9%kGOeto#M* zC_8*Al@7y!K-kE^REnzyo>Sl!g32tILP7j%gbdB~Nm8cf8*~WyV;1xr3RT!`@HZko zUuE`X{p$Aic7TdFMZTxuW}U>(8s0Lt++~foH=w(6WN57026CMn*|G~!qjAH;Svv?KM)J$fHDgPT`B3TCRR|*oq;|Twt zAYO;94|aBTE-o%^ZgmCm09R^~vY=a0{x??QkKc#khkK*k}5~EY3C7m1g2J7e;!FAF1X_tBQ^`a zrvn~Y%z%gG1(;v}#kg|&K8BG>ys;SHCF48s4x-wm@C4)_o{`(YzhJ)<;=JQYJ1&5Eo!;N|0 zEhoKudA8VHqME0ocNV1WfzNsHT$b{ub19brFt~b1kG|H8&ywEq`OXxjYyMCOXCQla zP~fQhNn*$p&i!@AE=KPP%Mjyfu4=O}PD+mt`DZ+wm9a&zE}#2HoI}QJ4bm}B7@4+b zT(9s1>pV_(qllmnIQge%T3EBe-FqHNy(qC)W-n0#(yAR@T8+1j%#JdgofXO1no=8ot&ZO~N_2*%5;KTd$4QH#ny9)z7@wDbs4&^ny(B%-0uIOYj zsmEQFBPs;wnC0LR`wIuX1m%dAFBM!5ADGF=CX8FIbpFm$<)4{h6%F~uVYYl0O_WlU zZPfea9!s7I&P;Jr)67-s`g*H?Kxbm*;RzA#2Q63)qPsbO0_twxe!NZn3*+o8F_EnU zOORA9@44-&Kkc$3jcDLs`3ywne69|P+H>jPi?h~ns(R*haXeIOA3^1M632dzg@xKY z=q8iauI6-1yN^T=n!ojsq&gR-9iDe{gsc@=6Mito=eAkU`TCuK$>QFIX9ENx3BLbL zI%0)~0<@Y*Jj&|hr|mR@zrTB43e9dc^a+?njsBXP#JEF}a4%ro%DkJ{yT=2Z_$KS{ zfyub^ze!uaWTM=C*N(R#^!U4Qh$U8J|_P58gh zco*^$cPxa&K7n93i59PXts+(B`}F~0tQLKAIZqWQ2i(nNMD?{Fl}n+vwwf}*>JAgZ zMaP{li^bKCXanu6;TaiqB{qZnC)fcY{NJL-Ot#epnTkfi`wDkdm7J*dJ<;!dz)2yJuh(+1+57 zp3fag%qR_((x=VV;K9Ja7bml|X|hzsZp@sOVBcBH@738?bJky}E7N=HxYBt&=h5|} z@SHI(=WddqcEVbKV#h@;rss*%fwcAPgy&Ee%oi^V3;VIINWxu0I)Qq^r@CWHVUk_f zrG^2VIz=1R*>Syzn+T*OvrwTJQD=u04I$%e_q!kbPi=#OpAx=zdf-VK&N7`#OLB0s z7du-J|CXZKCQu`GuiEk`cj{<_Ex2!6Un^18WcMk~WVK8_8av&C8W z+P3dSe5&V@;zvyNXBJVc%YeOnLEBVt^x$X7Z+cZM2?^|t_9(^a&MC6wO%?sRjJm(? zJW=0ZNEqLKgGMFc6$^kD5HEr%%Wk@Y9OGKO7F3*IZQ$to&hOO4*x6xZ@EkeFnc;pB zqn!6zG=wL0sHFhvZaU3{FNt*9F5eLebvxXylqDh%r*aw#xAC3cJP>^Oyvd^dY5#+B z;o0*p>U(sXe=Z_wMP#j};KygwMT8KhNYeZ5OrO1d_c>0G8vqy!a4R%NFRWCPJXNS= z1vZaGNs4Wt>I>7_Yr6wfz4X0I_p_y}hvMN5oBClS7QWZ%rs^sc{nD`4)9QF=_Xn8v zN3}U7VWN2jD`T z2<#=`AFoc7=``qK66r?$lkytamV%!slwB!+ox%SDtAXGC|A+p6;Wk|hdVAT&Zp}0M Qp`N6;u+00ycRHW{FC=GN2><{9 literal 0 HcmV?d00001 diff --git a/doc/pgpool-en.html b/doc/pgpool-en.html new file mode 100644 index 0000000..01129c1 --- /dev/null +++ b/doc/pgpool-en.html @@ -0,0 +1,2372 @@ + + + + + +pgpool-II user manual + + + +Last modified: Tue May 12 10:01:50 JST 2009 + + + + + + + + + + + +
Welcome to pgpool -II page
+
+ + +
+ +
+ + + + +

What is pgpool-II?

+ +

pgpool-II is a middleware that works between PostgreSQL servers +and a PostgreSQL database client. It provides the following features.

+ +

+

    + +
  • Connection Pooling
  • +

    pgpool-II saves connections to the PostgreSQL servers, and reuse +them whenever a new connection with the same properties +(i.e. username, database, protocol version) comes in. It reduces +connection overhead, and improves system's overall throughput.

    + +
  • Replication
  • +

    pgpool-II can manage multiple PostgreSQL servers. Using the +replication function enables creating a realtime backup on 2 or +more physical disks, so that the service can continue without stopping +servers in case of a disk failure.

    + +
  • Load Balance
  • +

    If a database is replicated, executing a SELECT query on any +server will return the same result. pgpool-II takes an advantage of +the replication feature to reduce the load on each PostgreSQL server +by distributing SELECT queries among multiple servers, improving +system's overall throughput. At best, performance improves +proportionally to the number of PostgreSQL servers. Load balance works +best in a situation where there are a lot of users executing many +queries at the same time.

    + +
  • Limiting Exceeding Connections
  • +

    There is a limit on the maximum number of concurrent +connections with PostgreSQL, and connections are rejected after this +many connections. Setting the maximum number of connections, however, +increases resource consumption and affect system +performance. pgpool-II also has a limit on the maximum number of +connections, but extra connections will be queued instead of returning +an error immediately.

    + +
  • Parallel Query
  • +

    Using the parallel query function, data can be divided +among the multiple servers, so that a query can be executed on all the +servers concurrently to reduce the overall execution time. Parallel query +works the best when searching large-scale data.

    + +
+

+ +

pgpool-II talks PostgreSQL's backend and frontend protocol, and +relays a connection between them. Therefore, a database application +(frontend) thinks that pgpool-II is the actual PostgreSQL server, and +the server (backend) sees pgpool-II as one of its clients. Because +pgpool-II is transparent to both the server and the client, an +existing database application can be used with pgpool-II almost +without a change to its sources.

+ + +

Supported Platforms

+ +

pgpool-II works on Linux, Solaris, FreeBSD, and most of the +UNIX-like architectures. Windows is not supported. Supported +PostgreSQL server's versions are 6.4 and higher. To use the parallel +query, however, 7.4 and higher must be used.

+ + +

pgpool-II Installation

+ +

+pgpool-II can be downloaded from pgpool Development page. +

+ +

Installing pgpool-II requires gcc 2.9 or higher, and GNU +make. Also, pgpool-II links libpq library, so it must be installed on +a machine used to build pgpool-II.

+ +
+
configure
+
+

+After extracting the source tar ball, execute the configure script. +

+./configure
+
+ +There are options that you can set if you want values other +than the default. + +
    +
  • --prefix=path
    + pgpool-II binaries and docs will be installed to this +directory. Default value is /usr/local
  • +
  • --with-pgsql=path
    + Top directory where PostgreSQL's client libraries are +installed. Default value is obtained by pg_config
  • +
+

+
+ +
make
+
+

+

+make
+make install
+
+will install pgpool-II. (If you use FreeBSD, replace make with gmake) +

+
+
+ +

Configuring pgpool-II

+ +

Configuration files for pgpool-II are +/usr/local/etc/pgpool.conf and +/usr/local/etc/pcp.conf by default. There are several +operation modes in pgpool-II. Each mode has associated functions which +can be enabled or disabled, and specific configuration parameters to +control their behaviors.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Function/Moderaw ModeConnection Pool ModeReplication ModeMaster/Slave ModeParallel Query Mode
Connection PoolXOOO0
ReplicationXXOX(*)
Load BalanceXXOO(*)
DegenerationXXOOX
FailoverOOXXX
Parallel QueryXXXXO
Required # of Servers1 or higher1 or higher2 or higher2 or higher2 or higher
System DB required?nonononoyes
+(*)The function of the replication and the load-balancing cannot be used for the table preserved by dividing data in Parallel Query Mode. +

Configuring pcp.conf

+ +

pgpool-II provides the control interface where an administrator +can collect pgpool-II status, and terminate pgpool-II processes via +network. The pcp.conf is the user/password file for +authentication with the interface. All modes require the +pcp.conf file to be set. After installing pgpool-II, +$prefix/etc/pcp.conf.sample is created. Change the name +of the file to pcp.conf and add your username and the +password. +

+ +
+cp $prefix/etc/pcp.conf.sample $prefix/etc/pcp.conf
+
+

+An empty line or a line starting with "#" is treated as a +comment and will be ignored. The username and the password must be +written on one line using the following format: +

+
+username:[password encrypted in md5]
+
+

+[password encrypted in md5] can be produced with the +$prefix/bin/pg_md5 command. +

+ +
+pg_md5 -p
+password: <your password>
+
+ +or + +
+./pg_md5 foo
+acbd18db4cc2f85cedef654fccc4a4d8
+
+

+The pcp.conf file must be readable by the user who +executes pgpool-II.

+ +

Configuring pgpool.conf

+ +

As described already, each operation mode has specific +configuration parameters in pgpool.conf. After instaling +pgpool-II, $prefix/etc/pgpool.conf.sample is +created. Change the name of the file to pgpool.conf and +edit the contents. + +

+cp $prefix/etc/pgpool.conf.sample $prefix/etc/pgpool.conf
+
+

+An empty line or a line starting with "#" is treated as a +comment and will be ignored.

+

+

raw Mode

+ +

In the raw mode, clients simply connect to the PostgreSQL servers +via pgpool-II. This mode is useful for simply limiting excess +connections to the servers, or enabling failover with multiple +servers.

+ +
+
listen_addresses
+
+

Specifies the address in hostname or IP address, which will + be accepted by pgpool-II via TCP/IP network. '*' accepts + all incoming connections. '' disables TCP/IP + connections. Default is 'localhost'. Connections via UNIX + domain socket are always accepted. This parameter can only be set at server start.

+
+ +
port
+
+

The port number where pgpool-II accepts connections. Default + is 9999. This parameter can only be set at server start.

+
+ +
socket_dir
+
+

The directory path of the UNIX domain socket accepting + connections for pgpool-II. Default is '/tmp'. Be + aware that the socket might be deleted by cron. We recommend to + set this value to '/var/run' or such directory. + This parameter can only be set at server start.

+
+ +
pcp_port
+
+

The port number where PCP process accepts + connections. Default is 9898. This parameter can only be set at + server start.

+
+ +
pcp_socket_dir
+
+

The directory path of the UNIX domain socket accepting + connections for PCP process. Default is '/tmp'. Be + aware that the socket might be deleted by cron. We recommend to + set this value to '/var/run' or such + directory. This parameter can only be set at server start.

+
+ +
backend_socket_dir
+
+

The directory path of the PostgreSQL server's UNIX domain + socket, which is used by pgpool-II to communicate with the + server. Default is '/tmp'. This parameter can only + be set at server start.

+

+ +
pcp_timeout
+
+

PCP connection timeout value in seconds. If a client does not + respond within the set seconds, PCP closes the connection with + the client. Default is 10 seconds. 0 means no timeout. This + parameter can be changed on service.

+
+ +
num_init_children
+
+

The number of preforked pgpool-II server processes. Default + is 32. Please note that cancelling a query creates another + connection to the backend; thus, a query cannot be cancelled if + the connections are full. If you want to ensure that queries can + be cancelled, set this value to twice the expected + connections. This parameter can only be set at server start.

+
+ +
child_life_time
+
+

A pgpool-II child process' life time in seconds. When a child + is idle for so many seconds, it is terminated and the new child + is created. This parameter is a measure to prevent memory + leaks and other unexpected errors. Default value is 300 (5 + minutes). 0 disables this function. Note that processes that have + not accepted any connections are not applicable for this. + You need to reload pgpool.conf if you change the value. +

+
+ +
child_max_connections
+
+

A pgpool-II child process will be terminated after so many + connections from clients. This parameter is useful on the server + if it is too busy that child_life_time and connection_life_time + are not effective. + You need to reload pgpool.conf if you change the value. +

+
+ +
client_idle_limit +
+

Disconnect the connection to a client being idle for + client_idle_limit seconds since the last query has completed. + This is usefull for preventing for pgpool childs from being + ocuppied by a lazy client or TCP/IP connection between client and + pgpool is accidentally down. The default value for + client_idle_limit is 0, which means the functionality is turned + off. You need to reload pgpool.conf This parameter is ignored in + the second stage of on line recovery. if you change + client_idle_limit.

+ +
authentication_timeout +
+

Specify the timeout for pgpool authentication. 0 disables the time + out, which is the default. You need to restart pgpool-II if you + change authentication_timeout.

+ +
logdir
+
+

The directory path of the logs. pgpool-II 2.2 or later does not + use this directive. In the future pgpool-II might implement its + own logging system and we leave this directive as it is. +

+
+ +
pid_file_name
+
+

Full path to a file which contains pgpool's process id. + Default is "/var/run/pgpool/pgpool.pid". + You need to restart pgpool-II if you change the value. +

+
+ +
print_timestamp
+
+

Add timestamps to the logs when set to true. Default is + true. + This parameter can be changed on service. + You need to reload pgpool.conf if you change print_timestamp. +

+
+ +
connection_cache
+
+

Caches connections when set to true. Default is + true.

+
+ +
health_check_timeout
+
+

pgpool-II periodically tries to connect to the backends to + detect any errors on the servers or networks. This error check + procedure is called "health check". If an error is detected, + pgpool-II tries to perform failover or degeneration. + + This parameter is to prevent the health check to wait for a long + time in a case like network cable has been disconnected. The + timeout value is in seconds. Default value is 20. 0 disables + timeout (waits until TCP/IP timeout). + + The health check requires one (1) extra connection to each + backend, so max_connections in the + postgresql.conf needs to be incremented as + needed. + You need to reload pgpool.conf if you change the value. +

+
+ +
health_check_period
+
+

This parameter specifies the interval between the health + checks in seconds. Default is 0, which means health check is + disabled. + You need to reload pgpool.conf if you change health_check_period. +

+
+ +
health_check_user
+
+

The user name to perform health check. This user must exist + in all the PostgreSQL backends. + You need to reload pgpool.conf if you change health_check_user. +

+
+ +
failover_command +
+

+ +This parameter specifies a command when a node is detached. +pgpool-II replaces special characters to backend information. + +

+ + + + + + + + + +
Special characterDescription
%dBackend ID of a detached node.
%hHostname of a detached node.
%pPort number of a detached node.
%DDatabase cluster directory of a detached node. +
%MOld master node ID.
%mNew master node ID.
%%'%' character
+
+You need to reload pgpool.conf if you change failover_command. +

+ +

+When a failover is performed, pgpool kills all its child processes, which +will in turn terminate all active sessions to pgpool. Then pgpool invoke +failover_command and wait for its completion. +After this, pgpool starts new child processes and becomes ready to wait +for connections from clients. +

+ +
failback_command +
+

+This parameter specifies a command when a node is attached. +pgpool-II replaces special characters to backend information. + +

+ + + + + + + + + +
Special characterDescription
%dBackend ID of an attached node.
%hHostname of an attached node.
%pPort number of an attached node.
%DDatabase cluster path of an attached node. +
%MOld master node
%mNew master node
%%'%' character
+
+ You need to reload pgpool.conf if you change failback_command. +

+ +
ignore_leading_white_space
+
+

pgpool-II ignores white spaces at the beginning of SQL + queries while in the load balance mode. It is useful for using + APIs like DBI/DBD:Pg which adds white spaces against the user's + will. + You need to reload pgpool.conf if you change the value. +

+
+ +
log_statement
+
+

Produces SQL log messages when true. This is similar to the + log_statement parameter in PostgreSQL. It produces logs even if the + debug option was not passed to pgpool-II at startup. + You need to reload pgpool.conf if you change the value. +

+
+ +
log_hostname
+
+

+ If true, ps command status will show the client's hostname instead + of an IP address. Also, if log_connections is enabled, hostname will + be logged. You need to reload pgpool.conf if you change the value. +

+
+ +
log_connections
+
+

+ If true, all incoming connections will be printed to the log. + You need to reload pgpool.conf if you change the value. +

+
+ +
enable_pool_hba
+
+

+ If true, use pool_hba.conf for client authentication. See + Setting up pool_hba.conf for client authentication. + You need to restart pgpool-II if you change the value. +

+
+ +
backend_hostname
+
+

Specifies the host name of the PostgreSQL backend. The empty + string ('') means pgpool-II uses UNIX domain + socket. + + Multiple backends can be specified by adding a number at the end + of the parameter name (e.g.backend_hostname0). This + number is referred to as "DB node ID", and it starts from 0. The + backend which was given the DB node ID of 0 will be called + "Master DB". When multiple backends are defined, the service can + be continued even if the Master DB is down (not true in some + modes). In this case, the youngest DB node ID alive will be the + new Master DB.

+

If you plan to use only one PostgreSQL server, specify it by + backend_hostname0.

+ +

+ This parameter can be added by reloading a configuration + file. However, this cannot be updated so you must restart + pgpool-II. +

+
+ +
backend_port
+
+

Specifies the port number of the backends. Multiple backends + can be specified by adding a number at the end of the parameter + name (e.g. backend_port0). If you plan to use only + one PostgreSQL server, specify it by + backend_port0.

+ +

+ This parameter can be added by reloading a configuration + file. However, this cannot be updated so you must restart + pgpool-II. +

+
+ +
backend_weight
+
+

Specifies the load balance ratio for the backends. Multiple + backends can be specified by adding a number at the end of the + parameter name (e.g. backend_weight0). If you plan + to use only one PostgreSQL server, specify it by + backend_weight0. In the raw mode, set to 1.

+

+ This parameter can be added by reloading a configuration + file. However, this cannot be updated so you must restart + pgpool-II. +

+
+ +
backend_data_directory
+
+

Specifies the database cluster directory of the + backends. Multiple backends can be specified by adding a number + at the end of the parameter name + (e.g. backend_data_directory0). + If you plan not to use online recovery, you do not need to + specify this parameter. +

+ +

+ This parameter can be added by reloading a configuration + file. However, this cannot be updated so you must restart + pgpool-II. +

+
+ + +
+ +

Failover in the raw Mode

+ +

Failover can be performed in the raw mode if multiple servers are +defined. pgpool-II usually accesses the backend specified by +backend_hostname0 during the normal operation. If the +backend_hostname0 fails for some reason, pgpool-II tries to access the +backend specified by backend_hostname1. If that fails, pgpool-II tries +the backend_hostname2, 3 and so on.

+ +

Connection Pool Mode

+ +

In the connection pool mode, all functions in raw mode and the +connection pool function can be used. To enable this mode, set +configuration parameters in the raw mode and below.

+ +
+
max_pool
+
+

The maximum number of cached connections in pgpool-II + children processes. pgpool-II reuses the cached connection if an + incoming connection is connecting to the same database by the + same username. If not, pgpool-II creates a new connection to the + backend. If the number of cached connections exceeds max_pool, + the oldest connection will be discarded, and uses that slot for + the new connection. + + Default value is 4. Please be aware that the number of + connections from pgpool-II processes to the backend will be + num_init_children * max_pool. + This parameter can only be set at server start.

+
+ +
connection_life_time
+
+

Cached connections expiration time in seconds. The expired + cached connection will be disconnected. Default is 0, which + means the cached connections will not be disconnected.

+
+ +
reset_query_list
+
+

Specifies the SQL commands sent to the backend when exitting + a session to reset the connection. Multiple commands can be + specified by delimitting each by ";". Default is + the following, but can be changed to suit your system. + +

+      reset_query_list = 'ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT'
+      
+ +

+ Commands differ in each PostgreSQL versions. Here are recommended settings. +

+

+ + + + + +
PostgreSQL versionreset_query_list value
7.1 or beforeABORT
7.2 to 8.2ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT
8.3 or laterABORT; DISCARD ALL
+

+
    +
  • "ABORT" is not issued when not in a transaction block for 7.4 or later. +
  • DISCARD ALL degrades performance since it aquires an exclusive lock on pg_listeners. +If there will be many concurrent sessions, you might not want to use DISCARD ALL, rather you specify each object using DISCARD command. +
+ +

+You need to re-read pgpool.conf upon modification of this direrctive. +

+
+
+ +

Failover in the Connection Pool Mode

+ +

Failover in the connection pool mode is the same as in the raw mode.

+ +

Replication Mode

+ +

This mode enables data replication between the backends. The +configuration parameters below must be set in addtion to everything above.

+ +
+
replication_mode +
+

Setting true enables replication mode. Default + is false.

+
+ +
load_balance_mode
+
+

When set to true, SELECT queries will be + distributed to each backend for load balance. Default is + false.

+
+ +
replication_stop_on_mismatch
+
+

When set to true, pgpool-II degenerates the + backends and keeps the service only with the Master DB if data + mismatch occurs. If false, pgpool-II just + terminates the query. Default is false.

+
+ + +
replicate_select
+
+

When set to true, pgpool-II replicate SELECTs. If false, + pgpool-II only sends them to Master DB. Default is false.

+
+ +

+replicate_select, load_balance_mode, if the SELECT query is inside an +explicit transaction block will affect to how replication works. Details +are shown below. +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SELECT is inside a transaction blockYYYNNNYN
replicate_select is trueYYNNYYNN
load_balance_mode is trueYNNNYNYY
results(R:replication, M: send only to master$B!$(BL: load balanceRRMMLRML
+

+ +
insert_lock
+
+

Replicating a table with SERIAL data type, the SERIAL column +value may differ between the backends. This problem is avoidable by +locking the table explicitly (although, transactions' parallelism will +be lost). To achieve this, however, the following change must be made: + +

+      INSERT INTO ...
+      
+ + to + +
+      BEGIN;
+      LOCK TABLE ...
+      INSERT INTO ...
+      COMMIT;
+      
+ + Setting insert_lock to true, pgpool-II + automatically adds the above queries each time INSERT is + executed (if already in transaction, simply adds LOCK TABLE + ....). + + As of pgpool-II 2.2, it automatically detects if the table has a + SERIAL columns or not, so only tables having SERIAL columns are locked. + + Also you might want to make a fine control: +

+ +
    +
  1. set insert_lock to true, and add /*NO + INSERT LOCK*/ at the beginning of an INSERT + statement which you do not want to acquire the table + lock.
  2. + +
  3. set insert_lock to false, and add + /*INSERT LOCK*/ at the beginning of an INSERT + statement which you want to acquire the table lock.
  4. +
+ +

+ Default value is false. If insert_lock is enabled, + the regression test for PostgreSQL 8.0 will fail in transactions, + privileges, rules and alter_table. The reasons for this is that + pgpool-II tries to LOCK the VIEW for the rule test, and others will + produce the following error message. + +

+      ! ERROR: current transaction is aborted, commands ignored until
+      end of transaction block
+      
+ + For example, the transactions test tries to INSERT into a table +which does not exist, and pgpool-II causes PostgreSQL to acquire the +lock before that. The transaction will be aborted, and the following +INSERT statement produces the above error message.

+ + +
recovery_user +
+

+This parameter specifies a PostgreSQL username for online recovery. +It can be changed on service. +

+ +
recovery_password +
+

+This parameter specifies a PostgreSQL password for online recovery. +It can be changed on service. +

+ +
recovery_1st_stage_command +
+

+This parameter specifies a command at the first stage of online +recovery. The command file must be put on database cluster directory +because of a security issue. + +For example, if recovery_1st_stage_command = 'sync-command', then +pgpool-II executes $PGDATA/sync-command. + +Note that pgpool-II accepts connections and queries while +recovery_1st_stage command is executed. You can retrieve and update +data. +

+

+It can be changed on service. +

+ +
recovery_2nd_stage_command +
+

+This parameter specifies a command at the second stage of online +recovery. The command file must be put on database cluster directory +because of a security issue. + +For example, if recovery_2nd_stage_command = 'sync-command', then +pgpool-II executes $PGDATA/sync-command. + +Note that pgpool-II do not accept connections and queries while +recovery_2nd_stage_command is executed. Thus if a client exists for a +long time, the command is not executed. pgpool-II waits until all +clients close their connections. The command is executed when no client +connects to pgpool-II. +

+

+It can be changed on service. +

+ +
recovery_timeout +
+

+pgpool does not accept connections at second stage. If a client +connect to pgpool during recovery processing, pgpool wait to be +close. +

+

+This parameter specifies recovery timeout in sec. If timeout, pgpool +cancels online recovery and accepts connections. 0 means no wait. +

+

+It can be changed on service. +

+ +
client_idle_limit_in_recovery +
+

Similar to client_idle_limit but only takes effect in recovery 2nd + stage. Disconnect the connection to a client being idle for + client_idle_limit_in_recovery seconds since the last query has + been sent. This is usefull for preventing for pgpool recovery + disturbed by a lazy client or TCP/IP connection between client and + pgpool is accidentally down. The default value for + client_idle_limit_in_recovery is 0, which means the functionality is turned + off. You need to reload pgpool.conf if you change + client_idle_limit_in_recovery.

+ +
+ +

condition for load balance

+

+For the query to be load balanced, all the requirements below + must be met: +

    +
  • PostgreSQL version 7.4 or later
  • +
  • the query must not be in an explicitly declared + transaction (i.e. not in a BEGIN ~ END block)
  • +
  • it's not SELECT nextval or SELECT setval +
  • it's not SELECT INTO +
  • it's not SELECT FOR UPDATE nor FOR SHARE +
  • start with "SELECT" (ignore_leading_white_space = true will + ignore leading white space) or one of COPY TO STDOUT, DECLARE..SELECT, FETCH, CLOSE +
+

+

+Note that you could supress load balancing by inserting arbitary +comments just in front of the SELECT query: +

+  /*REPLICATION*/ SELECT ...
+
+

+ +

+Please refer to replicate_select as well. +See also a flow chart. +

+ +

+ +Note: JDBC driver has autocommit option. If autocommit is false, JDBC driver +send "BEGIN" and "COMMIT" internally. So pgpool cannot load balancing. +You need to call setAutoCommit(true) to enable autocommit. + +

+ +

Failover in the Replication Mode

+ +

pgpool-II degenerates a dead backend and continues the +service. The service can be continued if there is at least one backend +alive.

+ +

Master/Slave Mode

+ +

This mode is for using pgpool-II with another master/slave +replication software (like Slony-I), so it really does the actual data +replication. DB nodes' information must be set as the replication mode. +In addtion to that, set +master_slave_mode and load_balance_mode to +true. pgpool-II will send queries that need to be replicated to the +Master DB, and others will be load balanced if possible.

+ +

In the master/slave mode, replication_mode must be set +to false, and master_slave_mode to true.

+ +

Parallel Mode

+ +

This mode enables parallel execution of queries.The table is divided, and data can be given to each node. Moreover, the replication and the loadbalance function can be used at the same time. In parallel mode, replication_mode and loadbalance_mode are set to true in pgpool.conf, master_slave is set to false, and parallel_mode is set to true. When you change this parameter, please reactivate pgpool-II. +

+ +

Configuring the System DB

+ +

To use the parallel mode, the System DB must be configured +properly. The System DB maintains rules, in the format of the database +table, to choose an appropriate backend to send partitioned +data. The System DB does not need to be created on the same host as +pgpool-II. The System DB's configuration is done in +pgpool.conf.

+ +
+
system_db_hostname
+
+

The hostname where the System DB is created. Specifying the + empty string ('') means the System DB is at the same host as + pgpool-II, and will be connected via UNIX domain socket.

+
+ +
system_db_port
+
+

The port number for the System DB

+
+ +
system_dbname
+
+

The partitioning rules and other information will be defined + in the database specified here. Default value is + 'pgpool'.

+
+ +
system_db_schema
+
+

The partitioning rules and other information will be defined + in the schema specified here. Default value is + 'pgpool_catalog'.

+
+ +
system_db_user
+
+

The username to connect to the System DB.

+
+ +
system_db_password
+
+

The password for the System DB. If no password is set, + set the empty string ('').

+
+
+ +

Initial Configuration of the System DB

+ +

First, create the database and schema specified in the +pgpool.conf file. A sample script can be found in +$prefix/share/system_db.sql. If you have specified a +different database name or schema, change them accordingly. + +

+psql -f $prefix/share/system_db.sql pgpool
+
+ +

+ +

Registering a Partitioning Rule

+ +

The rules for data partitioning must be registered to +pgpool_catalog.dist_def table.

+ +
+CREATE TABLE pgpool_catalog.dist_def(
+dbname TEXT,                                              -- database name
+schema_name TEXT,                                         -- schema name
+table_name TEXT,                                          -- table name
+col_name TEXT NOT NULL CHECK (col_name = ANY (col_list)), -- partitioning key column name
+col_list TEXT[] NOT NULL,                                 -- names of table attributes
+type_list TEXT[] NOT NULL,                                -- types of table attributes
+dist_def_func TEXT NOT NULL,                              -- name of the partitioning rule function
+PRIMARY KEY (dbname,schema_name,table_name)
+);
+
+ + +

Registering a Replication Rule

+

+When the table that does the replication of one SQL sentence that specifies the table registered in the partitioning rule with JOIN etc. is specified, information on the table that does the replication is registered in the table named pgpool_catalog.replicate_def beforehand. +

+ +
+CREATE TABLE pgpool_catalog.replicate_def(
+	dbname TEXT,	    --database name
+	schema_name TEXT,	--schema name 
+	table_name TEXT,	--teble name
+	col_list TEXT[] NOT NULL,	-- names of table attributes
+	type_list TEXT[] NOT NULL,	-- types of table attributes
+	PRIMARY KEY (dbname,schema_name,table_name)
+);
+
+ +

Example for partitioning pgbench tables

+ +

+It divides into the accounts table in this example, and the replication will be done to the branches table and the tellers table. Moreover, the accounts table and the banches table assume uniting with bid The branches table registers the rule of the replication table. When three tables of the accounts table and the branches table and the tellers table are united, it is necessary to register the rule of the replication table to the tellers table beforehand. +

+
+INSERT INTO pgpool_catalog.dist_def VALUES (
+	'pgpool',
+	'public',
+	'accounts',
+	'aid',
+	ARRAY['aid','bid','abalance','filler'],
+	ARRAY['integer','integer','integer','character(84)'],
+	'pgpool_catalog.dist_def_accounts'
+);
+
+INSERT INTO pgpool_catalog.replicate_def VALUES (
+	'pgpool',
+	'public',
+	'branches',
+	ARRAY['bid','bbalance','filler'],
+	ARRAY['integer','integer','character(84)']
+);
+
+ +

The partitioning rule function (namely, +pgpool_catalog.dist_def_accounts) takes a value for the partitioning +key column, and returns the corresponding DB node ID. Note that ID +must start from 0. Below is the example of each function for pgbench. +

+
+CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_accounts (val ANYELEMENT) RETURNS INTEGER AS '
+SELECT CASE WHEN $1 >= 1 and $1 <= 30000 THEN 0
+WHEN $1 > 30000 and $1 <= 60000 THEN 1
+ELSE 2
+
+ +

Setting up pool_hba.conf for client authentication (HBA)

+

+ Just like pg_hba.conf with PostgreSQL, pgpool supports a similar + client authentication function using a configuration file called + "pool_hba.conf". +

+

+ When you install pgpool, pool_hba.conf.sample will be installed in + "/usr/local/etc", which is the default directory for configuration + files. Copy pool_hba.conf.sample as pool_hba.conf and edit it if necessary. + By default, pool_hba authentication is enabled. See "6. Setting up + pgpool.conf" for more detail. +

+

+ The format of pool_hba.conf file follows very closely pg_hba.conf's format. +

+
+    local      DATABASE  USER  METHOD  [OPTION]
+    host       DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
+
+

+ See "pool_hba.conf.sample" for details of each field. +

+

+ Here are the limitations of pool_hba. +

    +
  • "hostssl" connection type is not supported
  • +

    + "hostssl" is invalid since pgpool currently does not support SSL + connections. +

    +
  • "samegroup" for DATABASE field is not supported
  • +

    + Since pgpool does not know anything about users in the backend server, + database name is simply checked against the entries in the DATABASE + field of pool_hba.conf. +

    +
  • group names following "+" for USER field is not supported
  • +

    + This is the same reason as in the "samegroup" described above. A + user name is simply checked against the entries in the USER field + of pool_hba.conf. +

    +
  • IPv6 for IP address/mask is not supported
  • +

    + pgpool currently does not support IPv6. +

    +
  • Only "trust", "reject" and "pam" for METHOD field are supported
  • +

    + Again, this is the same reason as in the "samegroup" described above. + pgpool does not hold user/password information. +

    +
+

+ Note that everything described in this section is about a client + authentication between a client and pgpool; a client still have to go through + an authentication process with PostgreSQL. As far as pool_hba is concerned, + it does not matter if a user name and/or database name given by a client + (i.e. psql -U testuser testdb) really exist in the backend. pool_hba only + cares if a match in the pool_hba.conf is found or not. +

+

+ PAM authentication is supported using user information on the host where + pgpool is executed. To enable PAM support in pgpool, specify "--with-pam" + option to configure: +

+
+    configure --with-pam
+
+

+ To enable PAM authentication, you need to create a + service-configuration file for pgpool in the system's PAM + configuration directory (which is usually at "/etc/pam.d"). A sample + service-configuration file is installed as "share/pgpool.pam" under + the install directory. +

+ +

Setting method of Query cache

+

The Query cache can be used in all modes in pgpool-II. The setting of pgpool.conf is set as follows.

+
+enable_query_cache = true
+
+ +

+Moreover, please make the following tables in the System DB. +

+
+CREATE TABLE pgpool_catalog.query_cache (
+  hash TEXT,
+  query TEXT,
+  value bytea,
+  dbname TEXT,
+  create_time TIMESTAMP WITH TIME ZONE,
+  PRIMARY KEY(hash, dbname)
+);
+
+

+However, please rewrite it suitably when you use a different schema because the schema name is "pgpool_catalog" in this example. +

+ +

Starting/Stopping pgpool-II

+ +

All the backends and the System DB (if necessary) must be started +before starting pgpool-II. +

+ +
+pgpool [-c][-f config_file][-a hba_file][-F pcp_config_file][-n][-d]
+
+

+ + + + + + + +
-cdeletes query cache
-f config_filespecifies pgpool.conf
-a hba_filespecifies pool_hba.conf
-F pcp_config_filespecifies pcp.conf
-nno daemon mode (terminal is not detached)
-ddebug mode
+There are two ways to stop pgpool-II. One is via PCP command +(described later) or pgpool-II command. Below is an example of the +pgpool-II command. +

+ +
+pgpool [-f config_file][-F pcp_config_file] [-m {s[mart]|f[ast]|i[mmediate]}] stop
+
+

+ + + +
-m s[mart]waits for clients to + disconnect, and shutdown (default)
-m f[ast]does not wait for clients; + shutdown immediately
-m i[mmediate]the same as '-m + f'
+

+ +

Reloading pgpool-II configuration files

+

pgpool-II can reload configuration files without restarting it. +

+ +
+pgpool [-c][-f config_file][-a hba_file][-F pcp_config_file] reload
+
+

+ + + + +
-f config_file
--config-file config-file
specifies pgpool.conf
-a hba_file
--hba-file hba_file
specifies pool_hba.conf
-F pcp_config_file
--pcp-password-file
specifies pcp.conf
+ +

+Please note that some configuration items are not changed with +relaoding. Also configuration reflects its changes after new session starts. +

+ +

Online Recovery

+

Overview

+

+pgpool-II, with replication mode, can sync database and attach a node +in service. We call that "online recovery". +

+ +

+A recovery target node must have detached before doing online recovery. + +If you wish to add PostgreSQL server dynamically, add backend_hostname etc. +parameters and reload pgpool.conf. pgpool-II registers a new node as a +detached node. +

+ +

+caution: Stop autovacuum on the master node (the +first node which is up and running). Autovacuum may change the contents +of the database and might cause inconsistency after online recovery if +it's runnung. +

+ +

+ If PostgreSQL have already started, you need to shutdown PostgreSQL + process. +

+ +

+pgpool-II performs online recovery in separated two phase. It has a few seconds +or minutes client wait connecting to pgpool-II while a recovery +node synchronizes database. It follows these steps: + +

    +
  1. CHECKPOINT +
  2. First stage of online recovery +
  3. Waiting until all clients have disconnected +
  4. CHECKPOINT +
  5. Second stage of online recovery +
  6. Starting up postmaster (perform pgpool_remote_start) +
  7. Node attaching +
+

+ +

+ We call the first step of data sync "first stage". We synchronize + data in the first stage. In the first stage, you can update or + retrieve all tables concurrently. +

+ +

+ You can specify a script executed at the first stage. pgpool-II + passes three arguments to the script. + +

    +
  1. Database cluster path of a master node. +
  2. Hostname of a recovery target node. +
  3. Database cluster path of a recovery target node. +
+

+ +

+ We synchronize data. We call it "second + stage". Before entering the second stage, pgpool-II waits until all + clients have disconnected. It blocks any connection until finishing + the second stage. + + After all connections are disconnected, merge updated data between + the first stage and the second stage. We perform final data + synchronization. +

+ +

+ + Note that there is a restriction about online recovery. If pgpool-II + works on multiple hosts, online recovery does not work + correctly, because pgpool-II stops clients on the 2nd stage of online + recovery. If there are some pgpool hosts, pgpool-II excepted for + receiving online recovery request cannot block connections. + +

+ +

Configuration for online recovery

+

+Set the following parameters for online recovery in pgpool.conf. + +

    +
  • backend_data_directory +
  • recovery_user +
  • recovery_password +
  • recovery_1st_stage_command +
  • recovery_2nd_stage_command +
+

+ + +

Installation of C language function

+

+You need to install the C language function for online recovery to +"template1" database of all backend nodes. + +Source code is in pgpool-II tar ball. +

+ +
+  pgpool-II-x.x.x/sql/pgpool-recovery/
+
+ +

+Change the directory and do "make install". +

+ +
+  % cd pgpool-II-x.x.x/sql/pgpool-recovery/
+  % make install
+
+ +

+Then, install SQL function. +

+ +
+  % cd pgpool-II-x.x.x/sql/pgpool-recovery/
+  % psql -f pgpool-recovery.sql template1
+
+ + +

Recovery script deployment

+

+We must deploy data sync scripts and a remote start script into +database cluster($PGDATA). Sample script files are available in +pgpool-II-x.x.x/sample directory. +

+ +

Online recovery by PITR

+

+We explain how to do online recovery by Point In Time Recovery(PITR). +Note that all PostgreSQL servers need to enable PITR. +

+ +

+We prepare a script to get base backup on a master node and copy to +recovery target node on the first stage. The script is named +"copy-base-backup" for example. Here is the sample script. + +

+ +
+  #! /bin/sh
+  DATA=$1
+  RECOVERY_TARGET=$2
+  RECOVERY_DATA=$3
+
+  psql -c "select pg_start_backup('pgpool-recovery')" postgres
+  echo "restore_command = 'scp $HOSTNAME:/data/archive_log/%f %p'" > /data/recovery.conf
+  tar -C /data -zcf pgsql.tar.gz pgsql
+  psql -c 'select pg_stop_backup()' postgres
+  scp pgsql.tar.gz $RECOVERY_TARGET:$RECOVERY_DATA
+
+ +

+The script generates the following recovery.conf. +

+
+restore_command = 'scp master:/data/archive_log/%f %p'
+
+ +

+ +

+Then, we prepare a script to switch XLOG on the second stage. +We deploy these scripts into $PGDATA. +

+ +
+  #! /bin/sh
+  psql -c 'select pg_switch_xlog()' postgres
+
+ +

+Finally, we edit pgpool.conf. + +

+recovery_1st_stage_command = 'copy-base-backup'
+recovery_2nd_stage_command = 'pgpool_recovery_pitr'
+
+ +

+ +

+We have finished preparing online recovery by PITR. +

+ +

pgpool_remote_start

+

+The script is to start up postmaster process from remote host. +pgpool-II executes as the following way. +

+ +
+  % pgpool_remote_start remote_host remote_datadir
+  remote_host:    Hostname of a recovery target.
+  remote_datadir: Database cluster path of a recovery target.
+
+ +

+In the sample script, we start up postmaster process over ssh. +So you need to connect over ssh without pass . +

+ +

+If you recover with PITR, you need to expand a base backup. Then, +postmaster automatically starts up with PITR. Then it accepts +connections. +

+ +
+#! /bin/sh
+DEST=$1
+DESTDIR=$2
+PGCTL=/usr/local/pgsql/bin/pg_ctl
+
+# Expand a base backup
+ssh -T $DEST 'cd /data/; tar zxf pgsql.tar.gz' 2>/dev/null 1>/dev/null < /dev/null
+# Startup PostgreSQL server
+ssh -T $DEST $PGCTL -w -D $DESTDIR start 2>/dev/null 1>/dev/null < /dev/null &
+
+ +

Online recovery with rsync.

+

+PostgreSQL 7.4 does not have PITR. So we use rsync to do online +recovery. In "sample" directory of pgpool-II tar ball, +there is a recovery script named "pgpool_recovery". It uses rsync +command. pgpool-II calls the script with three arguments. +

+ +
+  % pgpool_recovery datadir remote_host remote_datadir
+  datadir:        Database cluster path of a master node.
+  remote_host:    Hostname of a recovery target node.
+  remote_datadir: Database cluster path of a recovery target node.
+
+ +

+The script copy physical file with rsync over ssh. So you need to +connect over ssh without pass . +

+ +

+Note of rsync: +

    + +
  • -z (or --compress) option does compression before transmitting + data. This will be great for slower connection, but it might be a + CPU overhead for a 100M or faster connectons. In this case you + might want not to use the option. + +
  • The latest version rsync 3.0.5 has great speed performance + improvements (50% faster according to a report from pgpool-general + mailing list. +
+ +

+ +

+If you use pgpool_recovery, add the following lines into pgpool.conf. + +

+recovery_1st_stage_command = 'pgpool_recovery'
+recovery_2nd_stage_command = 'pgpool_recovery'
+
+

+ +

How to perform online recovery

+

+For doing online recovery, you use pcp_recovery_node command or +operate on pgpoolAdmin. +

+ +

+Note that you need to pass a greater number to the first argument of +pcp_recovery_node. It is a timeout parameter. If you use pgpoolAdmin, +set "_PGPOOL2_PCP_TIMEOUT " parameter to a greater number in +pgmgt.conf.php. +

+ + +

Restrictions

+

+

Authentication / Access Controls

+ +

+

    +
  • In the replication mode or master/slave mode, trust, clear text + password, pam methods are supported.
  • +
  • In all the other modes, trust, clear text password, crypt, md5, + pam methods are supported.
  • +
  • pgpool-II does not support pg_hba.conf-like access controls. If + the TCP/IP connection is enabled, pgpool-II accepts all the + connections from any host. If needed, use iptables and such to + control access from other hosts. (PostgreSQL server accepting + pgpool-II connections can use pg_hba.conf, of course).
  • +
+

+ +

Functions, etc. In Replication Mode

+ +

There is no guarantee that the data, which returns different values +each time even though the same query was executed (e.g. random number, +transaction ID, OID, SERIAL, sequence, CURRENT_TIMESTAMP), will be +replicated correctly on multiple backends.

+ +

Tables created by CREATE TEMP TABLE will not be +deleted after exitting a session. It is because of the connection +pooling which, from the backend's point of view, seems that the +session is still alive. To avoid this, you must explicitly drop the +temporary tables by DROP TABLE, or use CREATE TEMP +TABLE ... ON COMMIT DROP inside the transaction block.

+ +

Queries

+ +

Here are the queries which cannot be processed by pgpool-II

+ +

INSERT (for parallel mode)

+ +

You cannot use DEFAULT with the +partitioning key column. For example, if the column x in the table t +was the partitioning key column, + +

+INSERT INTO t(x) VALUES (DEFAULT);
+
+

+is invalid. Also, functions cannot be used as the value either. +

+ +
+INSERT INTO t(x) VALUES (func());
+
+

+Constant values must be used to INSERT with the partitioning +key. SELECT INTO and INSERT INTO ... SELECT +are also not supported. +

+ +

UPDATE (for parallel mode)

+ +

Data consistency between the backends may be lost if the +partitioning key column values are updated. pgpool-II does not +re-partition the updated data.

+ +

A transaction cannot be rolled back if a query has caused an error +on some backends due to the constraint violation.

+ +

If a function is called in the WHERE clause, that +query might not be executed correctly. +

+e.g.)  UPDATE branches set bid = 100 where bid = (select max(bid) from beances);
+
+

+ +

SELECT ... FOR UPDATE (for parallel mode)

+ +

If a function is called in the WHERE clause, that +query might not be executed correctly. +

+e.g.)  SELECT * FROM  branches where bid = (select max(bid) from beances) FOR UPDATE;
+
+

+ +

COPY (for parallel mode)

+ +

COPY BINARY is not supported. Copying from files are +also not supported. Only COPY FROM STDIN and COPY +TO STDOUT are supported.

+ +

ALTER/CREATE TABLE (for parallel mode)

+ +

To update the partitioning rule, pgpool-II must be restarted in +order to read them from the System DB.

+ +

Transaction (for parallel mode)

+ +

SELECT statements executed inside a transaction block +will be executed in the separate transaction. Here is an example: + +

+BEGIN;
+INSERT INTO t(a) VALUES (1);
+SELECT * FROM t ORDER BY a; <-- INSERT above is not visible from this SELECT statement
+END;
+
+ +

Views / Rules (for parallel mode)

+ +

+The same definition will be created on all the backends for views and rules. +

+ +
+SELECT * FROM a, b where a.i = b.i
+
+

+JOINs like above will be executed within one backend, and +then merged with the results returned by each backend. Views and Rules +that joins across the nodes cannot be created. +However, to JOIN tables that divide data only in the same node, VIEW can be made. +VIEW is registered in the pgpool_catalog.dist_def table. Moreover, please register +a col_name and a dist_def_func. These are used when Insert for View was used. +

+ +

Functions / Triggers (for parallel mode)

+ +

The same definition will be created on all the backends for +functions. Joins across the nodes, and data on the other nodes cannot +be manipulated inside the functions.

+ +

Extended Query Protocol (for parallel mode)

+ +

The extended query protocol used by JDBC drivers, etc. is not +supported. The simple query protocol must be used.

+ +

Natural Join (for parallel mode)

+ +

The Natural Join is not supported. + "ON join condition" or "USING (join_column)" must be needed.

+ +

USING CLAUSE (for parallel mode)

+ +

The USING CLAUSE is converted to ON CLAUSE by query rewrite process. + Therefore, when "*" is used at target list, the row of the same column name appears.

+ +

Multi-byte Characters (for all modes)

+ +

pgpool-II does not translate between different multi-byte +characters. The encoding for the client, backend and System DB must be +the same.

+ +

Multi-statement Query (for all modes)

+

+pgpool-II cannot process multi-statement query. +

+ +

Deadlocks (for parallel mode)

+ +

Deadlocks across the backends cannot be detected. For example: +

+
+(tellers table is partitioned using the following rule)
+  tid <= 10  --> node 0
+  tid >= 10  --> node 1
+
+A) BEGIN;
+B) BEGIN;
+A) SELECT * FROM tellers WHERE tid = 11 FOR UPDATE;
+B) SELECT * FROM tellers WHERE tid = 1 FOR UPDATE;
+A) SELECT * FROM tellers WHERE tid = 1 FOR UPDATE;
+B) SELECT * FROM tellers WHERE tid = 11 FOR UPDATE;
+
+

+In the case above, a single node cannot detect the deadlock, so +pgpool-II will still wait for the response. This phenomenon +occurs with other queries that acquire row level locks. +

+

Also, if a deadlock occurs in one node, transaction states in each +node will not be consistent. Therefore, pgpool-II terminates the +process if a deadlock is detected. +

+
+pool_read_kind: kind does not match between master(84) slot[1] (69)
+
+ +

Schemas (for parallel mode)

+ +

Objects in a schema other than public must be fully qualified like: +

+
+schema.object
+
+

+pgpool-II cannot resolve the correct schema when the path was set as +follows: +

+
+set search_path = xxx
+
+

+and the schema name was omitted in a query. +

+

table name - column name(for parallel mode)

+

+Limitation object:Parallel mode +

+

+A table or a column name cannot starts by pool_. +When rewriting the query, the name is used by internal processing. +

+ +

+

System DB

+ +

Partitioning Rules

+ +

Only one (1) partitioning key column can be defined in one +partitioning rule. Conditions like 'x or y' are not supported.

+ +

Environment Requirements

+ +

libpq

+ +

libpq is linked while building pgpool-II. libpq +version must be 3.0. Building pgpool-II with libpq version 2.0 will +fail. Also, the System DB must be PostgreSQL 7.4 or later.

+ +

Query Cache

+ +

Currently, query cache must be deleted manually. pgpool-II does not +invalidate old query cache automatically when the data is updated.

+ +

Compatibility with pgpool

+ +

References

+

PCP Command Reference

+ +

PCP Command List

+ +

PCP commands are UNIX commands which manipulate pgpool-II via network. + +

+* pcp_node_count        - retrieves the number of nodes
+* pcp_node_info         - retrieves the node information
+* pcp_proc_count        - retrieves the process list
+* pcp_proc_info         - retrieves the process information
+* pcp_systemdb_info     - retrieves the System DB information
+* pcp_detach_node       - detaches a node from pgpool-II
+* pcp_attach_node       - attaches a node to pgpool-II
+* pcp_stop_pgpool       - stops pgpool-II
+
+

+ + +

Common Command-line Arguments

+ +

There are five arguments common to all of the PCP commands. They +give information about pgpool-II and authentication. Extra +arguments may be needed for some commands. + +

+e.g.)  $ pcp_node_count 10 localhost 9898 postgres hogehoge
+
+First argument    - timeout value in seconds. PCP disconnects if
+                    pgpool-II does not respond in so many seconds.
+Second argument   - pgpool-II's hostname
+Third argument    - pgpool-II's port number for PCP server
+Fourth argument   - PCP username
+Fifth argument    - PCP password
+
+ +

PCP usernames and passwords must use ones in the +pcp.conf in $prefix/etc +directory. -F option can be used when starting pgpool-II +if pcp.conf is placed somewhere else. The password does +not need to be in md5 format when passing it to the PCP commands.

+ + +

PCP Commands

+ +

All PCP commands display the results to the standard output.

+ + +

pcp_node_count

+ +
+Format:
+pcp_node_count  _timeout_  _host_  _port_  _userid_  _passwd_
+
+ +

+Displays the number of total nodes defined in pgpool.conf. It does +not distinguish nodes status, ie attached/detached. ALL nodes are counted. +

+ + +

pcp_node_info

+ +
+Format:
+pcp_node_info  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
+
+ +

+Displays the information on the given node ID. The output example is +as follows: +

+ +
+$ pcp_node_info 10 localhost 9898 postgres hogehoge 0
+host1 5432 1 1073741823.500000
+
+The result is in the following order:
+1. hostname
+2. port number
+3. status
+4. load balance weight
+
+Status is represented by a digit from [0 to 3].
+0 - This state is only used during the initialization. PCP will never display it.
+1 - Node is up. No connections yet.
+2 - Node is up. Connections are pooled.
+3 - Node is down.
+
+

+The load balance weight is displayed in normalized format. +

+ +

Specifying an invalid node ID will result in an error with exit +status 12, and BackendError will be displayed.

+ +

pcp_proc_count

+

+

+Format:
+pcp_proc_count  _timeout_  _host_  _port_  _userid_  _passwd_
+
+

+Displays the list of pgpool-II child process IDs. If there is more than +one process, IDs will be delimitted by a white space. +

+

pcp_proc_info

+

+

+Format:
+pcp_proc_info  _timeout_  _host_  _port_  _userid_  _passwd_  _processid_
+
+

+Displays the information on the given pgpool-II child process ID. The +output example is as follows: +

+
+$ pcp_proc_info 10 localhost 9898 postgres hogehoge 3815
+postgres_db postgres 1150769932 1150767351 3 0 1
+
+The result is in the following order:
+1. connected database name
+2. connected username
+3. process start-up timestamp
+4. connection created timestamp
+5. protocol major version
+6. protocol minor version
+7. connection-reuse counter
+
+

+If there is no connection to the backends, nothing will be +displayed. If there are multiple connections, one connection's +information will be displayed on each line multiple +times. Timestamps are displayed in EPOCH format. +

+ +

Specifying an invalid node ID will result in an error with exit +status 12, and BackendError will be displayed.

+ +

pcp_systemdb_info

+

+

+Format:
+pcp_systemdb_info  _timeout_  _host_  _port_  _userid_  _passwd_
+
+

+Displays the System DB information. The output example is as follows: +

+
+$ pcp_systemdb_info 10 localhost 9898 postgres hogehoge
+localhost 5432 yamaguti '' pgpool_catalog pgpool 3
+yamaguti public accounts aid 4 aid bid abalance filler integer integer integer character(84) dist_def_accounts
+yamaguti public branches bid 3 bid bbalance filler integer integer character(84) dist_def_branches
+yamaguti public tellers bid 4 tid bid tbalance filler integer integer integer character(84) dist_def_tellers
+
+First, the System DB information will be displayed on the first
+line. The result is in the following order:
+1. hostname
+2. port number
+3. username
+4. password. '' for no password.
+5. schema name
+6. database name
+7. number of partioning rules defined
+
+

+Second, partioning rules will be displayed on the following lines. If +there are multiple definitions, one definition will be displayed on +each line multiple times. The result is in the following order: +

+
+1. targeted partitioning database name
+2. targeted partitioning schema name
+3. targeted partitioning table name
+4. partitioning key column name
+5. number of columns in the targeted table
+6. column names (displayed as many as said in 5.)
+7. column types (displayed as many as said in 5.)
+8. partitioning rule function name
+
+

+If the System DB is not defined (i.e. not in pgpool-II mode, and query +cache is disabled), it results in error with exit status 12, and +BackendError will be displayed.

+ + +

pcp_detach_node

+
+Format:
+pcp_detach_node  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
+
+

+Detaches the given node from pgpool-II. +

+ + +

pcp_attach_node

+

+

+Format:
+pcp_attach_node  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
+
+Attaches the given node to pgpool-II.
+
+

+ +

pcp_stop_pgpool

+
+Format:
+pcp_stop_pgpool  _timeout_  _host_  _port_  _userid_  _passwd_  _mode_
+
+ +

+Terminate pgpool-II process with the given shutdown mode. The availabe +modes are as follows: +

+ +
+s	- smart mode
+f	- fast mode
+i	- immediate mode
+
+

+If pgpool-II process does not exist, it results in error with exit +status 8, and ConnectionError will be displayed. +

+

+* Currently, there is no difference between the fast and immediate +mode. pgpool-II terminates all the processes wheter there are clients +connected to the backends.

+ + +

Exit Status

+ +

PCP command exits with status 0 when everything goes well. If any +error had occured, it will exit with the following error status. + +

+UNKNOWNERR      1      Unknown Error (should not occur)
+EOFERR          2      EOF Error
+NOMEMERR        3      Memory shortage
+READERR         4      Error while reading from the server
+WRITEERR        5      Error while writing to the server
+TIMEOUTERR      6      Timeout
+INVALERR        7      Argument(s) to the PCP command was invalid
+CONNERR         8      Server connection error
+NOCONNERR       9      No connection exists
+SOCKERR         10     Socket error
+HOSTERR         11     Hostname resolution error
+BACKENDERR      12     PCP process error on the server (specifying an invalid ID, etc.)
+AUTHERR         13     Authorization failure
+
+

+ +

Inside information

+

+On The pgpool-II version 2.0.x, Extensive modifications are added compared with the version 1.x +Please note incompatibility with information on the version 1.x. +

+ +

Parallel execution engine

+

+The parallel execution engine is built into pgpool-II. +This engine inquires same Query as each node, and indicates the engine that transmits the result to the front end in order of the response of the node. +

+ +

Query Rewriting

+

+It explains the Query rewriting that pgpool-II does in a parallel mode. +

+

+In a parallel mode, the inquiry of the retrieval system (SELECT processing) that the client transmitted is following it divided roughly Two processing is done. +

+
+Analysis of Query
+Rewriting of Query
+
+

+I will sequentially explain these two processing. +

+

Analysis of Query

+

Introduction

+

+The inquiry of the retrieval system that the client transmitted analyzes Query +based on information registered in system DB after SQL parser is passed. It +evaluates it to the analysis of Query by the transition of the execution status. +The execution status is the one that the set of a certain data acquires where or +it is treatable is judged here. For instance, because data is divided as for +the entire data sets of tables registered in the pgpool_catalog.dist_def table, +it is necessary to acquire it from all nodes. Oppositely, the entire data sets +of tables registered in the pgpool_catalog.replicate_def table are enough if +it does not acquire from all nodes but it acquires it from either of the +nodes. The state that should be processed here by all nodes The state of +P and the state that should be processed by one node It defines it as a +state of L. As special ..another.. There is a state of S. This shows +the state when processing it to all data acquired from all nodes. For +instance, the sorting application. After data is acquired from all +nodes, it is necessary to execute the sorting application to the data of +the table registered in the pgpool_catalog.dist_def table. +

+ +

+Retrieval system Query is analyzed in the following order of +processing, and the execution status changes. In the process to which +the execution status changes the following processing : as for the state +of S It enters the state of S. Also whether it is processed with DB +where is decided by the state of the final execution status of the last +SELECT. +

+ +
    +
  1. Whether UNION, EXTRACT, and INTERCECT are used or not? +
  2. Execution status of FROM Clause +
  3. Change in execution status by TARGETLIST +
  4. Change in execution status accouding to WHERE Clause +
  5. Change in execution status according to GROUP BY Clause +
  6. Change in execution status according to HAVING Clause +
  7. Change in execution status according to ORDER BY Clause +
  8. It changes into the LIMIT OFFSET predicate in the execution status. +
  9. Acquisition of the final execution status of SELECT +
+ +

+The relation between the final execution status of SELECT and the processed place is as follows. +

+ +

+ + + + + +
Execution statusProcessed place
LIt inquires of either of node.
PIt returns it to the client through all the same node inquiries and a parallel execution engines.
SAfter it processes it with system DB, it returns it to the client.
+

+ +

+Moreover, the above-mentioned rule adjusts to Sub-Query. In simple following Query, When p1-table is registered in pgpool_catalog.dist_def table of system DB, that is, when data is divided, the final execution status of Sub-Query : It becomes P, and call origin of Sub-Query as a result Execution status of SELECT also : It becomes P +

+ +
+SELECT * FROM (SELECT * FROM P1-table) as P2-table;
+
+ +

+Next, it explains how the execution status changes concretely. Two first of all. It explains from the execution status of the From . +

+ +

Execution status of FROM Clause

+

+Retrieval system Query (SELECT) The set of data is defined according to the FROMCluase. ..the state of P and the state of L.. The state of S is taken. The execution status of the table : simply when the table specified for the FROM Clause is one It becomes the execution status of the entire data set composed of the FROM Cluase. The execution status is decided according to the JOIN method as follows when there is two or more tables or Sub-Query in the FROM Clause. +

+ +

+ + + + + + + + + + + +
JOIN type LEFT OUTER JOIN RIGHT OUTER JOIN FULL OUTER JOIN$B!!!!!!(Bothers$B!!!!!!(B
left$B!@(Bright P L S P L S P L S P L S
P S P S S S S S S S S P S
L S L S P L S S L S P L S
S S S S S S S S S S S S S
+

+ +

+In the following examples, P1-table with the table in the state of P : +L1-table and L2-table : It is assumed that the table in the state of L. + +P1-table (left) and L1-table (right) according to the above-mentioned table then JOIN : In addition ..entering the state of P.., With the state of P L2-table in the state of L joins and the execution status of the FROM Clause It enters the state of P. +

+ +
+SELECT * FROM P1-table,L1-table,L2-table;
+
+ +

Change in execution status by TARGETLIST and Where Clause

+

+In a basic Query, the same execution status as the FROM Clause is succeeded to. However, with TARGETLIST, te execution status of the WHERE Clause changes in the following cases. +

+
    +
  1. When there is a subQuery +
  2. The FROM Clause When and, there are an aggregate function and DISTINCT in TARGETLIST for P +
  3. When the column that does not exist in the table (data set) + defined by the FROM Clause is used +
+

+The final execution status of the subQuery The execution status of TARGETLIST and the WHERE Clause enters the state of S for the state of P or S. In the following example, when the table used by the subQuery is P, the final execution status of the subQuery : It enters the state of P. Therefore, The execution status of the WHERE Clause : without depending on the execution status of L1-table It enters the state of S, and the execution place of this Query becomes system DB. +

+
+	SELECT * FROM L1-table where L1-table.column IN (SELECT * FROM P1-table);
+
+

+The FROM Clause It changes in the state of S to have to total it after data is acquired when and, there is an aggregate function in TARGETLIST for P. Moreover, optimization by the aggregate function is done under a specific condition. +

+

+The column that does not exist in the table and the subQuery defined by the FROM Clause might be used for the WHERE Clause. This is generated in following correlation Sub-Query. +

+
+	SELECT * FROM L1-table FROM L1-table.col1 IN (SELECT * FROM P1-table WHERE P1-table.col = L1-table.col1);
+
+

+It is used for the above-mentioned Sub-Query External refer to L1-table for L1-table.col1. The execution status of the WHERE Clause of the Sub-Query : in this case It enters the state of S. +

+

Change in execution status by GROUP BY, HAVING, ORDER BY and LIMIT OFFSET

+ +

+The execution status of the WHERE Clause It changes in the state of S when there are GROUP BY, HAVING Clause, and ORDER BY Clause and LIMIT OFFSET predicate for P. The Query where the GROUP BY Clause does not exist succeeds to the execution status of the WHERE Clause. Moreover, the execution status of the GROUP BY Clause is succeeded to when there is no HAVING Clause. The ORDER BY Clause and the LIMIT OFFSET predicate are also similar. +

+ +

When UNION, EXTRACT, and INTERSECT are used

+

+The Query that UNION, EXTRAT, and INTERSECT use depends on the final execution status of a left SELECT sentence and right SELECT sentence. The final execution status of a left, right SELECT sentence both : It enters the state of L at the state of L. Moreover, the final execution status of a left, right SELECT sentence both : For the state of P and UNION ALL It enters the state of P. It enters the state of S for other combinations. +

+

Acquisition of the final execution status of SELECT

+

+Everything the execution status Everything ..the state of L.. for L It enters the state of P for P. Besides, it enters the state of S. The load is distributed when loadbalance_mode of pgpool.conf is true for L, and it inquires of MASTER besides. Moreover, the parallel processing is done for P with a parallel execution engine. The Query rewriting at S that is the following phase is done. +

+ +

Query rewriting

+

+The Query is rewritten by using the execution status acquired in an analyzing phase of the Query. As an example the state of P With P1-table the state of L It explains by the Query that uses L1-table. +

+
+SELECT P1-table.col, L1-table.col FROM P1-table,L1-table where P1-table.col = L1-table.col order by P1-table.col;
+
+ +

+In this Query Because there is ORDER BY Clause It enters the state of S, and the FROM Clause, the WHERE Clause, and TARGETLIST : It enters the state of P. It is rewritten in such a Query as follows. +

+ +
+SELECT P1-table.col, L1-table.col FROM
+	dblink(select pool_parallel(SELECT P1-table.col, L1-table.col FROM P1-table,L1-table where P1-table.col = L1-table.col)) 
+  	order by P1-table.col;
+
+

+the dblink transmits the inquiry to pgpool-II here. Moreover, pool_parallel is the function which send the Query of arguments to the parallel execution engine. The above-mentioned is an image to the end and no actually executable Query. +

+

+The FROM Clause, the WHERE Clause, and TARGETLIST all : like the above-mentioned example The parallel processing is done bringing the FROM Clause, the WHERE Clause, and TARGETLIST together for P. +

+

+The following example is seen. +

+ +
+SELECT L1-table.col FROM L1-table WHERE L1-table.col % 2 = 0 AND L1-table.col IN (SELECT P1-table FROM P1-table) ;
+
+ +

+In this example, the FROM Clause : The state of L and TARGETLIST also : The state of L and the WHERE Clause : Because it has the subQuery in the state of P It enters the state of S. As for this, rewriting is done as follows. +

+
+	SELECT L1-table.col FROM dblink(SELECT loadbalance(SELECT L1-table.col FROM L1-table WHERE L1-table.col % 2 = 0 AND TRUE))
+		WHERE
+			L1-table.col %2 = 0 AND 
+		  L1-table.col IN 
+		  (
+		  	SELECT P1-Table FROM 
+		  	dblink(select pool_parallel(SELECT P1-table FROM P1-table))
+		  ) ;
+
+

+Here, pool_loadbalance is a function that transmits Queries to either of node. +

+ +

Query rewriting by aggregate functions

+

+As for the totaled Query (aggregate function and GROUP BY), it calculates, and the decreasing performance also improves the load of system DB to each node by recounting it with system DB. +

+

+First of all, rewriting the Query that pgpool-II actually does first is seen. +

+

+The Query which have state P in FROM Clause and count(*) in TARGETLIST, The Rewriting Query is done as follows +

+
+  select count(*) from P1-table;
+
+	-> rewrite
+
+    SELECT 
+        sum(pool_c$1) as count 
+    FROM 
+        dblink(select pool_parallel('select count(*) from  P1-table'))
+					AS pool_$1g (pool_c$1 bigint); 
+
+

+The condition that the Query rewriting like the above-mentioned is done is the following. +

+
    +
  1. The FROM Clause is in the state of P. +
  2. The column specified for the aggregate function (Only count, sum, min, max, and avg correspond) and GROUP BY is used for the target list. +
  3. The WHERE Clause is in the state of P. +
  4. Only the column defined by the aggregate function (Only count, sum, min, max, and avg correspond) used for the HAVING Clause and the FROM Clause and the column specified for GROUP BY are used. +
+

Notes of parallel mode

+

+When the Query is analyzed, the column name and the type are needed in a parallel mode. Therefore, when the expression and the function are used for TARGETLIST of the subQuery, it is necessary to give the alias and the type name in Cast. Please note processing as the text type when there are no Cast of the type in the expression and the function. As for count, when the Query rewriting by the case of the aggregate function and consolidating is done, the bigint type and sum become numeric types. It is calculated as a date type when the argument is a date type for min and max, and, besides, it is calculated as numeric. Avg is processed as sum/count. +

+ +

About the performance of a parallel mode

+

The final execution status of SELECT and a rough standard of the performance are as follows. +

+

+ + + + + + +
Execution statusPerformance
LThere is no performance deterioration with a single purpose node excluding the overhead of pgpool-II because it does not use a parallel Query.
PThe parallel processing is done with high-speed, especially the sequential scanning. Moreover, it becomes easy to get on cash because the size of the table becomes small by dividing data.
SWhen the Query rewriting by aggregate functions is done, it is fast.
+

+ +

Tutorial

+

+A tutorial for pgpool-II is available. +

+ + + + diff --git a/doc/pgpool-ja.html b/doc/pgpool-ja.html new file mode 100644 index 0000000..82b604e --- /dev/null +++ b/doc/pgpool-ja.html @@ -0,0 +1,3119 @@ + + + + + +pgpool-II $B%f!<%6%^%K%e%"%k(B + + + + +Last modified: Sun Oct 4 18:13:38 JST 2009 + + + + + + + + + + + + + + + + +
Welcome to pgpool -II page
+
+ + +
+ +
+ + [English page]
+ + + +

pgpool-II$B$H$O(B

+

+pgpool-II$B$O(BPostgreSQL$B@lMQ$N%_%I%k%&%'%"$G!"(BPostgreSQL$B$N%G!<%?%Y!<%9%/%i%$%"%s%H$H(BPostgreSQL$B%5!<%P$N4V$K3d$j9~$`7A$GF0:n$7!"(BPostgrSQL$B$K0J2<$N$h$&$J5!G=$rDI2C$7$^$9!#(B +

+ +

+

    + +
  • $B%3%M%/%7%g%s%W!<%j%s%0(B +

    +PostgreSQL$B$X$N@\B3$rJ]B8$7$F$*$-!":FMxMQ$9$k$3$H$K$h$C$F(BPostgreSQL$B$X$N@\B3%*!<%P%X%C%I$rDc8:$G$-!"%7%9%F%`A4BN$N%9%k!<%W%C%H$r8~>e$5$;$k$3$H$,$G$-$^$9!#(B +

    + +
  • $B%l%W%j%1!<%7%g%s(B +

    +pgpool-II$B$OJ#?t$N(BPostgreSQL$B%5!<%P$r4IM}$9$k$3$H$,$G$-$^$9!#%l%W%j%1!<%7%g%s$r;HMQ$9$k$3$H$K$h$j!"J*M}E*$K(B2$BBf0J>e$N%G%#%9%/$K%j%"%k%?%$%`$G%O!<%I%G%#%9%/$N%P%C%/%"%C%W$rc32$,H/@8$7$F$b1?MQ$r7QB3$9$k$3$H$,$G$-$^$9!#(B +

    + +
  • $BIi2YJ,;6(B +

    +$B%l%W%j%1!<%7%g%s$r1?MQ$7$F$$$k>l9g!"$9$Y$F$N(BPostgreSQL$B%G!<%?%Y!<%9$NFbMF$,0lCW$7$F$$$k$N$G!"$I$N%5!<%P$KLd$$9g$o$;$F$bF1$87k2L$,JV$C$F$-$^$9!#$3$N$3$H$rMxMQ$7$F!"B??t$N%j%/%(%9%H$r$=$l$>$l$N%5!<%P$GJ,C4$7$FIi2Y$r7Z8:$5$;!"%7%9%F%`A4BN$N@-G=$r8~>e$5$;$k$3$H$,$G$-$^$9!#:GNI$N>l9g$K$O%5!<%PBf?t$KHfNc$7$?@-G=8~>e$,8+9~$a$^$9!#FC$KB??t$N%f!<%6$,BgNL$NLd$$9g$o$;$rEj$2$k$h$&$J4D6-$G0RNO$rH/4x$7$^$9!#(B +

    + +
  • $B@\B3?t$N@)8B(B +

    +PostgreSQL$B$K@\B32DG=$J%;%C%7%g%s?t$K$O8B3&$,$"$j!"$=$l$rD6$($F@\B3$9$k$3$H$O$G$-$^$;$s!#$+$H8@$C$F!"F1;~%;%C%7%g%s?t$r$`$d$_$KB?$/@_Dj$9$k$H!"%a%b%j!<$J$I$N%j%=!<%9$,B?$/>CHq$5$l$F%Q%U%)!<%^%s%9$K1F6A$,$"$j$^$9!#(Bpgpool-II$B$G$b%/%i%$%"%s%H$+$i$N@\B3?t$K$O>e8B$,$"$j$^$9$,!"$=$l$rD6$($F$b$?$@$A$K%(%i!<$K$J$k$3$H$O$J$/!"0lDj$N4VBT$?$5$l$k$h$&$K$J$C$F$$$^$9!#$7$?$,$C$F!"(Bpgpool-II$B$O(BPostgreSQL$B$X$N@\B3MW5a$r + +

  • $B%Q%i%l%k%/%(%j(B +

    +$BJ#?t$N%5!<%P$K%G!<%?$rJ,3d$7$F$l$N%5!<%P$KF1;~$K8!:wLd$$9g$o$;$rEj$2$F!"Ld$$9g$o$;$N=hM};~4V$rC;=L$9$k%Q%i%l%k%/%(%j$,MxMQ$G$-$^$9!#FC$KBg5,LO$J%G!<%?$r8!:w$9$k$H$-$K0RNO$rH/4x$7$^$9!#(B +

    + +
+

+ +

+pgpool-II$B$O(BPostgreSQL$B%P%C%/%(%s%I$H%U%m%s%H%(%s%I$NDL?.%W%m%H%3%k$rM}2r$7$F$=$N4V$rCf7Q$7$^$9!#$9$J$o$A!"(BPostgreSQL$B$N%G!<%?%Y!<%9%"%W%j%1!<%7%g%s$+$i$O(BPostgreSQL$B%5!<%P$K!"(BPostgreSQL$B$+$i$O%G!<%?%Y!<%9%"%W%j%1!<%7%g%s$K8+$($k$h$&$K@_7W$5$l$F$$$^$9!#$=$N$?$a!"(BPostgreSQL$B$=$N$b$N$O$b$A$m$s!"%"%W%j%1!<%7%g%s$N3+H/8@8l$K$h$i$:!"(BPostgreSQL$B$N%G!<%?%Y!<%9%"%W%j%1!<%7%g%s$K$[$H$s$I + +

pgpool-II$B$N2TF/4D6-(B

+

+pgpool-II$B$O!"(BLinux$B$r$O$8$a!"(BSolaris$B$d(BFreeBSD$B$J$I$N$[$H$s$I$N(BUNIX$B4D6-$GF0:n$7$^$9!#(BWindows$B$G$OF0$-$^$;$s!#BP1~$9$k(BPostgreSQL$B$N%P!<%8%g%s$O!"(BPostgreSQL$B$N(B6.4$B0J9_$G$9!#$?$@$7%Q%i%l%k%/%(%j%b!<%I$r;HMQ$9$k$H$-$O(BPostgreSQL 7.4$B0J9_$r$*;H$$$/$@$5$$!#(B +

+ +

pgpool-II$B$N%$%s%9%H!<%k(B

+ +

+pgpool-II $B$N%=!<%9%3!<%I$O(Bpgpool$B3+H/%Z!<%8(B +$B$+$i%@%&%s%m!<%I$G$-$^$9!#(B +

+ +

+pgpool-II$B$N%$%s%9%H!<%k$K$O!"(Bgcc 2.9$B0J>e!"$*$h$S(BGNU make$B$,I,MW$G$9!#(B +$B$^$?!"(Bpgpool-II$B$O(Blibpq(PostgreSQL$BIUB0$N%/%i%$%"%s%H%i%$%V%i%j(B)$B$r;HMQ$9$k$N$G!"%S%k%I$r9T$&%^%7%s>e$K(Blibpq$B$,%$%s%9%H!<%k$5$l$F$$$k$3$H$,I,MW$G$9!#(B +

+ +
+
configure$B$N +

+$B%=!<%9%3!<%I$N(Btar ball$B$rE83+$7$?$i!"(Bconfigure$B$r +./configure + + +configure$B$K;XDj$G$-$k%*%W%7%g%s$O0J2<$G$9!#(B + +

    +
  • --prefix=path +pgpool-II$BK\BN$d4XO"%U%!%$%k$r%$%s%9%H!<%k$9$k%H%C%W%G%#%l%/%H%j$r;XDj$7$^$9!#(B +$B%G%U%)%k%H$O(B/usr/local$B$G$9!#(B +
  • --with-pgsql=path +PostgreSQL$B$N%/%i%$%"%s%H%i%$%V%i%j$J$I$,%$%s%9%H!<%k$5$l$F$$$k%H%C%W%G%#(B +$B%l%/%H%j$r;XDj$7$^$9!#%G%U%)%k%H$O(Bpg_config $B%3%^%s%I$G +

    + +
    make$B$N +

    + +

    +make
    +make install
    +
    +$B$G%$%s%9%H!<%k$,40N;$7$^$9(B(GNU make$B$,I,MW$J$N$G!"(BFreeBSD$B$J$I$G$O(B +make$B$r(Bgmake$B$KFI$_BX$($F$/$@$5$$(B)$B!#(B +
+ +

pgpool-II$B$N@_Dj(B

+

+pgpool-II$B$N@_Dj%U%!%$%k$O%G%U%)%k%H$G$O(B/usr/local/etc/pgpool.conf$B$*$h$S(B +/usr/local/etc/pcp.conf$B$G$9!#(Bpgpool-II$B$OF0:n%b!<%I$K$h$C$F;HMQ$G$-$k5!G=$H!"(B +$BI,MW$J@_Dj9`L\$,0[$J$j$^$9!#(B +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$B;HMQ$G$-$k5!G=(B/$B%b!<%I(Braw$B%b!<%I(B$B%3%M%/%7%g%s%W!<%k%b!<%I(B$B%l%W%j%1!<%7%g%s%b!<%I(B$B%^%9%?%9%l!<%V%b!<%I(B$B%Q%i%l%k%/%(%j%b!<%I(B
$B%3%M%/%7%g%s%W!<%j%s%0(B$B!_(B$B!{(B$B!{(B$B!{(B$B!{(B
$B%l%W%j%1!<%7%g%s(B$B!_(B$B!_(B$B!{(B$B!_(B$B"$(B(*)
$BIi2YJ,;6(B$B!_(B$B!_(B$B!{(B$B!{(B$B"$(B(*)
$B=LB`1?E>(B$B!_(B$B!_(B$B!{(B$B!{(B$B!_(B
$B%U%'%$%k%*!<%P(B$B!{(B$B!{(B$B!_(B$B!_(B$B!_(B
$B%Q%i%l%k%/%(%j(B$B!_(B$B!_(B$B!_(B$B!_(B$B!{(B
$B%5!<%PBf?t(B1$B0J>e(B1$B0J>e(B2$B0J>e(B2$B0J>e(B2$B0J>e(B
$B%7%9%F%`(BDB$BITMW(B$BITMW(B$BITMW(B$BITMW(B$BI,MW(B
+ +(*)$B%Q%i%l%k%/%(%j%b!<%I$G$O%G!<%?$rJ,3d$7$FJ]B8$7$F$$$k%F!<%V%k$KBP$7$F$O!"%l%W%j%1!<%7%g%s$J$i$S$KIi2YJ,;6$N5!G=$O;H$($^$;$s!#(B + +

pcp.conf$B$N@_Dj(B

+

+$B$I$NF0:n%b!<%I$G$b!"(Bpcp.conf$B$N@_Dj$OI,MW$G$9!#(Bpgpool-II$B$K$O4IM}pJsZ$,I,MW$K$J$k$N$G!"$=(B +$B$N%f!<%6L>$H%Q%9%o!<%I$r(Bpcp.conf$B$KEPO?$7$^$9!#(B +pgpool-II$B$r%$%s%9%H!<%k$9$k$H!"(B$prefix/etc/pcp.conf.sample$B$,$G$-$k$N$G!"$=$l$r(B +$prefix/etc/pcp.conf$B$H$$$&L>A0$G%3%T!<$7$^$9!#(B +

+
+cp $prefix/etc/pcp.conf.sample $prefix/etc/pcp.conf
+
+

+pcp.conf$B$G$O6uGr9T$d(B#$B$G;O$^$k9T$O%3%a%s%H$H8+$J$5$l$^$9!#(B +$B%f!<%6$H%Q%9%o!<%I$O!"(B +

+
+$B%f!<%6L>(B:[md5$B0E9f2=$7$?%Q%9%o!<%I(B]
+
+

+$B$N$h$&$K;XDj$7$^$9!#(B +[md5$B0E9f2=$7$?%Q%9%o!<%I(B]$B$O!"(B$prefix/bin/pg_md5$B%3%^%s%I$G:n@.$G$-$^$9!#(B +

+
+./pg_md5 foo
+acbd18db4cc2f85cedef654fccc4a4d8
+
+$B%Q%9%o!<%I$r0z?t$KEO$7$?$/$J$$>l9g$O(B pg_md5 -p $B$r +./pg_md5 -p +password: <$B%Q%9%o!<%I$rF~NO(B> + +

+pcp.conf$B$O!"(Bpgpool-II$B$rF0:n$5$;$k%f!<%6(BID$B$GFI$_ + +

pgpool.conf$B$N@_Dj(B

+

+$BA0=R$N$h$&$K!"F0:n%b!<%I$K$h$C$F!"(Bpgpool.conf$B$N@_Dj9`L\$,0[$J$j$^$9!#(B +pgpool-II$B$r%$%s%9%H!<%k$9$k$H!"(B$prefix/etc/pgpool.conf.sample$B$,$G$-$k$N$G!"$=$l$r(B +$prefix/etc/pgpool.conf$B$H$$$&L>A0$G%3%T!<$7$^$9!#(B +

+
+cp $prefix/etc/pgpool.conf.sample $prefix/etc/pgpool.conf
+
+

+pgpool.conf$B$G$O6uGr9T$d(B#$B$G;O$^$k9T$O%3%a%s%H$H8+$J$5$l$^$9!#(B +

+ +

raw$B%b!<%I(B

+

+$BC1$K(Bpgpool-II$B$r7PM3$7$F@\B3$9$k$@$1$N%b!<%I$G$9!#C1$K(BPostgreSQL$B%5!<%P$X$N@\(B +$BB3%;%C%7%g%s?t$r@)8B$7$?$j!"(B2$BBf0J>e$N(BPostgreSQL$B%5!<%P$rMQ0U$7$F%U%'%$%k(B +$B%*!<%PF0:n$r$5$;$?$$$H$-$KMxMQ$7$^$9!#(B +

+ +
+
listen_addresses +
+

+pgpool-II$B$,(BTCP/IP$B%3%M%/%7%g%s$r$^$?$O(BIP$B%"%I%l%9$G(B +$B;XDj$7$^$9!#!V(B*$B!W$r;XDj$9$k$H$9$Y$F$N(BIP$B%$%s%?%U%'!<%9$+$i$N%3%M%/%7%g(B +$B%s$ro$K + +

port +
+

+pgpool-II$B$,%3%M%/%7%g%s$r + +

socket_dir +
+

+pgpool-II$B$,%3%M%/%7%g%s$r + +

pcp_port +
+

+pcp$B$,;HMQ$9$k%]!<%HHV9f$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
pcp_socket_dir +
+

+pcp$B$,%3%M%/%7%g%s$r + +

backend_socket_dir +
+

+UNIX$B%I%a%$%s%=%1%C%H7PM3$G(Bpgpool-II$B$,(BPostgreSQL$B$H@\B3$9$k:]$K;HMQ$9$k(B +PostgreSQL$B$N(BUNIX$B%I%a%$%s%=%1%C%H$,CV$+$l$F$$$k%G%#%l%/%H%j!#%G%U%)%k%HCM(B +$B$O(B/tmp$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
pcp_timeout +
+

+pcp$B$,(Bpgppool$B$H@\B3$9$k:]$N%?%$%`%"%&%HCM!#(B0$B$K$9$k$H%?%$%`%"%&%H$7$^$;$s!#(B +$B%G%U%)%k%HCM$O(B10($BIC(B)$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
num_init_children +
+

+prefork$B$9$k(Bpgpool-II$B$N%5!<%P%W%m%;%9$N?t$G$9!#%G%U%)%k%HCM$O(B32$B$K$J$C$F(B +$B$$$^$9!#(B + $B$J$*!"Ld$$9g$o$;$N%-%c%s%;%k$r9T$&$HDL>o$N%3%M%/%7%g%s$H$OJL$K?7$?(B + $B$J%3%M%/%7%g%s$,D%$i$l$^$9!#$7$?$,$C$F!"$9$Y$F$N%3%M%/%7%g%s$,;HMQ(B + $BCf$N>l9g$OLd$$9g$o$;$N%-%c%s%;%k$,$G$-$J$/$C$F$7$^$&$N$G!"$4Cm0U2<(B + $B$5$$!#Ld$$9g$o$;$N%-%c%s%;%k$rI,$:J]>Z$7$?$$>l9g$O!"A[Dj$5$l$k%3%M(B + $B%/%7%g%s?t$NG\$NCM$r@_Dj$9$k$3$H$r$*$9$9$a$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
child_life_time +
+

+ pgpool-II$B$N;R%W%m%;%9$NuBV$K$J$C$F$+$i(B + child_life_time$BIC7P2a$9$k$H!"0lC6=*N;$7$F?7$7$$%W%m%;%9$r5/F0$7$^$9!#(B + $B%a%b%j!<%j!<%/$=$NB>$N>c32$KHw$($?M=KIA + +

child_max_connections +
+

+ $B3F(Bpgpool-II$B;R%W%m%;%9$X$N@\B32s?t$,$3$N@_DjCM$rD6$($k$H!"$=$N;R%W%m(B + $B%;%9$r=*N;$7$^$9!#(Bchild_life_time$B$d(Bconnection_life_time$B$,8z$+$J$$$/(B + $B$i$$K;$7$$%5!<%P$G!"(BPostgreSQL$B%P%C%/%(%s%I$,HnBg2=$9$k$N$rKI$0$N$K(B + $BM-8z$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
client_idle_limit +
+

+ $BA02s%/%i%$%"%s%H$+$iMh$?%/%(%j$+$i!"(Bclient_idle_limit $BIC1[$($F$bl9g$O!"%/%i%$%"%s%H$X$N@\B3$r6/@)E*$K@ZCG$7!"%/%i%$(B + $B%"%s%H$+$i$N + +

authentication_timeout +
+

+ $BG'>Z=hM}$N%?%$%`%"%&%H;~4V$rICC10L$G;XDj$7$^$9!#(B0 $B$r;XDj$9$k$H%?%$(B + $B%`%"%&%H$rL58z$K$7$^$9!#(Bauthentication_timeout $B$N%G%U%)%k%HCM$O(B 60 + $B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
logdir +
+

+ pgpool-II$B$N3F-MhFH<+$N%m%0%7%9%F%`$r + +

pid_file_name +
+

+ pgpool-II$B$N(Bpid file($B%W%m%;%9(BID$B$r3JG<$7$?%U%!%$%k(B)$B$N%U%k%Q%9L>$G$9!#(B + $B%G%U%)%k%HCM$O(B'/var/run/pgpool/pgpool.pid'$B$G$9!#(B + $B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
print_timestamp +
+

+ true$B$J$i$P(Bpgpool-II$B$N%m%0$K%?%$%`%9%?%s%W$rDI2C$7$^$9!#%G%U%)%k%H$O(B + true$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
connection_cache +
+

+ true$B$J$i%3%M%/%7%g%s$r%-%c%C%7%e$7$^$9!#%G%U%)%k%H$O(Btrue$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
health_check_timeout +
+

+ pgpool-II$B$O%5!<%P>c32$d%M%C%H%o!<%/>c32$r8!CN$9$k$?$a$K!"Dj4|E*$K%P%C(B + $B%/%(%s%I$K@\B3$r;n$_$^$9!#$3$l$r!V%X%k%9%A%'%C%/!W$H8@$$$^$9!#>c32(B + $B$,8!CN$5$l$k$H!"%U%'%$%k%*!<%P$d=LB`1?E>$r;n$_$^$9!#(B + + $B$3$N(B $B%Q%i%a!<%?$O!"%M%C%H%o!<%/%1!<%V%k$,H4$1$?:]$J$I$K%X%k%9%A%'%C(B + $B%/$,D9;~4VBT$?$5$l$k$N$rKI$0$?$a$N%?%$%`%"%&%HCM$rICC10L$G;XDj$7$^(B + $B$9!#%G%U%)%k%H$O(B20$BIC$G$9!#(B0$B$r;XDj$9$k$H%?%$%`%"%&%H=hM}$r$7$^$;$s!#(B + + $B$J$*!"%X%k%9%A%'%C%/$rM-8z$K$9$k$H!"%X%k%9%A%'%C%/$N$?$a$NM>J,$N@\(B + $BB3$,(B1$B$DI,MW$K$J$j$^$9$N$G!"(BPostgreSQL$B$N(Bpostgresql.conf$B$N@_Dj9`L\$N(B + max_connections$B$r>/$/$H$b(B1$BA}$d$9$h$&$K$7$F$/$@$5$$!#(B + +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
health_check_period +
+

+ $B%X%k%9%A%'%C%/$r9T$&4V3V$rICC10L$G;XDj$7$^$9!#(B0$B$r;XDj$9$k$H%X%k%9(B + $B%A%'%C%/$r9T$$$^$;$s!#%G%U%)%k%H$O(B0$B$G$9(B($B$D$^$j%X%k%9%A%'%C%/$r9T$$(B + $B$^$;$s(B)$B!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
health_check_user +
+

+ $B%X%k%9%A%'%C%/$r9T$&$?$a$N(BPostgreSQL$B%f!<%6L>$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
failover_command +
+

+$B%N!<%I$,@Z$jN%$5$l$?;~$KpJs$KCV$-49$($F%3%^%s%I$r + + + + + + + + + +
$BJ8;z(B$B0UL#(B
%d$B@Z$jN%$5$l$?%N!<%IHV9f(B
%h$B@Z$jN%$5$l$?%N!<%I$N%[%9%HL>(B
%p$B@Z$jN%$5$l$?%N!<%I$N%]!<%HHV9f(B
%D$B@Z$jN%$5$l$?%N!<%I$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B +
%M$B8E$$%^%9%?!<$N%N!<%IHV9f(B
%m$B?7$7$$%^%9%?!<$N%N!<%IHV9f(B
%%'%'$BJ8;z(B
+ +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+

+$B%U%'%$%k%*!<%P!<;~$K$O!"(Bpgpool$B$O$^$:;R%W%m%;%9$r@ZCG$7$^$9(B($B7k2L$H$7$F!"$9$Y$F$N%;%C%7%g%s$,@ZCG$5$l$^$9(B)$B!#uBV$K$J$j$^$9!#(B +

+ +
failback_command +
+

+$B%N!<%I$,I|5"$7$?;~$KpJs$KCV$-49$($F%3%^%s%I$r + + + + + + + + + +
$BJ8;z(B$B0UL#(B
%d$BI|5"$7$?%N!<%IHV9f(B
%h$BI|5"$7$?%N!<%I$N%[%9%HL>(B
%p$BI|5"$7$?%N!<%I$N%]!<%HHV9f(B
%D$BI|5"$7$?%N!<%I$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B +
%M$B8E$$%^%9%?!<$N%N!<%IHV9f(B
%m$B?7$7$$%^%9%?!<$N%N!<%IHV9f(B
%%'%'$BJ8;z(B
+ +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
ignore_leading_white_space +
+

+ true$B$J$i$P!"(Bload balance$B$N:]$K(BSQL$BJ89TF,$N6uGr$rL5;k$7$^$9(B($BA43Q%9(B + $B%Z!<%9$OL5;k$5$l$^$;$s(B)$B!#$3$l$O!"(BDBI/DBD:Pg$B$N$h$&$K!">! + +

log_statement +
+

+ true$B$J$i$P(BSQL$BJ8$r%m%0=PNO$7$^$9!#$3$NLrL\$O(BPostgreSQL$B$N(B + log_statement$B%*%W%7%g%s$H;w$F$$$F!"%G%P%C%0%*%W%7%g%s$,$J$$$H$-$G$b(B + $BLd$$9g$o$;$r%m%0=PNO$7$FD4$Y$k$3$H$,$G$-$k$N$GJXMx$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
log_hostname +
+

+ true$B$J$i$P!"(Bps$B%3%^%s%I$G$N>uBVI=<(;~$K(BIP$B%"%I%l%9$G$O$J$/!"%[%9%HL>(B + $B$rI=<($7$^$9!#$^$?!"(Blog_connections$B$,M-8z$J>l9g$K$O%m%0$K%[%9%HL>$r(B + $B=PNO$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
log_connections +
+

+ true$B$J$i$P!"A4$F$N%/%i%$%"%s%H@\B3$r%m%0$X=PNO$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
enable_pool_hba +
+

+ true$B$J$i$P!"(Bpool_hba.conf$B$K=>$C$F%/%i%$%"%s%HG'>Z$r9T$$$^$9!#(B + $B>\:Y$O(B$B%/%i%$%"%s%HG'>Z(B(HBA)$B$N$?$a$N(Bpool_hba.conf$B@_Dj(B + $BJ}K!(B$B$r;2>H$7$F$/$@$5$$!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
backend_hostname +
+

+$B;HMQ$9$k(BPostgreSQL$B%5!<%P$N%[%9%HL>$r;XDj$7$^$9!#6uJ8;z$r;XDj$9$k$H(BUNIX$B%I(B +$B%a%$%s%=%1%C%H$G@\B3$7$^$9!#(B +$Bl9g!">r7o$K$h$C$F$O%^%9%?!<(BDB$B$,%@%&%s$7$F$b(B +$B1?MQ$rB3$1$k$3$H$,$G$-$^$9!#$3$N>l9g$O!"2TF/Cf$+$D(BDB$B%N!<%I(BID$B$,$b$C$H$b(B +$B +

+1$BBf$7$+(BPostgreSQL$B$r;HMQ$7$J$$>l9g$O!"(B"backend_hostname0"$B$H$7$F$/$@$5$$!#(B +

+

+backend_hostname $B$O?7$7$/DI2C$7$?9T$r@_Dj%U%!%$%k:FFI$_9~$_$GDI2C$9$k(B +$B$3$H$,$G$-$^$9!#$9$G$K$"$k>pJs$rESCf$GJQ99$9$k$3$H$O$G$-$^$;$s!#JQ99$9(B +$B$k>l9g$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
backend_port +
+

+$B;HMQ$9$k(BPostgreSQL$B%5!<%P$N%]!<%HHV9f$r;XDj$7$^$9!#(B +$Bl9g$O!"(B +"backend_port0"$B$H$7$F$/$@$5$$!#(B +

+ +

+backend_port $B$O?7$7$/DI2C$7$?9T$r@_Dj%U%!%$%k:FFI$_9~$_$GDI2C$9$k(B +$B$3$H$,$G$-$^$9!#$9$G$K$"$k>pJs$rESCf$GJQ99$9$k$3$H$O$G$-$^$;$s!#JQ99$9(B +$B$k>l9g$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ + +
backend_weight +
+

+$B;HMQ$9$k(BPostgreSQL$B%5!<%P$KBP$9$kIi2YJ,;6$NHfN($r;XDj$7$^$9!#(B +$Bl9g$O!"(B +"backend_weight0"$B$H$7$F$/$@$5$$!#(B +$BIi2YJ,;6$r;HMQ$7$J$$>l9g$O!"!V(B1$B!W$r@_Dj$7$F$/$@$5$$!#(B +

+ +

+backend_weight $B$O?7$7$/DI2C$7$?9T$r@_Dj%U%!%$%k:FFI$_9~$_$GDI2C$9$k(B +$B$3$H$,$G$-$^$9!#$9$G$K$"$k>pJs$rESCf$GJQ99$9$k$3$H$O$G$-$^$;$s!#JQ99$9(B +$B$k>l9g$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
backend_data_directory +
+

+$B;HMQ$9$k(B PostgreSQL $B%5!<%P$N%G!<%?%Y!<%9%/%i%9%?$N%Q%9$r;XDj$7$^$9!#(B +$Bl9g$K$O@_Dj$9$kI,MW$O$"$j$^$;$s!#(B +

+ +

+backend_data_directory $B$O?7$7$/DI2C$7$?9T$r@_Dj%U%!%$%k:FFI$_9~$_$GDI2C$9$k(B +$B$3$H$,$G$-$^$9!#$9$G$K$"$k>pJs$rESCf$GJQ99$9$k$3$H$O$G$-$^$;$s!#JQ99$9(B +$B$k>l9g$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
+ +

raw$B%b!<%I$K$*$1$k%U%'%$%k%*!<%PF0:n$K$D$$$F(B

+

+raw$B%b!<%I$K$*$$$F!"(B2$BBf0J>e$N(BPostgreSQL$B%5!<%P$r;XDj$9$k$H!"%U%'%$%k%*!<%P(B +$B$,2DG=$G$9!#%U%'%$%k%*!<%P$G$O!"@5>o;~$K$O(Bbackend_hostname0$B$G;XDj$7$?(B +PostgreSQL$B$N$_$r;HMQ$7!"$[$+$N%5!<%P$K$O%"%/%;%9$7$^$;$s!#(B +backend_hostname0$B$N%5!<%P$,%@%&%s$9$k$H!" + +

$B%3%M%/%7%g%s%W!<%k%b!<%I(B

+

+raw$B%b!<%I$K2C$(!"%3%M%/%7%g%s%W!<%j%s%0$,MxMQ$G$-$k$h$&$K$J$j$^$9!#(B +$B@_Dj9`L\$O!"(Braw$B%b!<%I$G$N@_Dj9`L\$NB>$K0J2<$r@_Dj$7$^$9!#(B +

+ +
+
max_pool +
+

+ pgpool-II$B$N3F%5!<%P%W%m%;%9$,%-!<%W$9$k(BPostgreSQL$B$X$N:GBg%3%M%/%7%g%s(B + $B?t$G$9!#(Bpgpool-II$B$O!"%f!<%6L>!"%G!<%?%Y!<%9$,F1$8$J$i$P%3%M%/%7%g%s$r(B + $B:FMxMQ$7$^$9$,!"$=$&$G$J$1$l$P?7$?$K(BPostgreSQL$B$X$N%3%M%/%7%g%s$r3N(B + $BN)$7$h$&$H$7$^$9!#$7$?$,$C$F!"$3$3$G$OA[Dj$5$l$k(B[$B%f!<%6L>(B:$B%G!<%?%Y!<(B + $B%9L>(B]$B$N%Z%"$Nl9g$O0lHV8E$$%3%M%/%7%g%s$r@ZCG$7!"(B + $B$=$N%9%m%C%H$,:FMxMQ$5$l$^$9!#(B + + max_pool$B$N%G%U%)%k%HCM$O(B4$B$G$9!#(B + + $B$J$*!"(Bpgpool-II$BA4BN$H$7$F$O!"(Bnum_init_children*max_pool $BJ,$@$1(B + PostgreSQL$B$X$N%3%M%/%7%g%s$,D%$i$l$kE@$KCm0U$7$F$/$@$5$$!#(B + +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
connection_life_time +
+

+ $B%3%M%/%7%g%s%W!<%kCf$N%3%M%/%7%g%s$NM-8z4|4V$rICC10L$G;XDj$7$^$9!#(B0 + $B$r;XDj$9$k$HM-8z4|4V$OL58B$K$J$j$^$9!#(Bconnection_life_time$B$N%G%U%)(B + $B%k%HCM$O(B0$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
reset_query_list +
+

+ $B%;%C%7%g%s$,=*N;$9$k$H$-$K%3%M%/%7%g%s$r=i4|2=$9$k$?$a$N(BSQL$B%3%^%s%I(B + $B$r!V(B;$B!W$G6h@Z$C$FNs5s$7$^$9!#%G%U%)%k%H$O0J2<$N$h$&$K$J$C$F$$$^$9$,!"(B + $BG$0U$N(BSQL$BJ8$rDI2C$7$F$b9=$$$^$;$s!#(B +

+   reset_query_list = 'ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT'
+
+ +

+ PostgreSQL$B$N%P!<%8%g%s$K$h$C$F;HMQ$G$-$k(BSQL$B%3%^%s%I$,0c$$$^$9$,!"(B + $B3F%P!<%8%g%s$4$H$N$*4+$a@_Dj$O0J2<$G$9!#(B +

+

+ + + + + +
PostgreSQL$B%P!<%8%g%s(Breset_query_list$B$N@_DjCM(B
7.1$B0JA0(BABORT
7.2$B$+$i(B8.2ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT
8.3$B0J9_(BABORT; DISCARD ALL
+

+

+ +

    +
  • $B!V(BABORT$B!W$O!"(BPostgreSQL 7.4$B0J>e$G$O%H%i%s%6%/%7%g%s%V%m%C%/$NCf$K$$(B + $B$J$$>l9g$K$OH/9T$5$l$^$;$s!#(B +
  • DISCARD ALL$B$O%7%9%F%`%F!<%V%k$N(Bpg_listener$B$KGSB>%m%C%/$r$+$1$k$?$a!"(B + $BF1;~l9g$O!"LLE]$G$b(BDISCARD$B%3%^%s%I$GGK4~$7$?$$%*%V%8%'%/%H$r$$$A$$$A;XDj$9$k$3$H$r$*4+$a$7$^$9!#(B +
+ +

+ +

+$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+
+ +
+ +

$B%3%M%/%7%g%s%W!<%k%b!<%I$K$*$1$k%U%'%$%k%*!<%PF0:n$K$D$$$F(B

+

+raw$B%b!<%I$HF1MM$NF0:n$r$7$^$9!#(B +

+ +

$B%l%W%j%1!<%7%g%s%b!<%I(B

+

+$B%l%W%j%1!<%7%g%s$rM-8z$K$9$k%b!<%I$G$9!#(B +raw$B%b!<%I!"%3%M%/%7%g%s%W!<%k%b!<%I$K2C$(!"0J2<$r@_Dj$7$^$9!#(B +

+ +
+
replication_mode +
+

+ $B%l%W%j%1!<%7%g%s%b!<%I$GF0:n$5$;$k>l9g$O(Btrue$B$r;XDj$7$F$/$@$5$$!#%G(B + $B%U%)%k%HCM$O(Bfalse$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
load_balance_mode +
+

+ true$B$r;XDj$9$k$H%l%W%j%1!<%7%g%s%b!<%I$N:]$K!"(BSELECT$BJ8$r%^%9%?$H%;(B + $B%+%s%@%j$N4V$G%m!<%I%P%i%s%9$7$^$9!#%G%U%)%k%HCM$O(Bfalse$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
replication_stop_on_mismatch +
+

+ true$B$r;XDj$9$k$H%^%9%?!<(BDB$B$HB>$N(BDB$B%N!<%I$N4V$G%G!<%?$NIT0lCW$,$"$C$?>l9g(B + $B$K6/@)E*$K=LB`1?E>$KF~$j$^$9!#$3$N%*%W%7%g%s$,(Bfalse$B$N>l9g$O!"3:Ev$N(B + $BLd$$9g$o$;$r6/@)E*$K=*N;$9$k$@$1$KN1$a$^$9!#%G%U%)%k%HCM$O(Bfalse$B$G$9!#(B +

+ + +
replicate_select +
+

+ true $B$r@_Dj$9$k$H%m!<%I%P%i%s%9$5$l$J$$(B SELECT $BJ8$r%l%W%j%1!<%7%g%s(B + $B$5$;$^$9!#$3$l$O(B pgpool-II 1.0 $B$^$G$N5sF0$HF1$8$K$J$j$^$9!#(Bfalse $B$r(B + $B@_Dj$9$k$H(B SELECT $BJ8$r%^%9%?$N$_$KAw?.$7$^$9!#%G%U%)%k%HCM$O(B false + $B$G$9!#(B +

+

+replicate_select$B!"(Bload_balance_mode$B!"(BSELECT$BLd9g$o$;$,L@<(E*$J%H%i%s%6%/%7%g%s%V%m%C%/$NFbB&$K$"$k$+$I$&$+$I$&$+$G!"%l%W%j%1!<%7%g%s%b!<%I$NF0:n$,JQ2=$7$^$9!#>\:Y$rI=$K<($7$^$9!#(B +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SELECT$B$,L@<(E*$J%H%i%s%6%/%7%g%s%V%m%C%/$NFbB&$K$"$k(BYYYNNNYN
replicate_select$B$,(BtrueYYNNYYNN
load_balance_mode$B$,(BtrueYNNNYNYY
$B7k2L(B(R:$B%l%W%j%1!<%7%g%s(B, M: $B%^%9%?$N$_$KAw?.!"(BL: $B%m!<%I%P%i%s%9$5$l$k(BRRMMLRML
+

+ +
insert_lock +
+

+ SERIAL$B7?$r;H$C$F$$$k%F!<%V%k$r%l%W%j%1!<%7%g%s$9$k$H!"(BSERIAL$B7?$NNs(B + $B$NCM$,(BDB$B%N!<%I$N4V$G0lCW$7$J$/$J$k$3$H$,$"$j$^$9!#$3$NLdBj$O!"(B + $B3:Ev%F!<%V%k$rL@<(E*$K%m%C%/$9$k$3$H$G2sHr$G$-$^$9(B($B$b$A$m$s%H%i%s%6(B + $B%/%7%g%s$NJBNs@7$K$J$j$^$9$,(B)$B!#$7$+$7!"$=$N$?$a$K$O!"(B +

+
+   INSERT INTO ...
+
+ +

+ $B$r(B +

+ +
+   BEGIN;
+   LOCK TABLE ...
+   INSERT INTO ...
+   COMMIT;
+
+ +

+ $B$K=q$-49$($J$1$l$P$J$j$^$;$s!#(Binsert_lock$B$r(Btrue$B$K$9$k$H<+F0E*$K%H%i(B + $B%s%6%/%7%g%s$N3+;O!"%F!<%V%k%m%C%/!"%H%i%s%6%/%7%g%s$N=*N;$r9T$C$F(B + $B$/$l$k$N$G!"$3$&$7$?J$/$3$H$,$G$-$^$9!J$9$G$K%H%i%s%6%/%7%g(B + $B%s$,3+;O$5$l$F$$$k>l9g$O(BLOCK TABLE...$B$@$1$,l9g$K$O!"%F!<%V%k$N%m%C%/$O9T$J$o$l$^$;$s!#(B + $B$J$*!"$"$^$jI,MW$J$$$+$bCN$l$^$;$s$,!"%3%a%s%H$rMxMQ$7$F!"$3$N5sF0$r(B + $B:Y$+$/@)8f$9$k$3$H$b$G$-$^$9!#(B +

+ +
    +
  1. insert_lock$B$r(Btrue$B$K$7$F!"(BINSERT$BJ8$N@hF,$K(B/*NO INSERT LOCK*/$B%3%a(B + $B%s%H$rDI2C$9$k!#$3$N%3%a%s%H$,$"$k$H!"%F!<%V%k%m%C%/$O9T$o$l$^$;(B + $B$s!#(B + +
  2. insert_lock$B$r(Bfalse$B$K$7$F!"(BINSERT$BJ8$N@hF,$K(B/*INSERT LOCK*/$B%3%a%s(B + $B%H$rDI2C$9$k!#$3$N%3%a%s%H$,$"$k$H!"$3$N(BINSERT$BJ8$KBP$7$F$N$_%F!<(B + $B%V%k%m%C%/$,9T$o$l$^$9!#(B +
+ +

+ insert_lock$B$N%G%U%)%k%HCM$O(Btrue$B$G$9!#(B + + $B$J$*!"(Binsert_lock$B$rM-8z$K$7$F(Bregression test$B$r/$/$H$b(B + PostgreSQL 8.0$B$G$O(Btransactions, privileges, rules, alter_table$B$,(B + fail$B$7$^$9!#(Brule$B$G$O!"(Bview$B$KBP$7$F(BLOCK$B$r$7$h$&$H$7$F$7$^$&$3$H!"(B + $B$[$+$N$b$N$O(B +

+
+   ! ERROR:  current transaction is aborted, commands ignored until end of transaction block
+
+ +

+ $B$H$$$&$h$&$J%a%C%;!<%8$,=P$F$7$^$&$?$a$G$9!#$?$H$($P!"(Btransactions + $B$G$O!"B8:_$7$J$$%F!<%V%k$KBP$7$F(BINSERT$B$r9T$&%F%9%H$,4^$^$l$F$*$j!"(B + pgpool$B$,:G=i$KB8:_$7$J$$%F!<%V%k$KBP$7$F(BLOCK$B$r9T$&7k2L!"%(%i!<$K$J$C(B + $B$F%H%i%s%6%/%7%g%s$,%"%\!<%H>uBV$K$J$j!"B3$/(BINSERT$B$G>e5-%(%i!<$,=P(B + $B$F$7$^$$$^$9!#(B +

+ +

+$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ + +
recovery_user +
+

+ $B%*%s%i%$%s%j%+%P%j$r9T$&$?$a$N(B PostgreSQL $B%f!<%6L>$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
recovery_password +
+

+ $B%*%s%i%$%s%j%+%P%j$r9T$&$?$a$N(B PostgreSQL $B%f!<%6%Q%9%o!<%I$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
recovery_1st_stage_command +
+

+ $B:G=i$K%*%s%i%$%s%j%+%P%jCf$K5/F0$9$k%3%^%s%IL>$r;XDj$7$^$9!#%3%^%s%I(B + $B%U%!%$%k$O%;%-%e%j%F%#>e$N4QE@$+$i%G!<%?%Y!<%9%/%i%9%?0J2<$K$"$k%3%^(B + $B%s%I$d%9%/%j%W%H$N$_$r8F$S=P$7$^$9!#(B + + $BNc$($P!"(Brecovery_1st_stage_command = 'sync-command' $B$H@_Dj$7$F$"$k>l(B + $B9g!"(B$PGDATA/sync-command $B$r5/F0$7$h$&$H$7$^$9!#(B + + recovery_1st_stage_command $B$r$B@)8B$7$^$;$s(B$B!#;2>H$d99?7$r9T$&$3$H$,$G$-$^$9!#(B +

+

+$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
recovery_2nd_stage_command +
+

+ 2 $B2sL\$N%*%s%i%$%s%j%+%P%jCf$K5/F0$9$k%3%^%s%IL>$r;XDj$7$^$9!#%3%^%s(B + $B%I%U%!%$%k$O%;%-%e%j%F%#>e$N4QE@$+$i%G!<%?%Y!<%9%/%i%9%?0J2<$K$"$k%3(B + $B%^%s%I$d%9%/%j%W%H$N$_$r8F$S=P$7$^$9!#(B + + $BNc$($P!"(Brecovery_2nd_stage_command = 'sync-command' $B$H@_Dj$7$F$"$k>l(B + $B9g!"(B$PGDATA/sync-command $B$r5/F0$7$h$&$H$7$^$9!#(B + + recovery_2nd_stage_command $B$rH!"99?7=hM}$r0l@Z(B$B$B!#$^$?!"%P%C%A(B + $B=hM}$J$I$K$h$C$F@\B3$7$F$$$k%/%i%$%"%s%H$,D9;~4VB8:_$7$F$$$k>l9g$K$O(B + $B%3%^%s%I$r5/F0$7$^$;$s!#@\B3$r@)8B$7!"8=:_$N@\B3?t$,(B 0 $B$K$J$C$?;~E@(B + $B$G%3%^%s%I$r5/F0$7$^$9!#(B +

+

+$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
recovery_timeout +
+

+ pgpool$B$O!"%*%s%i%$%s%j%+%P%j$N:]$K$9$Y$F$N%/%i%$%"%s%H$,@\B3$r=*N;$9$k$^$GBT$A$^$9!#(B + recovery_timeout$B$G$=$N:GBgBT$A;~4V$r;XDj$7$^$9!#C10L$OIC$G$9!#(B + $BBT$A;~4V$,(Brecovery_timeout$B$r1[$($k$H!"%*%s%i%$%s%j%+%P%j$OCf;_$5$l!"DL>o$N>uBV$KLa$j$^$9!#(B +

+

+ $B%"%$%I%k>uBV$N%/%i%$%"%s%H$,<+J,$+$i@ZCG$9$k$N$rBT$A$?$/$J$$>l9g$O!"(Bclient_idle_limit_in_recovery$B$rMxMQ$9$k$3$H$b$G$-$^$9!#(B +

+

+

+recovery_timeout$B$O!"$3$NB>!"%*%s%i%$%s%j%+%P%j$N:G8e$K%j%+%P%jBP>]$N(BDB$B%N!<%I$G(Bpostmaster$B$r5/F0$9$k:]$NBT$A;~4V$K$bMxMQ$5$l$^$9!#(B +

+

+recovery_timeout$B$N%G%U%)%k%HCM$O(B90$BIC$G$9!#(B +recovery_timeout$B$r(B0$B$H$7$F$b%?%$%`%"%&%H$,L58z$K$J$k$o$1$G$O$J$/!"C1$KB(:B$K%?%$%`%"%&%H$9$k$@$1$G$9$N$GCm0U$7$F$/$@$5$$!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
client_idle_limit_in_recovery +
+

+ client_idle_limit$B$H;w$F$$$^$9$,!"$3$N%Q%i%a!<%?$O%j%+%P%j$N%;%+%s%I%9(B + $B%F!<%8$G$N$_8zNO$,$"$j$^$9!#A02s%/%i%$%"%s%H$+$iMh$?%/%(%j$+$i!"(B + client_idle_limit_in_recovery $BIC1[$($F$bl9g$O!"%/(B + $B%i%$%"%s%H$X$N@\B3$r6/@)E*$K@ZCG$7!"(B + $B%j%+%P%j$N%;%+%s%I%9%F!<%8$N?J9T$,K832$5$l$k$N$rKI$.$^$9!#%G%U%)%k%HCM$O(B 0($BL58z(B)$B$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O@_Dj%U%!%$%k$r:FFI$_9~$_$7$F$/$@$5$$!#(B +

+ +
+ +

$B%m!<%I%P%i%s%9$N>r7o$K$D$$$F(B

+

+load_balance_mode = true $B$r@_Dj$7$?>l9g!"0J2<$N>r7o$N$9$Y$F$rK~$?$7$?;~$K(BSELECT$B$J$I$NLd$$9g$o$;$,%m!<%I%P%i%s%9$5$l$^$9!#(B +

    +
  • PostgreSQL$B$N%P!<%8%g%s$,(B7.4$B0J9_$G$"$k(B +
  • $BLd$$9g$o$;$,L@<(E*$J%H%i%s%/%6%7%g%s%V%m%C%/$NFbB&$K$J$$(B($B$D$^$j!"(BBEGIN$B$rH/9T$7$F$$$J$$(B) +
  • SELECT$BJ8(B($B$?$@$7!"(BSELECT nextval $B$H(B SELECT setval $B$N>l9g$O=|$/(B)$B$^$?$O(BCOPY TO STDOUT, DECLARE..SELECT, FETCH, CLOSE$B$N$$$:$l$+$G$"$k(B +
  • SELECT INTO $BJ8$G$O$J$$(B +
  • SELECT FOR UPDATE/SELECT FOR SHARE$BJ8$G$O$J$$(B +
  • $B%/%(%jJ8;zNs$,(B SELECT $B$G;O$^$k(B(ignore_leading_white_space = true$B$N>l9g$O6uGr$OL5;k$7$^$9(B) +
+

+

+ +(replicate_select$B$N9`L\(B$B$b;29M$K$7$F$/$@$5$$(B) +$B$^$?!"(B$B>\:Y$JH=Dj>r7o$r%U%m!<%A%c!<%H$K$7$?$b(B$B$N$b$4Mw2<$5$$!#(B + +$B$J$*!"(B +

+  /*REPLICATION*/ SELECT ...
+
+

+

+$B$H$9$k$3$H$K$h$C$F!"K\MhIi2YJ,;6$5$l$?$j!"%^%9%?$N$_$KAw?.$5$l$k$Y$-Ld9g$o$;$,$9$Y$F$N%P%C%/%(%s%I$KAw?.$5$l$k!J%l%W%j%1!<%7%g%s$5$l$k!K$h$&$K$J$j$^$9!#I{:nMQ$,$"$k4X?t$r4^$`Ld9g$o$;$KBP$7$F$O$3$N%F%/%K%C%/$,MxMQ$G$-$^$9!#(B +

+ +

+ +$BCm0U(B: JDBC $B%I%i%$%P$J$I$N$h$&$K!"%I%i%$%PFb$G(B autocommit $B$NM-8z!&L58z$N%*%W%7%g%s$,$"$k>l9g!"(B +autocommit $B$rL58z$K$9$k$H!"(Bpgpool$B$,FbIt$G(B BEGIN $B%3%^%s%I$re!"@5$7$/%m!<%I%P%i%s%9$5$l$J$$2DG=@-$,$"$j$^$9!#(B +$B%/%(%j$r%m!<%I%P%i%s%9$5$;$?$$>l9g$O(B autocommit $B$rM-8z$K$7$F$/$@$5$$!#(B +$B$?$H$($P(BJDBC$B$G$"$l$P(B setAutoCommit(true) $B$r +

+ +

$B%l%W%j%1!<%7%g%s%b!<%I$K$*$1$k=LB`1?E>$K$D$$$F(B

+

+PostgreSQL$B%5!<%P$N$&$A!"(B1$BBf$,%@%&%s$9$k$H!"$=$N%5!<%P$r@Z$jN%$7$F=LB`1?(B +$BE>$KF~$j$^$9!#(B1$BBf$G$b%5!<%P$,@8$-;D$C$F$$$l$P!"%7%9%F%`$H$7$F$N1?MQ$r7Q(B +$BB3$G$-$^$9!#(B +

+ +

$B%l%W%j%1!<%7%g%s%b!<%I8GM-$N%(%i!<$K$D$$$F(B

+

+$B%G!<%?$N@09g@-$rJ]$D$?$a$K!"(Bpgpool$B$O%l%W%j%1!<%7%g%s;~$K(B INSERT, UPDATE, +DELETE $B$N99?77o?t$,$9$Y$F$N%N!<%I$,F1$8$G$J$$>l9g!"0U?^E*$K9=J8%(%i!<$r5/$9(BSQL$B$rAw?.$9$k$3$H$K$h$C$F!"%H%i%s%6%/%7%g%s$r%"%\!<%H$5$;$^$9(B($B%U%'%$%k%*!<%P$O5/$-$^$;$s(B)$B!#0J2<$N$h$&$J46$8$K$J$j$^$9!#(B +

+   =# UPDATE t SET a = a + 1;
+   ERROR: pgpool detected difference of the number of update tuples
+   HINT: check data consistency between master and other db node
+
+ +

+ +

$B%^%9%?!<%9%l!<%V%b!<%I(B

+

+ master/slave$B%b!<%I$O!"(BSlony-I$B$N$h$&$J!"(Bmaster/slave$B<0$N%l%W%j%1!<%7%g(B + $B%s%=%U%H$K%l%W%j%1!<%7%g%s$r$^$+$;$k%b!<%I$G$9!#$3$N%b!<%I$G;H$&$?$a$K(B + $B$O!"%l%W%j%1!<%7%g%s%b!<%I$HF1$8$h$&$K!"(BDB$B%N!<%I$N%[%9%H>pJs(B + $B$r%;%C%H$7!"(Bmaster_slave_mode$B$H(Bload_balance_mode$B$r(Btrue$B$K$7$^$9!#$3$N$H(B + $B$-!"Ld$$9g$o$;$K$h$C$F%^%9%?!<(BDB$B$@$1$KLd$$9g$o$;$,Aw$i$l$k>l9g$H!"(BDB + $B%N!<%I$N4V$G%m!<%I%P%i%s%9$5$l$FLd$$9g$o$;$,Aw$i$l$k>l9g$,$"$j$^$9!#(B + $B%m!<%I%P%i%s%9$N>r7o$O%l%W%j%1!<%7%g%s%b!<%I$HF1$8$G$9!#(B +

+ +

+$B%^%9%?!<%9%l!<%V%b!<%I$G$O!"(Bpgpool.conf$B$N(Breplication_mode$B$r(Bfalse$B$K!"(Bmaster_slave_mode +$B$r(Btrue$B$K$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +

$B%Q%i%l%k%b!<%I(B

+

+$B%Q%i%l%k%/%(%j5!G=$,MxMQ$G$-$k%b!<%I$G$9!#%F!<%V%k$rJ,3d$5$;!"3F%N!<%I$K%G!<%?(B +$B$r;}$?$;$k$3$H$,$G$-$^$9!#$^$?%l%W%j%1!<%7%g%s$dIi2YJ,;65!G=$bF1;~$K;H$&$3$H$,(B +$B$G$-$^$9!#(B + +$B%Q%i%l%k%b!<%I$G$O!"(Bpgpool.conf$B$N(Breplication_mode$B$^$?$O(Bloadbalance_mode$B$K(Btrue +$B$r@_Dj$7!"(Bmaster_slave $B$r(Bfalse$B$K$7!"(Bparallel_mode $B$r(Btrue$B$K$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+

+$B%7%9%F%`(BDB$B$N@_Dj(B +

+

+$B%Q%i%l%k%b!<%I$rMxMQ$9$k$?$a$K$O!"%7%9%F%`(BDB$B$r@_Dj$9$kI,MW$,$"$j$^$9!#(B +$B%7%9%F%`(BDB$B$O%G!<%?$r3F(BPostgreSQL$B%5!<%P$GJ,3d$9$k$?$a$N%k!<%k$r(B +PostgreSQL$B$N%F!<%V%k$N7A$GJ];}$7$^$9!#%7%9%F%`(BDB$B$O(Bpgpool$B$,F0:n$9$k%[%9%H(B +$B$HF1$8%[%9%H$KCV$/I,MW$O$"$j$^$;$s!#%7%9%F%`(BDB$B$N@_Dj$O(Bpgpool.conf$B$G9T$$(B +$B$^$9!#(B +

+ +
+
system_db_hostname +
+

+$B%7%9%F%`(BDB$B$,F0$$$F$$$k%[%9%HL>$G$9!#6uJ8;z$r;XDj$9$k$H!"(BUNIX$B%I%a%$%s%=%1%C(B +$B%H$G@\B3$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
system_db_port +
+

+$B%7%9%F%`(BDB$B$N%]!<%HHV9f$G$9!#$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II +$B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
system_dbname +
+

+$B%7%9%F%`(BDB$B$O@lMQ$N%G!<%?%Y!<%9$K@_CV$7$^$9!#$=$N%G!<%?%Y!<%9L>$r;XDj$7$^$9!#(B +$B$3$N%G!<%?%Y!<%9$O$"$i$+$8$aB8:_$7$J$1$l$P$J$j$^$;$s!#$3$3$G$O!"(B +"pgpool"$B$H$$$&%G!<%?%Y!<%9L>$K$9$k$b$N$H$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
system_db_schema +
+

+$B%7%9%F%`(BDB$B$O@lMQ$N%9%-!<%^$K@_CV$7$^$9!#$=$N%9%-!<%^L>$r;XDj$7$^$9!#(B +$B$3$N%9%-!<%^$O$"$i$+$8$aB8:_$7$J$1$l$P$J$j$^$;$s!#$3$3$G$O!"(B +"pgpool_catalog"$B$H$$$&%9%-!<%^$K$9$k$b$N$H$7$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
system_db_user +
+

+$B%7%9%F%`(BDB$B$K@\B3$9$k$H$-$N%f!<%6L>$G$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
system_db_password +
+

+$B%7%9%F%`(BDB$B$K@\B3$9$k$H$-$N%Q%9%o!<%I$G$9!#%Q%9%o!<%I$r@_Dj$7$F$$$J$$>l9g(B +$B$O6uJ8;z$K$7$F$*$-$^$9!#(B +$B$3$N%Q%i%a!<%?$rJQ99$7$?;~$K$O(B pgpool-II $B$r:F5/F0$7$F$/$@$5$$!#(B +

+ +
+ +

$B%7%9%F%`(BDB$B$N=i4|@_Dj(B

+

+$B%7%9%F%`(BDB$B$K%9%-!<%^$H%F!<%V%k$r:n@.$7$^$9!#=i4|@_DjMQ$N%9%/%j%W%H$,(B +$prefix/share/system_db.sql$B$K$"$k$N$G$=$l$rMxMQ$7$^$9!#$?$@$7!"$3$N%9%/(B +$B%j%W%H$G$O%9%-!<%^L>$,(B"pgpool_catalog"$B$H$J$C$F$$$k$N$G!"0c$&%9%-!<%^$r;H(B +$B$&>l9g$OE,Ev$K=q$-49$($F$/$@$5$$!#$^$?!"%G!<%?%Y!<%9L>$H$7$F(B"pgpool"$B0J30(B +$B$r;H$&>l9g$O0J2<$rE,Ev$KFI$_BX$($F$/$@$5$$!#(B +

+psql -f $prefix/share/system_db.sql pgpool +

+ +

dblink$B$N%$%s%9%H!<%k(B

+

+$B%Q%i%l%k%b!<%I$G$O(Bdblink$B$r;H$$$^$9!#(Bdblink$B$O(BPostgreSQL$B%=!<%9%U%!%$%k(B +($POSTGRES_SRC) +

+
+$(POSTGRES_SRC)/contrib/dblink
+
+

+$B$K$"$j$^$9!#(B$POSTGRES_SRC/contrib/dblink/README.dblink$B$r;29M$K%7%9%F%`(B +DB$B$K(Bdblink$B$r%$%s%9%H!<%k$7$F$/$@$5$$!#(B +$B$^$?!"(Bpgpool$B%G!<%?%Y!<%9$K4X?t$NEPO?$,I,MW$G$9!#(B +

+
+psql pgpool < $POSTGRES_SRC/contrib/dblink/dblink.sql
+
+ +

$B%3%M%/%7%g%s?t$N@_Dj(B

+

+$B%Q%i%l%k%b!<%I$G$O!"%/%(%j$K$h$j%7%9%F%`(BDB$B$+$i(Bdblink$B7PM3$G(Bpgpool$B$K@\B3(B +$B$9$k$N$G!"A[Dj$5$l$kF1;~@\B3?t0J>e$N%3%M%/%7%g%s$,I,MW$K$J$k>l9g$,$"$j(B +$B$^$9!#$=$N$?$a!"(Bpgpool.conf$B$N(Bnum_init_children$B$K$OF1;~@\B3?t$h$j==J,Bg(B +$B$-$$CM$r@_Dj$7$F2<$5$$!#(B +

+

+$BL\0B$H$7$F0J2<$N<0$G(Bnum_init_children$B$r@_Dj$7$F$/$@$5$$!#(B +

+
+num_init_children = $BA[Dj$5$l$kF1;~@\B3?t(B * ( 1 + $B%/%(%j$NCf$G;H$o$l$F$$$k%F!<%V%k$N:GBg?t(B)
+
+ +

$B%G!<%?J,3d%k!<%k$NEPO?(B

+

+$B%G!<%?J,3d$r9T$&%F!<%V%k$KBP$7$F$O!"%F!<%V%k>pJs$r$"$i$+$8$a(B pgpool_catalog.dist_def +$B$H$$$&%F!<%V%k$KEPO?$7$F$*$-$^$9!#(B +

+ +
+CREATE TABLE pgpool_catalog.dist_def(
+	dbname TEXT,	-- DB$BL>(B
+	schema_name TEXT,	--schema$BL>(B
+	table_name TEXT,	-- $B%F!<%V%kL>(B
+	col_name TEXT NOT NULL CHECK (col_name = ANY (col_list)),	-- $BJ,;6%-!(B
+	col_list TEXT[] NOT NULL,	-- table$B$NB0@-L>(B
+	type_list TEXT[] NOT NULL,	-- $BB0@-$N%?%$%WL>(B
+	dist_def_func TEXT NOT NULL,	-- $BJ,;6@h$N(BDB$B%N!<%I$r7hDj$9$k4X?tL>(B
+	PRIMARY KEY (dbname,schema_name,table_name)
+);
+
+

$B%l%W%j%1!<%7%g%s%F!<%V%k$N%k!<%kEPO?(B

+

+$B0l$D$N(BSQL$BJ8$K(BJOIN$BEy$G%G!<%?J,3d%k!<%k$KEPO?$7$?%F!<%V%k$H6&$K(B +$B%l%W%j%1!<%7%g%s$r9T$&%F!<%V%k$r;XDj$9$k>l9g$K$O!"%l%W%j%1!<%7%g%s(B +$B$r9T$&%F!<%V%k$N>pJs$r$"$i$+$8$a!"(Bpgpool_catalog.replicate_def +$B$H$$$&%F!<%V%k$KEPO?$7$F$*$-$^$9!#(B +

+ +
+CREATE TABLE pgpool_catalog.replicate_def(
+	dbname TEXT,	-- DB$BL>(B
+	schema_name TEXT,	--schema$BL>(B
+	table_name TEXT,	-- $B%F!<%V%kL>(B
+	col_list TEXT[] NOT NULL,	-- table$B$NB0@-L>(B
+	type_list TEXT[] NOT NULL,	-- $BB0@-$N%?%$%WL>(B
+	PRIMARY KEY (dbname,schema_name,table_name)
+);
+
+ +

+ +

+pgbench$B$N%F!<%V%k$rJ,3d$9$k%k!<%k$NNc$r<($7$^$9!#(B +

+

+$B$3$NNc$G$O!"(Baccounts$B%F!<%V%k$KBP$7$F$OJ,3d$r9T$$!"(Bbranches$B%F!<%V%k(B +$B$H(Btellers$B%F!<%V%k$KBP$7$F$O%l%W%j%1!<%7%g%s$r9T$&$3$H$K$7$^$9!#(B +$B$^$?!"(Baccounts$B%F!<%V%k$H(Bbanches$B%F!<%V%k$O(Bbid$B$G7k9g$5$l$k$3$H$rA[Dj$7(B +branches$B%F!<%V%k$O%l%W%j%1!<%7%g%s%F!<%V%k$N%k!<%kEPO?$r9T$$$^$9!#(B + +$B$b$7!"(Baccounts$B%F!<%V%k!"(Bbranches$B%F!<%V%k$H(Btellers$B%F!<%V%k$N#3$D$N(B +$B%F!<%V%k$N7k9g$,9T$o$l$k>l9g$K$O!"$"$i$+$8$a(Btellers$B%F!<%V%k$KBP$7$F$b(B +$B%l%W%j%1!<%7%g%s%F!<%V%k$N%k!<%kEPO?$r9T$&I,MW$,$"$j$^$9!#!!(B +

+ + +
+INSERT INTO pgpool_catalog.dist_def VALUES (
+	'pgpool',
+	'public',
+	'accounts',
+	'aid',
+	ARRAY['aid','bid','abalance','filler'],
+	ARRAY['integer','integer','integer','character(84)'],
+	'pgpool_catalog.dist_def_accounts'
+);
+
+INSERT INTO pgpool_catalog.replicate_def VALUES (
+	'pgpool',
+	'public',
+	'branches',
+	ARRAY['bid','bbalance','filler'],
+	ARRAY['integer','integer','character(84)']
+);
+
+ +

+$B$3$3$G!"(Bpgpool_catalog.dist_def_accounts$B$O!"0z?t$H$7$FJ,3d%-!<$NCM$r +

+CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_accounts (val ANYELEMENT) RETURNS INTEGER AS '
+  SELECT CASE WHEN $1 >= 1 and $1 <= 30000 THEN 0
+	      WHEN $1 > 30000 and $1 <= 60000 THEN 1
+	      ELSE 2
+  END' LANGUAGE SQL;
+
+ +

$B%/%i%$%"%s%HG'>Z(B(HBA)$B$N$?$a$N(B pool_hba.conf $B@_DjJ}K!(B

+

+ PostgreSQL$B$N(Bpg_hba.conf$B$HF1$8$h$&$K(Bpgpool$B$G$b(Bpool_config.conf$B%U%!%$(B + $B%k$r;H$C$?%/%i%$%"%s%HG'>Z$,%5%]!<%H$5$l$F$$$^$9!#(B +

+

+ pgpool$B$r%$%s%9%H!<%k$9$k$H%G%U%)%k%H%$%s%9%H!<%k@h$N@_Dj%U%!%$%k%G%#(B + $B%l%/%H%j(B"/usr/local/etc"$B$K(Bpool_hba.conf.sample$B$,0l=o$K%$%s%9%H!<%k(B + $B$5$l$^$9!#$3$N(Bpool_hba.conf.sample$B%U%!%$%k$r(Bpool_hba.conf$B$H$7$F%3%T!<(B + $B$7!"I,MW$G$"$l$PJT=8$7$F$/$@$5$$!#%G%U%)%k%H$G$O(Bpool_hba$B$K$h$kG'>Z$OM-(B + $B8z$K$J$C$F$$$^$9!#(B +

+

+ pool_hba.conf$B$N%U%)!<%^%C%H$O(Bpg_hba.conf$B$N$b$N$H$[$H$s$IF1$8$G$9!#(B +

+
+     local      DATABASE  USER  METHOD  [OPTION]
+     host       DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
+
+

+ $B3F%U%#!<%k%I$G@_Dj$G$-$kCM$N>\:Y$O(B"pool_hba.conf.sample"$B$r;2>H$7$F(B + $B$/$@$5$$!#(B +

+

+ $B0J2<$O(Bpool_hba$B$N@)8B;v9`$G$9!#(B + +

    +
  • "hostssl"$B@\B3%?%$%W$O%5%]!<%H$5$l$^$;$s(B
  • +

    + $B8=:_(Bpgpool$B$O(BSSL$B@\B3$r%5%]!<%H$7$F$$$J$$$N$G(B"hostssl"$B$O;XDj$9$k$3(B + $B$H$,$G$-$^$;$s!#(B +

    +
  • DATABASE$B%U%#!<%k%ICM$H$7$F(B"samegroup"$B$O%5%]!<%H$5$l$^$;$s(B
  • +

    + pgpool$B$O%P%C%/%(%s%I%5!<%P$K$"$k%f!<%6>pJs$r;vA0$KCN$k;v$,$G$-$J(B + $B$$$?$a!"%G!<%?%Y!<%9L>$O(Bpool_hba.conf$B$K$"$kCM$N$_$HHf3S$5$l$^$9!#(B + $B$J$N$G%0%k!<%W$K4X$9$kG'>Z$O(Bpool_hba$B$G9T$&$3$H$,$G$-$^$;$s!#(B +

    +
  • USER$B%U%#!<%k%ICM$H$7$F(B"+"$B$r;H$C$?%0%k!<%W;XDj$O%5%]!<%H$5$l$^$;$s(B
  • +

    + $B>e5-$N(B"samegroup"$B$HF1$8M}M3$G!"%f!<%6L>$O(Bpool_hba.conf$B$K$"$kCM$N(B + $B$_$HHf3S$5$l$^$9!#%0%k!<%W$K4X$9$kG'>Z$O(Bpool_hba$B$G9T$&$3$H$O$G$-(B + $B$^$;$s!#(B +

    +
  • IPv6$B%"%I%l%9(B/$B%^%9%/I=5-K!$O%5%]!<%H$5$l$^$;$s(B
  • +

    + $B8=:_(Bpgpool$B$O(BIPv6$B$r%5%]!<%H$7$F$$$^$;$s!#(B +

    +
  • "trust", "reject", "pam"$B0J30$N%a%=%C%I$O%5%]!<%H$5$l$^$;$s(B
  • +

    + $B$3$l$b>e5-$N(B"samegroup"$B$HF1$8M}M3$K$h$k$b$N$G$9!#(Bpgpool$B$O%P%C%/%((B + $B%s%I$N%f!<%6(B/$B%Q%9%o!<%I>pJs$r;}$C$F$$$J$$$N$G!"%P%C%/%(%s%I$KJ]B8(B + $B$5$l$F$$$k%Q%9%o!<%I$r;H$C$?G'>Z$r9T$&$3$H$,$G$-$^$;$s!#(B +

    +
+

+

+ $B$3$3$G@bL@$5$l$?5!G=!"@)8B$O%/%i%$%"%s%H$H(Bpgpool$B4V$G9T$o$l$k%/%i%$(B + $B%"%s%HG'>Z$K$D$$$F$@$H$$$&$3$H$KCm0U$7$F$/$@$5$$!#%/%i%$%s%"%s%H$O(B + pgpool$B$N%/%i%$%"%s%HG'>Z$K@.8y$7$?$H$7$F$b!"(BPostgreSQL$B$K$h$k%/%i%$(B + $B%"%s%HG'>Z$K@.8y$7$J$$$H@\B3>uBV$H$J$j$^$;$s!#(Bpool_hba$B$K$H$C$F$O%/(B + $B%i%$%"%s%H$K;XDj$5$l$?%f!<%6L>$d%G!<%?%Y!<%9L>(B + ($BNc(B. psql -U testuser testdb)$B$,e$KB8:_$9$k$+$I$&(B + $B$+$OLdBj$G$O$"$j$^$;$s!#$=$l$,(Bpool_hba.conf$B$NCM$H%^%C%A$9$k$+$I$&$+(B + $B$G%A%'%C%/$,9T$o$l$^$9!#(B +

+

+ pgpool$B$,2TF/$9$k%[%9%H>e$N%f!<%6>pJs$r;H$C$?(BPAM$BG'>Z$rMxMQ$9$k$3$H$,(B + $B$G$-$^$9!#(Bpgpool$B$r(BPAM$B%5%]!<%HIU$-$G%S%k%I$9$k$K$O(Bconfigure$B%*%W%7%g(B + $B%s$K(B"--with-pam"$B$r;XDj$7$F$/$@$5$$!#(B +

+
+     ./configure --with-pam
+
+

+ $BZ$rM-8z$K$9$k$K$O!"(Bpool_hba.conf$B$G(B"pam"$B%a%=%C%I$r@_Dj$9(B + $B$k$N$K2C$(!"(Bpgpool$B$N%5!<%S%9@_Dj%U%!%$%k$r%7%9%F%`$N(BPAM$B@_Dj%G%#%l%/%H(B + $B%j!JDL>o$O(B /etc/pam.d $B$K:n@.$9$kI,MW$,$"$j$^$9!#%5!<%S%9@_Dj%U%!%$(B + $B%k$NNc$O%$%s%9%H!<%k%G%#%l%/%H%j$N(B"share/pgpool.pam"$B$r;29M$K$7$F$/(B + $B$@$5$$!#(B +

+ +

$B%/%(%j%-%c%C%7%e$N@_DjJ}K!(B

+ +

+ pgpool-II$B$G$O!"$9$Y$F$N%b!<%I$G%/%(%j%-%c%C%7%e$rMxMQ$9$k$3$H$,$G$-$^$9!#(B + $BMxMQ$9$k>l9g$K$O!"(Bpgpool.conf$B$N@_Dj$r0J2<$N$h$&$K@_Dj$7$^$9!#(B +

+enable_query_cache = true
+
+

+$B$^$?!"%7%9%F%`(BDB$B$K0J2<$N%F!<%V%k$r:n@.$7$F$/$@$5$$!#(B +

+
+CREATE TABLE pgpool_catalog.query_cache (
+  hash TEXT,
+  query TEXT,
+  value bytea,
+  dbname TEXT,
+  create_time TIMESTAMP WITH TIME ZONE,
+  PRIMARY KEY(hash, dbname)
+);
+
+

+$B$?$@$7!"$3$NNc$G$O%9%-!<%^L>$,(B"pgpool_catalog"$B$H$J$C$F$$$k$N$G!"0c$&%9%-!<%^$r;H$&>l9g$OE,Ev$K=q$-49$($F$/$@$5$$!#(B +

+ + +

pgpool-II$B$N5/F0$HDd;_(B

+

+$B0J>e$G@_Dj$,=*$o$C$?$N$G!"3F(BDB$B%N!<%I$r5/F0$7!"I,MW$J$i$P%7%9%F%`(BDB$B$b5/F0(B +$B$7$F$+$i(Bpgpool-II$B$r5/F0$7$^$9!#(B +

+pgpool [-c][-f config_file][-a hba_file][-F pcp_config_file][-n][-d]
+
+

+

+ + + + + + +
-c$B%/%(%j%-%c%C%7%e$r>C5n$7$^$9(B
-f config_filepgpool-II$B$N@_Dj%U%!%$%k$r;XDj$7$^$9(B
-a hba_fileHBA$BG'>Z@_Dj%U%!%$%k$r;XDj$7$^$9(B
-F pcp_config_filepcp$B$N@_Dj%U%!%$%k$r;XDj$7$^$9(B
-n$B%G!<%b%s%b!<%I$G5/F0$7$^$;$s(B($B@)8fC +
-d$B%G%P%C%0%b!<%I$G5/F0$7$^$9(B
+

+

+pgpool-II$B$NDd;_$O8e=R$N(Bpcp$B%3%^%s%I$G$b$G$-$^$9$,!"(Bpgpool-II$B%3%^%s%I$r;H$&$3$H(B +$B$b$G$-$^$9!#(B +

+
+pgpool [-f config_file][-F pcp_config_file] [-m {s[mart]|f[ast]|i[mmediate]}] stop
+
+ +

+ + + + +
-m s[mart]$B@\B3Cf$N%/%i%$%"%s%H$,@\B3$r=*$o$k$N$rBT$C$F$+$iDd;_$7$^$9(B($B%G%U%)%k%H(B)
-m f[ast]$B@\B3Cf$N%/%i%$%"%s%H$,@\B3$r=*$o$k$N$rBT$?$:$KD>$A$KDd;_$7$^$9(B
-m i[mmediate]-m f$B$HF1$8F0:n$G$9(B
+

+ +

pgpool-II$B$N@_Dj%U%!%$%k$N:FFI$_9~$_(B

+

+pgpool-II$B$N@_Dj%U%!%$%k$O!"(Bpgpool-II$B$r:F5/F0$9$k$3$H$J$/FI$_D>$9$3$H$,$G$-$^$9!#(B +

+pgpool [-f config_file][-a hba_file][-F pcp_config_file] reload
+
+

+

+ + + + +
-f config_filepgpool-II$B$N@_Dj%U%!%$%k$r;XDj$7$^$9(B
-a hba_fileHBA$BG'>Z@_Dj%U%!%$%k$r;XDj$7$^$9(B
-F pcp_config_filepcp$B$N@_Dj%U%!%$%k$r;XDj$7$^$9(B
+

+

+$B@_Dj9`L\$K$h$C$F$O!":FFI$_9~$_$r9T$J$C$F$bH?1G$5$l$J$$$b$N$,$"$k$N$G!"$4Cm0U2<$5$$!#(B +$B$^$?!"@_Dj$NJQ99$O$9$G$K@\B3Cf$N%;%C%7%g%s$K$OH?1G$5$l$^$;$s!# + +

$B%*%s%i%$%s%j%+%P%j(B

+

$B%*%s%i%$%s%j%+%P%j35MW(B

+

+ $B%l%W%j%1!<%7%g%s%b!<%I$G(B pgpool $B$,F0:n$7$F$$$k>l9g!"%@%&%s$7$?%N!<(B + $B%I$N%G!<%?$r:FF14|$5$;$?>e$G!"%N!<%I$rI|5"$5$;$k$3$H$,$G$-$^$9!#$3(B + $B$N5!G=$r!V%*%s%i%$%s%j%+%P%j!W$H8F$S$^$9!#(B +

+ +

+ $B%*%s%i%$%s%j%+%P%j$rl9g$K(B + $B$O(B pgpool.conf $B$N(B backend_hostname$B$J$I$N%Q%i%a!<%?$rDI2C$7$F$*$-!"@_Dj%U%!%$%k(B + $B$r:FFI$_9~$_$5$;$k$H!"%N!<%I$,@Z$jN%$5$l$?>uBV$G(B pgpool $B$K%N!<%I>pJs$,EPO?$5$l$^$9!#(B +

+ +

+ $B$^$?!"%j%+%P%j$9$k%N!<%I$N(B PostgreSQL $B$,$9$G$KF0:nCf$G$"$l$P!"$"$i(B + $B$+$8$a(B PostgreSQL $B$r%7%c%C%H%@%&%s$5$;$F$*$$$F$/$@$5$$!#(B +

+ +

+$BCm0U(B: $B%*%s%i%$%s%j%+%P%j$re$G$N(Bautovacuum$B$rDd;_$7$F$/$@$5$$!#(B +$B%*%s%i%$%s%j%+%P%jCf$K(Bautovacuum$B$,F0$/$H!"%G!<%?%Y!<%9$NFbMF$,JQ2=$9$k2DG=@-$,$"$k$?$a!"(B +$B%N!<%I4V$NF14|$,$-$A$s$H +

+ +

+ pgpool $B$G$O%*%s%i%$%s%j%+%P%j$r(B 2 $BCJ3,$KJ,$1$F +

  • CHECKPOINT $B $B%U%!!<%9%H%9%F!<%8$N $B@\B3$,$9$Y$F@ZCG$5$l$k$^$GBT5!(B +
  • CHECKPOINT $B $B%;%+%s%I%9%F!<%8$N postmaster $B$N5/F0(B(pgpool_remote_start $B$N $B%N!<%I$NI|5"(B + +

    + +

    + $B%G!<%?F14|$NBh0lCJ3,$r!V%U%!!<%9%H%9%F!<%8!W$H8F$S$^$9!#%U%!!<%9%H(B + $B%9%F!<%8Cf$K(B1 $B2sL\$N%G!<%?F14|$r9T$$$^$9!#%U%!!<%9%H%9%F!<%8Cf$O%G!<(B + $B%?$N99?7$d;2>H$rJB9T$7$F9T$&$3$H$,$G$-$^$9!#(B +

    + +

    + $B%U%!!<%9%H%9%F!<%8$G=hM}$9$kFbMF$O%f!<%6$,Dj5A$9$k$3$H$,$G$-$^$9!#(B + $B%9%/%j%W%H$G$O(B 3 $B$D$N0z?t$r +

  • $B%^%9%?$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B +
  • $B%j%+%P%j%N!<%I$N%[%9%HL>(B +
  • $B%j%+%P%j%N!<%I$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B + +

    + +

    + $Bl9g(B + $B$K$O!"$=$N@\B3$r$9$Y$F%V%m%C%/$7$^$9!#(B +

    + +

    + $B%;%+%s%I%9%F!<%8$G=hM}$9$kFbMF$O%f!<%6$,Dj5A$9$k$3$H$,$G$-$^$9!#(B + $B%9%/%j%W%H$G$O(B 3 $B$D$N0z?t$r +

      +
    1. $B%^%9%?$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B +
    2. $B%j%+%P%j%N!<%I$N%[%9%HL>(B +
    3. $B%j%+%P%j%N!<%I$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B +
    +

    + $B$9$Y$F$N@\B3$,=*N;$5$l$k$H!"%U%!!<%9%H%9%F!<%80J9_$K99?7$5$l$?%G!<(B + $B%?$rF14|$9$k$?$a$N%;%+%s%I%9%F!<%8$,3+;O$5$l$^$9!#$=$3$G:G=*E*$J%G!<(B + $B%?$NF14|$r9T$$$^$9!#$3$N4V$O%/%i%$%"%s%H$+$i$O(B pgpool $B$X$N@\B3$,BT(B + $B$?$5$l$k>uBV$K$J$j$^$9!#(B +

    + +

    + + $B$J$*!"%*%s%i%$%s%j%+%P%j$N@)8B;v9`$H$7$F!"J#?t$N%[%9%H$K(B pgpool $B$r(B + $BG[CV$7$F%l%W%j%1!<%7%g%s$5$;$F$$$k>l9g$K$O!"%*%s%i%$%s%j%+%P%j$O@5(B + $B$7$/F0:n$7$^$;$s!#$I$l$+$N(B pgpool $B$K%j%+%P%j%j%/%(%9%H$r=P$7$?;~$K!"(B + $BB>$N(B pgpool $B$+$i99?7$,EAHB$9$k$H!"%G!<%?$rF14|$5$;$k$3$H$,$G$-$J$/(B + $B$J$j$^$9!#(B + +

    + +

    pgpool $B$N@_Dj(B

    +

    + $B%*%s%i%$%s%j%+%P%j$r@_Dj$9$k$?$a$K$O!"(Bpgpool.conf $B$N0J2<$NCM$r@_Dj(B + $B$7$F$/$@$5$$!#(B + +

      +
    • backend_data_directory +
    • recovery_user +
    • recovery_password +
    • recovery_1st_stage_command +
    • recovery_2nd_stage_command +
    +

    + + +

    C $B8@8l4X?t$N%$%s%9%H!<%k(B

    +

    +$B + +

    +  pgpool-II-x.x.x/sql/pgpool-recovery/
    +
    + +

    +$B$K$"$j$^$9!#%G%#%l%/%H%j$r0\F0$7!"(Bmake install $B$7$F$/$@$5$$!#(B +

    + +
    +  % cd pgpool-II-x.x.x/sql/pgpool-recovery/
    +  % make install
    +
    + +

    +C $B8@8l4X?t$N%b%8%e!<%k$r%$%s%9%H!<%k$7$?$i!"B3$$$F(B C $B8@8l4X?t$r8F$S$@(B +$B$9$?$a$N(B SQL $B$r%$%s%9%H!<%k$7$^$9!#(B +

    + +
    +  % cd pgpool-II-x.x.x/sql/pgpool-recovery/
    +  % psql -f pgpool-recovery.sql template1
    +
    + + +

    $B%j%+%P%j%9%/%j%W%H$NG[CV(B

    +

    +$B%G!<%?$rF14|$5$;$k$?$a$N%9%/%j%W%H$H!"%j%b!<%H$+$i(B postmaster $B$r:F5/F0(B +$B$5$;$k$?$a$N%9%/%j%W%H$r3F%N!<%I$N(B $PGDATA $B0J2<$KG[CV$7$^$9!#$"$i$+$8(B +$B$a(Bpgpool-II-x.x.x/sample $B0J2<$K%5%s%W%k%9%/%j%W%H$bMQ0U$7$F$"$j$^$9$N(B +$B$G;29M$K$7$F$/$@$5$$!#$3$3$G$O%5%s%W%k%9%/%j%W%H$r;H$C$F!"(BPITR $B$K$h$k(B +$B%j%+%P%jJ}K!$H!"(Brsync $B$K$h$k%j%+%P%jJ}K!$r@bL@$7$^$9!#(B +

    + +

    PITR $B$K$h$k%j%+%P%j(B

    +

    +$B$3$3$G$O(B PostgreSQL $B$N(B PITR $B5!G=$r;H$C$F%j%+%P%j$r$9$k@_DjNc$r@bL@$7$^(B +$B$9!#(BPITR $B$K$h$k%j%+%P%j$r$9$k>l9g$K$O$"$i$+$8$a(B PostgreSQL $B$N@_Dj$G%m(B +$B%0$r%"!<%+%$%V$5$;$k$h$&$K$7$F$*$$$F$/$@$5$$!#(B +

    + +

    +$B$^$:%U%!!<%9%H%9%F!<%8$G%Y!<%9%P%C%/%"%C%W$r$r(B copy-base-backup $B$H$7$^$9(B)$B$rMQ0U$7(B +$B$^$9!#Nc$($P0J2<$N$h$&$J%9%/%j%W%H$G + +

    +  #! /bin/sh
    +
    +  DATA=$1
    +  RECOVERY_TARGET=$2
    +  RECOVERY_DATA=$3
    +
    +  psql -c "select pg_start_backup('pgpool-recovery')" postgres
    +  echo "restore_command = 'scp $HOSTNAME:/data/archive_log/%f %p'" > /data/recovery.conf
    +  tar -C /data -zcf pgsql.tar.gz pgsql
    +  psql -c 'select pg_stop_backup()' postgres
    +  scp pgsql.tar.gz $RECOVERY_TARGET:$RECOVERY_DATA
    +
    + +

    +$B%Y!<%9%P%C%/%"%C%W +

    +restore_command = 'scp master:/data/archive_log/%f %p'
    +
    + +

    + +

    +$B%;%+%s%I%9%F!<%8$G$O:G?7$N>uBV$^$G(B PITR $B$K$h$k%j%+%P%j$r + +

    +  #! /bin/sh
    +  psql -c 'select pg_switch_xlog()' postgres
    +
    + +

    +$B%9%/%j%W%H$NG[CV$,40N;$7$?$i(B pgpool.conf $B$K@_Dj$7$^$9!#(B + +

    +recovery_1st_stage_command = 'copy-base-backup'
    +recovery_2nd_stage_command = 'pgpool_recovery_pitr'
    +
    + +

    + +

    +$B$3$l$G(B PITR $B$K$h$k%*%s%i%$%s%j%+%P%j$N=`Hw$,40N;$G$9!#(B +

    + +

    pgpool_remote_start

    +

    +$B%G!<%?:FF14|8e$K(B postmaster $B$r5/F0$5$;$k%9%/%j%W%H$G$9!#(B +pgpool $B$+$i$O0J2<$N7A<0$G%9%/%j%W%H$r + +

    +  % pgpool_remote_start remote_host remote_datadir
    +  remote_host:    $B%j%+%P%j%N!<%I$N%[%9%HL>(B
    +  remote_datadir: $B%j%+%P%j%N!<%I$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B 
    +
    + +

    +$B%5%s%W%k%9%/%j%W%H$G$O(B ssh $B7PM3$G(B postmaster $B$r5/F0$7$F$$$^$9!#$3$A$i(B +$B$b$"$i$+$8$a%Q%9%U%l!<%:L5$7$G(B ssh $B7PM3$G%m%0%$%s$G$-$k$h$&$K@_Dj$7$F(B +$B$*$/I,MW$,$"$j$^$9!#(B +

    + +

    +PITR $B$K$h$k%j%+%P%j$G$"$l$P!"(Bpgpool_remote_start $BFb$G%Y!<%9%P%C%/%"%C(B +$B%W$rE83+$7!"(Brecovery.conf $B$NFbMF$K$7$?$,$C$F%j%+%P%j$7$?8e$K(B +postmaster $B$,@\B32DG=>uBV$K$J$j$^$9!#(B +

    + +
    +#! /bin/sh
    +DEST=$1
    +DESTDIR=$2
    +PGCTL=/usr/local/pgsql/bin/pg_ctl
    +
    +# Expand a base backup
    +ssh -T $DEST 'cd /data/; tar zxf pgsql.tar.gz' 2>/dev/null 1>/dev/null < /dev/null
    +# Startup PostgreSQL server
    +ssh -T $DEST $PGCTL -w -D $DESTDIR start 2>/dev/null 1>/dev/null < /dev/null &
    +
    + +

    rsync $B$K$h$k%j%+%P%j(B

    +

    +7.4 $B0JA0$N>l9g$O(B PITR $B5!G=$,$"$j$^$;$s!#$=$3$G(B PITR $B$r;H$o$:$K(B rsync +$B$r;H$C$?%j%+%P%jJ}K!$r@bL@$7$^$9!#(Bsample $B%G%#%l%/%H%j$K(B +pgpool_recovery $B$H$$$&%U%!%$%k$,$"$j$^$9!#%^%9%?$+$iI|5"$5$;$k%N!<%I$X(B +$B$N%G!<%?$NJ*M}%3%T!<$r9T$&%9%/%j%W%H$G$9!#(Bpgpool $B$+$i$O0J2<$N7A<0$G%9(B +$B%/%j%W%H$r + +

    +  % pgpool_recovery datadir remote_host remote_datadir
    +  datadir:        $B%^%9%?$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B
    +  remote_host:    $B%j%+%P%j%N!<%I$N%[%9%HL>(B
    +  remote_datadir: $B%j%+%P%j%N!<%I$N%G!<%?%Y!<%9%/%i%9%?%Q%9(B 
    +
    + +

    +$B%5%s%W%k%9%/%j%W%H$G$O(B rsync $B$r;H$C$FJ*M}%3%T!<$r$7$F$$$^$9!#$b$7(B +rsync $B$r;H$&>l9g$O!"%Q%9%U%l!<%:L5$7$G(B ssh $B7PM3$G%m%0%$%s$G$-$k$h$&$K(B +$B$"$i$+$8$a@_Dj$7$F$*$/I,MW$,$"$j$^$9!#(B +

    + +

    +rsync$B$K4X$9$kCm5-(B: +

      + +
    • -z (or --compress)$B%*%W%7%g%s$ODcB.$J%M%C%H%o!<%/$G$O8z2L$,$"$j$^$9$,!"(B + 100M$B0J>e$N9bB.$J%M%C%H%o!<%/$G$O$+$($C$F(BCPU$BIi2Y$rA}$d$7!"7k2LE*$KCY$/$J$k$3$H$,$"$j$^$9!#(B + $B9bB.%M%C%H%o!<%/$G$O!"$3$N%*%W%7%g%s$r;HMQ$7$J$$$3$H$r$*4+$a$7$^$9!#(B + +
    • rsync $B$N?7$7$$%P!<%8%g%s(B(3.0.5)$B$G$O!"(B50%$B$b@-G=$,NI$/$J$C$?$H$$$&Js9p$,(B + pgpool-general$B%a!<%j%s%0%j%9%H$G$"$j$^$7$?!#(B +
    +

    + +

    +pgpool_recovery $B$r;H$&>l9g$O(B pgpool.conf $B$K0J2<$N9T$rDI2C$7$F$/$@$5$$!#(B + +

    +recovery_1st_stage_command = 'pgpool_recovery'
    +recovery_2nd_stage_command = 'pgpool_recovery'
    +
    +

    + +

    $B%j%+%P%j$N +

    +$B0J>e$G%*%s%i%$%s%j%+%P%j$N=`Hw$,@0$$$^$7$?!#(B +$B%*%s%i%$%s%j%+%P%j$r + +

    +$BCm0UE@$H$7$F!"(Bpcp_recovery_node $B$rl9g$O(B pgmgt.conf.php $BFb$N(B +_PGPOOL2_PCP_TIMEOUT $B$rBg$-$/$7$F$/$@$5$$!#(B +

    + + +

    $B@)8B;v9`(B

    +

    +

    $BG'>Z!&%"%/%;%9@)8fJ}<0(B

    +

    +

      +
    • $B%l%W%j%1!<%7%g%s%b!<%I$^$?%^%9%?(B/$B%9%l!<%V%b!<%I;~$K$O(Btrust, reject, clear + text password, pam, $BG'>ZJ}<0$@$1$,MxMQ$G$-$^$9!#(Bmd5$BG'>Z!"(Bcrypt$BG'>Z$J$I$NG'>ZJ}<0$OMxMQ$G$-$^$;$s!#(B +
    • $B$=$l0J30$N%b!<%I$G$O!"(Btrust, reject, clear text password, pam, crypt, md5$BG'>ZJ}<0$@$1$,MxMQ$G$-$^$9!#(B +
    +

    + +

    $B%l%W%j%1!<%7%g%s%b!<%I$GCm0U$,I,MW$J4X?t$J$I(B

    +

    +pgpool-II$B$G$OF1$8Ld$$9g$o$;$rAw$C$F$b0[$J$k7k(B + $B2L$rJV$9$h$&$J%G!<%?!"$?$H$($PMp?t$d%H%i%s%6%/%7%g%s(BID$B!"(BOID$B!"(BSERIAL$B!"(B + $B%7!<%1%s%9!"(BCURRENT_TIMETSTAMP$B$N$h$&$J$b$N$K4X$7$F$O%l%W%j%1!<%7%g(B + $B%s$O$7$^$9$,!"(B2$BBf$N%[%9%H$G$^$C$?$/F1$8CM$,%3%T!<$5$l$kJ]>Z$O$"$j$^(B + $B$;$s!#(B +

    +

    +CREATE TEMP TABLE$B$G:n@.$5$l$?%F!<%V%k$O%U%m%s%H%(%s%I$,%;%C%7%g(B + $B%s$r=*N;$7$F$b:o=|$5$l$^$;$s!#$3$l$O!"%3%M%/%7%g%s%W!<%k$N8z(B + $B2L$G%P%C%/%(%s%I$+$i8+$k$H%;%C%7%g%s$,7QB3$7$F$$$k$h$&$K8+$((B + $B$k$+$i$G$9!#%;%C%7%g%s$N=*N;;~$KL@<(E*$K(BDROP TABLE$B$9$k$+!"%H(B + $B%i%s%6%/%7%g%s%V%m%C%/$NCf$G(BCREATE TEMP TABLE ... ON COMMIT + DROP$B$r$*;H$$2<$5$$!#(B +

    + +

    $B%/%(%j$K$D$$$F(B

    +

    +pgpool-II $B$G$O07$&$3$H$,$G$-$J$$%/%(%j$K$D$$$F@bL@$7$^$9!#(B +

    + +

    $B%^%k%A%P%$%HJ8;z$K$D$$$F(B

    +

    +$B@)8BBP>](B:$BA4%b!<%I(B +

    +

    +$B8=:_$N + +

    $B%^%k%A%9%F!<%H%a%s%H(B

    +

    +$B@)8BBP>](B:$BA4%b!<%I(B +

    +

    +$B%^%k%A%9%F!<%H%a%s%H(B(';' $B$G6h@Z$C$FJ#?t$NJ8$r$^$H$a$?(B SQL)$B$r(B pgpool $B$,(B +$B@5$7$/=hM}$9$k$3$H$,$G$-$^$;$s!#I,$:J8$rJ,$1$FAw?.$7$F$/$@$5$$!#(B +

    +

    +$B$J$*!"(Bpsql $B$r;H$C$F(B pgpool $B$K@\B3$7$?>l9g$O!"(Bpsql $BFbIt$G%^%k%A%9%F!<%H(B +$B%a%s%H$rJ,2r$7!"(B1 $B$D$:$DAw?.$7$^$9!#(B +

    + +

    $B3HD%Ld$$9g$o$;%W%m%H%3%k(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +JDBC $B%I%i%$%P$J$I$N$h$&$J3HD%Ld$$9g$o$;%W%m%H%3%k$K$OBP1~$7$F$$$^$;$s!#(B +$BI,$:4J0WLd$$9g$o$;%W%m%H%3%k$r;HMQ$7$F$/$@$5$$!#(B +

    + +

    SELECT

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +postgresql.conf $B$N(B add_missing_from$B@_DjCM$r(B off ($B%G%U%)%k%HCM(B)$B$K@_Dj$7$F$/$@$5$$!#(B +add_missing_from $B@_DjCM$,(B on $B$N;~$K;H$($k%/%(%j$O@5$7$/(Bpgpool$B$G=hM}$5$l$J$$2DG=@-(B +$B$,$"$j$^$9!#(B +

    +

    INSERT

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +$B%G!<%?J,3d$r$7$F$$$k%F!<%V%k$KBP$7$F(BINSERT $B$r9T$&:]$K$O!"J,3d%k!<%k$H$J$kCM$r(B DEFAULT $B$K$O$G$-$^$;$s!#Nc$((B +$B$P%F!<%V%k(B t $B$K(B x $B$H$$$&%+%i%`$,$"$j!"(Bx $B$,J,3d%k!<%k$NBP>]%+%i%`$@$C$?(B +$B>l9g$K$O!"(B +

    +
    +  INSERT INTO t(x) VALUES (DEFAULT);
    +
    +

    +$B$O$G$-$^$;$s!#$^$?!"J,3d%k!<%k$H$J$kCM$,4X?t8F$S=P$7$N>l9g$b(B +$BBP1~$7$F$$$^$;$s!#(B +

    +
    +  INSERT INTO t(x) VALUES (func());
    +
    +

    +$BI,$:L@<(E*$KCM$rM?$($kI,MW$,$"$j$^$9!#(B + +$B$^$?!"(BSELECT INTO $B$d(B INSERT INTO ... SELECT $B$H$$$&7A<0$b%5%]!<%H$7$F$$(B +$B$^$;$s!#(B +

    + +

    UPDATE

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +$BJ,3d%k!<%k$H$J$k%+%i%`$r99?7$9$k$HJ,3d%k!<%k$K=>$C$?%G!<%?$N@09g@-$,Jx(B +$B$l$k2DG=@-$,$"$j$^$9!#(Bpgpool-II $B$G$OFC$K%G!<%?$N:FG[CV$H$$$&$3$H$O9T$$(B +$B$^$;$s!#(B +

    +

    +$B$b$7@)Ls0cH?$J$I$K$h$j0lIt$N%N!<%I$G%(%i!<$K$J$C$?>l9g$K%m!<%k%P%C%/$9(B +$B$k$3$H$O$G$-$^$;$s!#(B +

    +

    +WHERE $B6g$K%G!<%?J,3d$r9T$C$?%F!<%V%k$r;2>H$9$k%5%V%/%(%j$d4X?t8F$S=P$7$,$"$k>l9g$K$O@5$7$/F0$+$J$$2DG=@-$,(B +$B$"$j$^$9!#(B +

    +
    +$BNc!'(BUPDATE branches set bid = 100 where bid = (select max(bid) from beances);
    +
    + +

    SELECT ... FOR UPDATE

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +WHERE $B6g$K%G!<%?J,3d$r9T$C$?%F!<%V%k$r;2>H$9$k%5%V%/%(%j$d4X?t8F$S=P$7$,$"$k>l9g$K$O@5$7$/F0$+$J$$2DG=@-$,(B +$B$"$j$^$9!#(B +

    +$BNc!'(BSELECT * FROM  branches where bid = (select max(bid) from beances) FOR UPDATE;
    +
    +

    + +

    COPY

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +COPY BINARY $B$K$OBP1~$7$F$$$^$;$s!#$^$?!"%U%!%$%k$+$i$N%3%T!<$K$bBP1~$7(B +$B$F$$$^$;$s!#(BCOPY FROM STDIN $B$H(B COPY TO STDOUT $B$N$_BP1~$7$F$$$^$9!#(B +

    + +

    ALTER/CREATE TABLE $B$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +pgpool $B$K>pJs$r99?7$5$;$k$?$a$K$O!"(Bpgpool $B$r:F5/F0$9$kI,MW$,$"$j$^$9!#(B +

    + +

    $B%H%i%s%6%/%7%g%s(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +$B%H%i%s%6%/%7%g%sCf$KH/9T$5$l$k(B SELECT $B$O(B dblink $B$r7PM3$9$k>l9g$K$OJL%H(B +$B%i%s%6%/%7%g%s$K$J$j$^$9!#0J2<$KNc$r<($7$^$9!#(B +

    +
    +  BEGIN;
    +  INSERT INTO t(a) VALUES (1);
    +  SELECT * FROM t ORDER BY a; <-- $B>e$N(B INSERT $B$7$?CM$O8+$($J$$(B
    +  END;
    +
    +

    +$B$^$?@)Ls0cH?$J$I$K$h$j0lIt$N%N!<%I$G%(%i!<$K$J$C$?>l9g$K%m!<%k%P%C%/$9$k$3$H$O$G$-$^$;$s!#(B +

    +

    View/Rule

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +View $B$d(B Rule $B$O3F%N!<%I$KF1$8FbMF$,Dj5A$5$l$^$9!#(B +

    +
    +  CREATE VIEW sample AS SELECT * FROM a, b where a.i = b.i
    +
    +

    +$B>e5-$N$h$&$J(B $B%F!<%V%k7k9g$r4^$s$@(BVIEW$B$O!"(Ba $B$H(B b $B$OF1$8%N!<%IFb$G$N$_7k9g=hM}$r9T$$!"(B +$B3F%N!<%I$+$i$Nl9g$K!"(BVIEW$B$r:n@.$9$k$3$H$O2DG=$G$9!#$3$N>l9g$K$O(BVIEW$B$r(B +pgpool_catalog.dist_def$B%F!<%V%k$K(BVIEW$B$rEPO?$7$F$*$-$^$9!#(B +$B$^$?!"(Bpgpool_catalog.dist_def$B%F!<%V%k$N(Bcol_name$B$H(Bdist_def_func$B$K$O!"(BVIEW$B$GDj5A$7$?(B +$B%+%i%`$H(BVIEW$B$KBP$7$F(BINSERT$B$,H/9T$5$l$?>l9g$K2?=h$N%N!<%I$K%/%(%j$rLd$$9g$o$;$k$N$+$r7hDj(B +$B$9$k4X?t$rEPO?$7$F$/$@$5$$!#(B +

    + +

    $B4X?t(B/$B%H%j%,$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +$B4X?t$O3F%N!<%I$KF1$8FbMF$,Dj5A$5$l$^$9!#4X?tFb$G(B JOIN $B$dB>$N%N!<%I$N%G!<(B +$B%?A`:n$r9T$&$3$H$O$G$-$^$;$s!#(B +

    + +

    Natural Join $B$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +Natural Join$B$OMxMQ$G$-$^$;$s!#(BON $B7k9g>r7o!!$^$?$O!"(BUSING($B7k9g%+%i%`(B)$B$rL@<(E*$K(B +$B;XDj$9$kI,MW$,$"$j$^$9!#(B +

    + +

    USING$B6g(B $B$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +JOIN$B!!9=J8$NCf$GMxMQ$5$l$k(B USING $B6g$O%/%(%j$N=q$-49$(=hM}$K$h$C$F(BON $B6g$K(B +$BJQ49$5$l$^$9!#$=$N$?$a!"%?!<%2%C%H%j%9%H$K(B"*"$B$rMxMQ$9$kLd$$9g$o$;$r9T$&(B +$B>l9g$K$O!"F1$8NsL>$,=PNO$5$l$^$9!#(B +

    + +

    $B%G%C%I%m%C%/$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +$B%N!<%I4V$r$^$?$,$k%G%C%I%m%C%/$r8!=P$9$k$3$H$,$G$-$^$;$s!#(B +

    +
    +$BNc!'(Baccounts$B%F!<%V%k$O0J2<$N%k!<%k$GJ,3d$5$l$F$$$k!#(B
    +    aid <= 100000 $B%N!<%I(B 0
    +    aid >= 100000 $B%N!<%I(B 1
    +
    +  A) BEGIN;
    +  B) BEGIN;
    +  A) SELECT * FROM accounts WHERE aid = 100001 FOR UPDATE;
    +  B) SELECT * FROM accounts WHERE aid = 100000 FOR UPDATE;
    +  A) SELECT * FROM accounts WHERE aid = 100000 FOR UPDATE;
    +  B) SELECT * FROM accounts WHERE aid = 100001 FOR UPDATE;
    +
    +

    +$B$3$N>l9g!"C10l$N%N!<%I$G$O%G%C%I%m%C%/$r8!CN$G$-$J$$$?$a!"(Bpgpool $B$OBT(B +$B$?$5$l$?>uBV$K$J$j$^$9!#$3$N8=>]$O(B SELECT FOR UPDATE $B0J30$K$b9T%m%C%/(B +$B$r3MF@$9$k%/%(%j$GH/@8$9$k2DG=@-$,$"$j$^$9!#(B +

    +

    +$B$^$?!"$"$k%N!<%I$G%G%C%I%m%C%/$,H/@8$7$?>l9g$O!"3F%N!<%I$N%H%i%s%6%/%7%g(B +$B%s$N>uBV$,0[$J$k>u67$K$J$j$^$9!#$=$N$?$a!"%G%C%I%m%C%/$r8!CN$7$?;~E@$G(B +$B0J2<$N%m%0$r=PNO$7$F(B pgpool $B$O3:Ev$N%W%m%;%9$r=*N;$5$;$^$9!#(B +

    +  pool_read_kind: kind does not match between master(84) slot[1] (69)
    +
    + +

    $B%9%-!<%^$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +public $B0J30$N%9%-!<%^$KB0$9$h$&$J%*%V%8%'%/%H$N;2>H$OI,$:(B +

    +
    +  $B%9%-!<%^(B.$B%*%V%8%'%/%H(B
    +
    +

    +$B$H;XDj$9$k$h$&$K$7$F$/$@$5$$!#(B +

    +
    +  set search_path = xxx
    +
    +

    +$B$r;XDj$7!"%9%-!<%^L>$r>JN,$9$k$H!"(Bpgpool $B$,$I$NJ,;6%k!<%k$rE,MQ$9$k$+(B +$BH=CG$G$-$^$;$s!#(B +

    +

    $B%F!<%V%kL>!"%+%i%`L>$K$D$$$F(B

    +

    +$B@)8BBP>](B:$B%Q%i%l%k%b!<%I(B +

    +

    +pool_$B$G;O$^$k%F!<%V%k!"%+%i%`L>$O;H$($^$;$s!#%/%(%j=q$-49$($N:]$KFbIt=hM}$G;HMQ$7$^$9!#(B +

    + +

    $B%7%9%F%`(B DB

    + +

    $BJ,3d%k!<%k(B

    +

    +pgpool-II $B$G$OJ,3d%k!<%k$NBP>]$N%+%i%`$O(B 1 $B$D$N$_$H$7$^$9!#(Bx $B$H(B y $B$N(B +OR $B>r7o$J$I$H$$$C$?$b$N$K$OBP1~$7$F$$$^$;$s!#(B +

    + +

    $B%S%k%I$KI,MW$J4D6-(B

    + +

    libpq

    +

    +pgpool-II $B$G$O(B libpq $B$r%j%s%/$7$^$9!#(Blibpq $B$N%P!<%8%g%s$O(B 2.0 $B$N>l9g!"(B +configure $B$K<:GT$7$^$9!#I,$:(B libpq 3.0 (PostgreSQL 7.4) $B$r%j%s%/$9$k$h(B +$B$&$K$7$F$/$@$5$$!#$^$?!"(BSystemDB $B$N%P!<%8%g%s$b(B PostgreSQL 7.4 $B0J9_$,(B +$BI,?\$K$J$j$^$9!#(B +

    + +

    $B%/%(%j%-%c%C%7%e(B

    +

    +$B8=:_$N%/%(%j%-%c%C%7%e$N + +

    + +

    $B%j%U%!%l%s%9(B

    +

    PCP$B%3%^%s%I%j%U%!%l%s%9(B

    + +

    PCP$B%3%^%s%I0lMw(B

    +

    + pgpool-II$B$rA`:n$9$k(BUNIX$B%3%^%s%I$H$7$F!"0J2<$N$b$N$,$"$j$^$9!#(B +

    +   * pcp_node_count	- $B%N!<%I?t$rpJs$rpJs$rpJs$r
    +

    + + +

    $B6&DL0z?t(B

    +

    + $BA4$F$N%3%^%s%I$K$O6&DL$9$k0z?t$,$"$j$^$9!#$3$l$O@\B3$9$k(Bpgpool-II$B$N>pJs$dG'>Z(B + $B>pJs$J$I$G$9!#(B +

    +   ex)
    +   $ pcp_node_count [-d] 10 localhost 9898 postgres hogehoge
    +
    +    $BBh0l0z?t(B    - $B%?%$%`%"%&%HCM(B
    +		$BIC?t$G%?%$%`%"%&%HCM$r;XDj$7$^$9!#$3$N;~4VFb$K(Bpgpool-II$B$+$i1~(B
    +		$BEz$,$J$$>l9g$O%3%M%/%7%g%s$r@ZCG$7$F=*N;$7$^$9!#$J$*!"(B
    +		$B$3$N%*%W%7%g%s$O(B 2.1 $B$+$i$OL5;k$9$k$h$&$K$J$C$F$$$^$9!#(B
    +    $BBhFs0z?t(B	- pgpool-II$B$,2TF0$7$F$$$k%[%9%HL>(B
    +    $BBh;00z?t(B	- pgpool-II$B$,(B
    +    $BBh8^0z?t(B	- PCP$B%Q%9%o!<%I(B
    +
    +	$B%*%W%7%g%s0z?t$H$7$F!"(B-d$B$,$"$j$^$9!#(B-d$B$,;XDj$5$l$k$H%G%P%C%0>pJs$r=PNO$7$^$9!#(B
    +
    +

    + PCP$B%f!<%6L>$H%Q%9%o!<%I$O(B ./configure $B;~$K(B --prefix $B$G;XDj$7$?(B + '$B%$%s%9%H!<%k%G%#%l%/%H%j(B/etc' $B$K$"$k(B pcp.conf $BFb$K5-=R$5$l$F$$$k$b$N$r;XDj(B + $B$7$^$9!#(Bpcp.conf $B%U%!%$%k$N>l=j$,%G%U%)%k%H0J30$N>l=j$K$"$k>l9g!"(Bpgpool $B$N(B + -F $B%*%W%7%g%s$G$=$N0LCV$r;XDj$9$k$3$H$,$G$-$^$9!#(B + $B%Q%9%o!<%I$O%3%^%s%I$KEO$9;~E@$G(Bmd5$B2=$5$l$F$$$kI,MW$O$"$j$^$;$s!#(B +

    + + +

    $B%3%^%s%I72(B

    +

    + $BA4$F$N%3%^%s%I$O!" + + +

    pcp_node_count

    +
    +   $B=q<0!'(B
    +	pcp_node_count  _timeout_  _host_  _port_  _userid_  _passwd_
    +
    +

    + pgpool-II$B$N(B pgpool.conf $B$GDj5A$5$l$?%N!<%I$NAm?t$rI=<($7$^$9!#@Z$jN%$5$l$F$$$k(B + $B%N!<%I$N6hJL$O$7$^$;$s!#(B +

    + + +

    pcp_node_info

    +
    +   $B=q<0!'(B
    +	pcp_node_info  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
    +
    + +

    + pgpool-II$B$N(B pgpool.conf $B$GDj5A$5$l$?%N!<%I$N>pJs$rI=<($7$^$9!#=PNO7k2L$O0J2<$N(B + $BNc$NDL$j$G$9!#(B +

    + +
    +   ex)
    +   $ pcp_node_info 10 localhost 9898 postgres hogehoge 0
    +   host1 5432 1 1073741823.500000
    +
    +   $B7k2L$O0J2<$N=g$NDL$j$G$9!#(B
    +   1. $B%N!<%I$N%[%9%HL>(B
    +   2. $B%N!<%I$N%]!<%HHV9f(B
    +   3. $B%9%F!<%?%9(B
    +   4. $B%m!<%I%P%i%s%9%&%'%$%H(B
    +
    +   $B%9%F!<%?%9$O(B[0..3]$B$^$G$N?t;z$GI=$o$5$l$^$9!#3F?t;z$N0UL#$O!'(B
    +   0 - $B=i4|2=;~$N$_$KI=$o$l$k!#(BPCP$B%3%^%s%I$GI=<($5$l$k$3$H$O$J$$!#(B
    +   1 - $B%N!<%I2TF/Cf!#@\B3L5$7(B
    +   2 - $B%N!<%I2TF/Cf!#@\B3M-$j(B
    +   3 - $B%N!<%I%@%&%s(B
    +
    + +

    + $B%m!<%I%P%i%s%9%&%'%$%H$O(BNormalize$B$5$l$?%U%)!<%^%C%H$G=PNO$5$l$^$9!#(B +

    +

    + $BDj5A$5$l$F$$$J$$%N!<%I(BID$B$r;XDj$9$k$H(BBackendError$B$HI=<($5$l!"=*N;%3!<%I(B12$B$G=*(B + $BN;$7$^$9!#(B +

    + + +

    pcp_proc_count

    +

    +

    +   $B=q<0!'(B
    +	pcp_proc_count  _timeout_  _host_  _port_  _userid_  _passwd_
    +
    +

    + pgpool-II$B$N;R%W%m%;%9$N%W%m%;%9(BID$B$r0lMwI=<($7$^$9!#J#?t$"$k>l9g$O6uGrJ8;z$G6h(B + $B@Z$i$l$^$9!#(B +

    + + +

    pcp_proc_info

    +

    +

    +   $B=q<0!'(B
    +	pcp_proc_info  _timeout_  _host_  _port_  _userid_  _passwd_  _processid_
    +
    +

    + pgpool-II$B$N;R%W%m%;%9>pJs$rI=<($7$^$9!#=PNO7k2L$O0J2<$NNc$NDL$j$G$9!#(B +

    +
    +   ex)
    +   $ pcp_proc_info 10 localhost 9898 postgres hogehoge 3815
    +   postgres_db postgres 1150769932 1150767351 3 0 1
    +
    +   $B7k2L$O0J2<$N=g$NDL$j$G$9!#(B
    +   1. $B@\B3$7$F$$$k%G!<%?%Y!<%9L>(B
    +   2. $B@\B3$7$F$$$k%f!<%6L>(B
    +   3. $B%W%m%;%9%9%?!<%H;~9o(B
    +   4. $B%3%M%/%7%g%s:n@.;~9o(B
    +   5. $B%W%m%H%3%k%a%8%c!<%P!<%8%g%s(B
    +   6. $B%W%m%H%3%k%^%$%J!<%P!<%8%g%s(B
    +   7. $B%3%M%/%7%g%s;HMQ2s?t(B
    +
    +   $B%3%M%/%7%g%s$,%P%C%/%(%s%I$KBP$7$FD%$i$l$F$$$J$$>l9g!"%G!<%?$OI=<($5$l$^$;$s!#(B
    +   $B%3%M%/%7%g%s>pJs$,J#?t$"$k>l9g!"J#?t9T$K(B1$B9T(B1$B%3%M%/%7%g%s>pJs$GI=<($5$l$^$9!#(B
    +   $B;~9o$O(BEPOCH$B%?%$%`$+$i$NIC?t$GI=$o$5$l$^$9!#(B
    +
    +   $BDj5A$5$l$F$$$J$$%W%m%;%9(BID$B$r;XDj$9$k$H(BBackendError$B$HI=<($5$l!"=*N;%3!<%I(B12$B$G(B
    +   $B=*N;$7$^$9!#(B
    +
    +

    + +

    pcp_systemdb_info

    +

    +

    +   $B=q<0!'(B
    +	pcp_systemdb_info  _timeout_  _host_  _port_  _userid_  _passwd_
    +
    +   pgpool-II$B$N%7%9%F%`(BDB$B>pJs$rI=<($7$^$9!#=PNO7k2L$O0J2<$NDL$j$G$9!#(B
    +
    +   $ pcp_systemdb_info 10 localhost 9898 postgres hogehoge
    +   localhost 5432 yamaguti '' pgpool_catalog pgpool 3
    +   yamaguti public accounts aid 4 aid bid abalance filler integer integer integer character(84) dist_def_accounts
    +   yamaguti public branches bid 3 bid bbalance filler integer integer character(84) dist_def_branches
    +   yamaguti public tellers bid 4 tid bid tbalance filler integer integer integer character(84) dist_def_tellers
    +
    +   $B$^$:0l9TL\$K%7%9%F%`(BDB$B$N>pJs$,I=<($5$l$^$9!#7k2L$O0J2<$N=g$NDL$j$G$9!#(B
    +
    +   1. $B%[%9%HL>(B
    +   2. $B%]!<%HHV9f(B
    +   3. $B%f!<%6L>(B
    +   4. $B%Q%9%o!<%I!#6u$N>l9g$O(B''$B$GI=<($5$l$^$9!#(B
    +   5. $B%9%-!<%^L>(B
    +   6. $B%G!<%?%Y!<%9L>(B
    +   7. $BJ,;6Dj5A4X?t$N?t(B
    +
    +   $BFs9TL\0J9_$OJ,;6Dj5A$,I=<($5$l$^$9!#J#?t$NDj5A$,$"$k>l9g$O!"0l$D$NDj5A$K$D$-(B
    +   $B0l9TI=<($5$l$^$9!#7k2L$O0J2<$N=g$NDL$j$G$9!#(B
    +
    +   1. $BJ,;6BP>]$N%G!<%?%Y!<%9L>(B
    +   2. $BJ,;6BP>]$N%9%-!<%^L>(B
    +   3. $BJ,;6BP>]$N%F!<%V%kL>(B
    +   4. $BJ,;6%-!<%+%i%`L>(B
    +   5. $BJ,;6BP>]%F!<%V%kCf$N%+%i%`?t(B
    +   6. $B%+%i%`L>%j%9%H(B(5.$B$N%+%i%`?tJ,I=<($5$l$^$9(B)
    +   7. $B%+%i%`7?%j%9%H(B(5.$B$N%+%i%`?tJ,I=<($5$l$^$9(B)
    +   8. $BJ,;6Dj5A4X?tL>(B
    +
    +   $B%7%9%F%`(BDB$B$,Dj5A$5$l$F$$$J$$(B(pgpool-II$B%b!<%I$G$J$$!"$+$D%/%(%j%-%c%C%7%e$,%*(B
    +   $B%U$N(B)$B>l9g$K
    +

    + + +

    pcp_detach_node

    +

    +

    +   $B=q<0!'(B
    +	pcp_detach_node  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
    +
    +   pgpool-II$B$N%N!<%I$r@Z$jN%$7$^$9!#(B
    +
    +

    + + +

    pcp_attach_node

    +

    +

    +   $B=q<0!'(B
    +	pcp_attach_node  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
    +
    +   pgpool-II$B$N%N!<%I$rI|5"$5$;$^$9!#(B
    +
    +

    + +

    pcp_stop_pgpool

    +

    +

    +   $B=q<0!'(B
    +	pcp_stop_pgpool  _timeout_  _host_  _port_  _userid_  _passwd_  _mode_
    +
    +   pgpool-II$B$r;XDj$5$l$?%b!<%I$G%7%c%C%H%@%&%s$7$^$9!#;XDj$G$-$k%b!<%I$O0J2<$NDL(B
    +   $B$j$G$9!#(B
    +
    +   s	- smart $B%b!<%I(B
    +   f	- fast $B%b!<%I(B   
    +   i	- immediate $B%b!<%I(B
    +
    +   pgpool-II$B$,5/F0$7$F$$$J$$>l9g$O(BConnectionError$B$HI=<($5$l!"=*N;%3!<%I(B8$B$G=*N;$7(B
    +   $B$^$9!#(B
    +
    +   $B"((B $B8=:_$O(B fast $B%b!<%I$H(B immediate $B%7%c%C%H%@%&%s$N=hM}$K6hJL$O$"$j(B
    +      $B$^$;$s!#L?Na$rAw$C$?;~E@$G%/%i%$%"%s%H$,$$$k!&$$$J$$$K4X$o$i$:(B
    +      $B%7%c%C%H%@%&%s=hM}$rB(:B$K9T$$$^$9!#(B
    +
    +

    + +

    pcp_recovery_node

    +

    +

    +   $B=q<0!'(B
    +	pcp_recovery_node  _timeout_  _host_  _port_  _userid_  _passwd_  _nodeid_
    +
    +   pgpool-II$B$N%N!<%I$r%G!<%?$r:FF14|$5$;$?>e$GI|5"$5$;$^$9!#(B
    +
    +

    + + +

    $B=*N;%9%F!<%?%9(B

    +

    + PCP$B%3%^%s%I$O@5>o$K=hM}$r=*N;$7$?>l9g!"%9%F!<%?%9(B'0'$B$G=*N;$7$^$9!#%(%i!<$,5/(B + $B$-$?>l9g$O0J2<$N%9%F!<%?%9$K$h$j=*N;$7$^$9!#(B +

    +   UNKNOWNERR	1	$BITL@$J%(%i!<(B
    +   EOFERR	2	EOF$B%(%i!<(B
    +   NOMEMERR	3	$B%a%b%jITB-(B
    +   READERR	4	$B%5!<%P$+$i$N%G!<%?FI$_9~$_%(%i!<(B
    +   WRITEERR	5	$B%5!<%P$X$N%G!<%?=q$-9~$_%(%i!<(B
    +   TIMEOUTERR	6	$B%?%$%`%"%&%H(B
    +   INVALERR	7	PCP$B%3%^%s%I$X$NIT@5$J%*%W%7%g%s(B
    +   CONNERR	8	$B%5!<%P@\B3%(%i!<(B
    +   NOCONNERR	9	$B@\B3$,B8:_$7$J$$(B
    +   SOCKERR	10	$B%=%1%C%H%(%i!<(B
    +   HOSTERR	11	$B%[%9%HL>2r7h%(%i!<(B
    +   BACKENDERR	12	$B%5!<%P$G$N(BPCP$B=hM}%(%i!pJs$rl9g$J$I(B
    +   AUTHERR	13	$BG'>Z%(%i!<(B
    +
    +

    + +

    $BFbIt>pJs(B

    +

    + pgpool-II$B%P!<%8%g%s(B 2.0 $B0J9_$G$O!"(B1.x $B%P!<%8%g%s$HHf$YBgI}$J2~NI$,2C$($i$l$F$$$^$9!#(B + 1.x $B%P!<%8%g%s$N>pJs$H$O8_49@-$,$J$$$N$GCm0U$7$F$/$@$5$$!#(B +

    + +

    $B%Q%i%l%k + +

    +pgpool-II$B$K$O%Q%i%l%k +

    +$B$3$N%(%s%8%s$O!"%Q%i%l%k%b!<%I$N$H$-$K!"3F%N!<%I$KF1$8%/%(%j$rLd$$9g(B +$B$o$;!"%N!<%I$N1~Ez=g$K7k2L$r%U%m%s%H%(%s%I$KAw?.$9$k%(%s%8%s$N$3$H$r(B +$B;X$7$^$9!#(B +

    + +

    $B%/%(%j=q$-49$((B

    +

    +$B%Q%i%l%k%b!<%I$G(Bpgpool-II$B$,9T$&%/%(%j=q$-49$($K$D$$$F@bL@$7$^$9!#(B +

    +

    +$B%Q%i%l%k%b!<%I$G$O!"%/%i%$%"%s%H$,Aw?.$7$?8!:w7O(B(SELECT$B=hM}(B)$B$NLd$$9g$o$;$O!"Bg$-$/J,$1$F0J2<$N(B 2 $B$D$N=hM}$r9T$$$^$9!#(B +

    +
      +
    1. $B%/%(%j$N2r@O(B +
    2. $B%/%(%j$N=q$-49$((B +
    + +

    +$B$3$l$i#2$D$N=hM}$K$D$$$F=g$K@bL@CW$7$^$9!#(B +

    + +

    $B%/%(%j$N2r@O(B

    +

    +

    +$B$O$8$a$K(B +

    +

    +

    +$B%/%i%$%"%s%H$,Aw?.$7$?8!:w7O$NLd$$9g$o$;$O!"(BSQL$B%Q!<%5$rDL$7$F$+$i%7%9%F%`(BDB$B$KEPO?$5$l$F$$$k>pJs$r(B +$B$b$H$K%/%(%j2r@O$r9T$$$^$9!#%/%(%j$N2r@O$K$O2A$7$F$$$^$9!#(B +$B$3$3$GuBV$r(B P $B>uBV!"0l$D$N%N!<%I$G=hM}$9$kI,MW$,$"$k>uBV$r(B L $B>u(B +$BBV$H$7$FDj5A$7$^$9!#(B +$B$b$&0l$D!"FCJL$J>uBV$H$7$F(B S $B>uBV$,$"$j$^$9!#$3$l$O!"$9$Y$F$N%N!<%I$+$iuBV$N$3$H$r<($7$^$9!#(B +$BNc$($P!"%=!<%H=hM}$G$9!#(Bpgpool_catalog.dist_def$B%F!<%V%k$KEPO?$5$l$F$$$k%F!<%V%k$N%G!<%?$KBP$9$k%=!<(B +$B%H=hM}$O!"$9$Y$F$N%N!<%I$+$i%G!<%?$r +

    +$B8!:w7O%/%(%j$O!"0J2<$N=hM}=g$K2r@O$5$l!"uBV$H$J$k$H!"0J9_$N=hM}$OI,$:(B S $B>uBV$H$J$j$^$9!#(B +$B$=$7$F:G8e$N(BSELECT$B$N:G=*uBV$K$h$j!"2?=h$N(BDB$B$G=hM}$5$l$k$+$,(B +$B7hDj$7$^$9!#(B + +

      +
    1. UNION$B!"(BEXTRACT$B!"(BINTERCECT$B$,MxMQ$5$l$F$$$k$+$I$&$+(B +
    2. FROM $B6g$N TARGETLIST $B$K$h$k WHERE $B6g(B $B$K$k GROUP BY $B6g$K$h$k HAVING $B6g$K$h$k ORDER BY $B6g$K$h$k LIMIT OFFSET $B=R8l$K SELECT$B$N:G=* +

      +SELECT$B$N:G=*l=j$H$N4X78$O!"0J2<$NDL$j$G$9!#(B +

      + +

      + + + + + + +
      $B$B=hM}$5$l$k>l=j(B
      L$B$$$:$l$+$N%N!<%I$KLd$$9g$o$;$r9T$&(B
      P$B$9$Y$F$N%N!<%IF1$8Ld$$9g$o$;$r9T$$!"%Q%i%l%k
      S$B%7%9%F%`(BDB$B$G=hM}$r9T$C$?8e$K%/%i%$%"%s%H$KJV5Q(B
      +

      + +

      +$B$^$?%5%V%/%(%j$KBP$7$F$b>e5-$N%k!<%k$,E,1~$5$l$^$9!#(B +$B0J2<$NC1=c$J%/%(%j$G$O!"(Bp1-table$B$,%7%9%F%`(BDB$B$N(Bpgpool_catalog.dist_def$B%F!<%V%k$KEPO?$5$l$F$$$k>l9g!"$D$^$j%G!<%?$NJ,3d$,(B +$B9T$o$l$F$$$k>l9g$K$O!"%5%V%/%(%j$N:G=* + SELECT * FROM (SELECT * FROM P1-table) as P2-table; +

    +

    +

    +$B +

    +

    +FROM $B6g$N +

    +

    +$B8!:w7O%/%(%j(B(SELECT)$B$O(B FROM $B6g$K$h$j%G!<%?$N=89g$rDj5A$7$^$9!#(BFROM$B6g$+$i9=@.$;$l$k%G!<%?=89g$O(B P $B>uBV(B, L $B>u(B +$BBV!"$^$?$O(B S $B>uBV$rl9g$K$O!"C1=c$K%F!<%V%k$Nl9g(B +$B$K$O!"7k9gJ}K!$K$h$C$F0J2<$N$h$&$K + +

    + + + + + + + +
    $B7k9gJ}<0(B LEFT OUTER JOIN RIGHT OUTER JOIN FULL OUTER JOIN$B!!!!!!$=$NB>!!!!!!(B
    $B:8!@1&(B P L S P L S P L S P L S
    P S P S S S S S S S S P S
    L S L S P L S S L S P L S
    S S S S S S S S S S S S S
    +

    + +

    +$B0J2<$NNc$G$O!"(BP1-table$B$,(B P $B>uBV$N%F!<%V%k$G(BL1-table,L2-table$B$,(B L $B>uBV$N%F!<%V%k$@$H$7$^$9!#(B +$B$9$k$H>e5-$NI=$K$h$j!"(BP1-table ($B:8(B)$B$H(BL1-table ($B1&(B) $B$,7k9g$7(B P $B>uBV$H$J$j!"$5$i$K(B P $B>uBV$H(B L $B>uBV$N(BL2-table$B$,7k9g$7$F(BFROM$B6g$NuBV$H$J$j$^$9!#(B +

    +	SELECT * FROM P1-table,L1-table,L2-table;
    +
    +

    + +

    +

    +TARGETLIST $B$H(B WHERE$B6g$N +

    + +

    +$B4pK\E*$J%/%(%j$G$O!"(BFROM $B6g$HF1$85$7$^$9!#(B +$B$7$+$7!"(BTARGETLIST $B$H(B WHERE$B6g$Nl9g$KJQ2=$7$^$9!#(B +

      +
    1. $B%5%V%/%(%j$,$"$k>l9g(B +
    2. FROM$B6g$,(B P $B>uBV$N>l9g!"$+$D!"(BTARGETLIST$B$K=8Ls4X?t!"(BDISTINCT$B$,$"$k>l9g(B +
    3. FROM$B6g$GDj5A$7$?%F!<%V%k(B($B%G!<%?=89g(B)$B$KB8:_$7$J$$%+%i%`$,;H$o$l$F$$$k>l9g(B +
    +

    +

    +$B%5%V%/%(%j$N:G=*uBV!"$^$?$O!"(BS $B>uBV$N>l9g$K$O!"(BTARGETLIST$B!"(BWHERE$B6g$NuBV$H$J$j$^$9!#(B +$B2<5-$NNc$G$O!"%5%V%/%(%j$G;H$o$l$F$$$k%F!<%V%k$,!"(BP $B>uBV$N>l9g$K$O!"%5%V%/%(%j$N:G=*uBV$H$J$j$^$9!#$=$N$?$a(B L1-table$B$NuBV$H$J$j(B +$B!"$3$N%/%(%j$Nl=j$O%7%9%F%`(BDB$B$H$J$j$^$9!#(B +

    +
    +	SELECT * FROM L1-table where L1-table.column IN (SELECT * FROM P1-table);
    +
    + +

    +FROM $B6g$,(B P $B>uBV$N>l9g!"$+$D!"(BTARGETLIST$B$K=8Ls4X?t$,$"$k>l9g$O!"%G!<%?$ruBV(B +$B$KA+0\$7$^$9!#(B +$B$^$?!"FCDj$N>r7o$N2<$G$O!"=8Ls4X?t$K$h$k:GE,2=$,9T$o$l$^$9!#(B +

    + +

    +FROM$B6g$GDj5A$7$?%F!<%V%k!"%5%V%/%(%j$K$OB8:_$7$J$$%+%i%`$,(BWHERE$B6g$K;H$o$l$F$$$k>l9g$,$"$j$^$9!#$3$l$O0J2<$N$h$&$JAj4X%5%V%/%(%jFb$GH/@8$7$^$9!#(B +

    +
    +	SELECT * FROM L1-table FROM L1-table.col1 IN (SELECT * FROM P1-table WHERE P1-table.col = L1-table.col1);
    +
    +

    $B>e5-$N%5%V%/%(%j$K;H$o$l$F$$$k(B L1-table.col1$B$O!"(BL1-table$B$r30It;2>H$7$F$$$^$9!#$3$N>l9g$K%5%V%/%(%j$N(BWHERE$B6g$NuBV$H$J$j$^$9!#(B + + +

    +

    +GROUP BY $B6g!"(BHAVING $B6g!"(BORDER BY $B6g!"(BLIMIT OFFSET $B=R8l$N +

    + +

    +WHERE$B6g$NuBV$N>l9g$K!"(BGROUP BY , HAVING $B6g!"(BORDER BY $B6g!"(BLIMIT OFFSET $B=R8l$,$"$k$H(BS$B>uBV$KA+0\$7$^$9!#(B +GROUP BY$B6g$,B8:_$7$J$$%/%(%j$O(BWHERE$B6g$N5$7$^$9!#$^$?!"(BHAVING$B6g$,L5$$>l9g$K$O(BGROUP BY $B6g$N5$7$^$9!#(B +ORDER BY $B6g!"(BLIMIT OFFSET $B=R8l$bF1MM$G$9!#(B +

    + +

    +UNION$B!"(BEXTRACT$B!"(BINTERSECT$B$,;H$o$l$F$$$k>l9g(B +

    + +

    +UNION$B!"(BEXTRAT$B!"(BINTERSECT$B$,;H$C$F$$$k%/%(%j$O:8B&$N(BSELECT$BJ8$H1&B&$N(BSELECT$BJ8$N:G=*uBV$N;~$K$O!"(BL $B>uBV$H$J$j$^$9!#(B +$B$^$?!":8B&$H1&B&$N(BSELECT$BJ8$N:G=*uBV!"$+$D(BUNION ALL$B$N>l9g$K$O(B P $B>uBV$H$J$j$^$9!#(B +$B$=$NB>$NAH$_9g$o$;$N>l9g$K$O!"(BS$B>uBV$H$J$j$^$9!#(B +

    + +

    +

    +SELECT$B$N:G=* +

    + +

    +$BuBV$N>l9g$K$O(BL$B>uBV!"$9$Y$F(B P $B>uBV$N>l9g$K$O!"(BP $B>uBV$H$J$j$^$9!#(B +$B$=$l0J30$O!"(BS $B>uBV$H$J$j$^$9!#(B +L $B>uBV$N>l9g$K$O!"(Bpgpool.conf$B$N(Bloadbalance_mode$B$,(Btrue$B$N>l9g$K$OIi2YJ,;6$5$l!"$=$l0J30$N>l9g$K$O(BMASTER$B$KLd$$9g$o$;$r9T$$$^$9!#$^$?!"(BP $B>uBV$N>l9g$K$O!"%Q%i%l%kuBV$N>l9g$K$O!" + +

    $B%/%(%j=q$-49$((B

    + +

    +$B%/%(%j$N2r@O%U%'!<%:$GuBV$N(B P1-table $B$H(B L $B>uBV$N(B L1-table $B$r;H$C$?%/%(%j$G@bL@$7$^$9(B +

    +
    +	SELECT P1-table.col, L1-table.col FROM P1-table,L1-table where P1-table.col = L1-table.col order by P1-table.col;
    +
    +

    +$B$3$N%/%(%j$G$O(B ORDER BY $B6g$,$"$k$?$a(B S $B>uBV$H$J$j!"(BFROM$B6g!"(BWHERE$B6g!"(BTARGETLIST$B$O(B P $B>uBV$H$J$j$^$9!#(B +$B$3$N$h$&$J%/%(%j$G$O0J2<$N$h$&$K=q$-49$($i$l$^$9!#(B +

    +
    +	SELECT P1-table.col, L1-table.col FROM
    +	$B!!!!!!(Bdblink(select pool_parallel(SELECT P1-table.col, L1-table.col FROM P1-table,L1-table where P1-table.col = L1-table.col)) 
    +  	order by P1-table.col;
    +
    +

    +$B$3$3$G(Bdblink$B$O(Bpgpool-II$B$KLd$$9g$o$;$rAw?.$7$^$9!#$^$?!"(Bpool_parallel$B$O0z?t$N%/%(%j$r%Q%i%l%ke5-$O$"$/$^$G%$%a!<%8$G$"$j +

    +$B>e5-$NNc$N$h$&$K!"(BFROM$B6g!"(BWHERE$B6g!"(BTARGETLIST$B$,$9$Y$F(B P $B>uBV$N>l9g$K$O!"(BFROM$B6g!"(BWHERE$B6g!"(BTARGETLIST$B$r$^$H$a$FJBNs=hM}$r9T$$$^$9!#(B + +

    +$B +

    +	SELECT L1-table.col FROM L1-table WHERE L1-table.col % 2 = 0 AND L1-table.col IN (SELECT P1-table FROM P1-table) ;
    +
    +

    +$B$3$NNc$G$O!"(BFROM $B6g$O(B L $B>uBV!"(BTARGETLIST$B$b(B L $B>uBV!"(BWHERE$B6g$O(B P $B>uBV$N%5%V%/%(%j$r;}$C$F$$$k$?$a(B S $B>uBV$H$J$j$^$9!#(B +$B$3$l$O0J2<$N$h$&$K=q$-49$($,9T$o$l$^$9!#(B +

    +
    +	SELECT L1-table.col FROM dblink(SELECT loadbalance(SELECT L1-table.col FROM L1-table WHERE L1-table.col % 2 = 0 AND TRUE))
    +		WHERE
    +			L1-table.col %2 = 0 AND 
    +		  L1-table.col IN 
    +		  (
    +		  	SELECT P1-Table FROM 
    +		  	dblink(select pool_parallel(SELECT P1-table FROM P1-table))
    +		  ) ;
    +
    +

    +$B$3$3$G!"(Bpool_loadbalance$B$O%/%(%j$r$$$:$l$+$N%N!<%I$KAw?.$9$k4X?t$G$9!#(B +

    + +

    +

    +$B=8Ls$K$h$k%/%(%j=q$-49$((B +

    +

    + +

    +$B=87W$r9T$&%/%(%j(B($B=8Ls4X?t!"(BGROUP BY )$B$O3F%N!<%I$K7W;;$5$;!"%7%9%F%`(BDB$B$G(B +$B:F=87W$r9T$&$3$H$K$h$j!"%7%9%F%`(BDB$B$NIi2Y$r8:$i$7%Q%U%)!<%^%s%9$b8~>e(B +$B$7$^$9!#(B +

    +

    +$B$^$:!":G=i$K(Bpgpool-II$B$, +

    +FROM $B6g$,(B P $B>uBV$G(B count(*) $B$r;H$C$?%/%(%j$O!"0J2<$N$h$&$K=q$-49$($,9T$o$l$^$9!#(B +

    + +
    +    select count(*) from P1-table;
    +
    +    -> $B%/%(%j=q$-49$((B
    +
    +    SELECT 
    +        sum(pool_c$1) as count 
    +    FROM 
    +        dblink(select pool_parallel('select count(*) from  P1-table'))
    +					AS pool_$1g (pool_c$1 bigint); 
    +
    + +

    +$B3F%N!<%I$G(Bcount(*) $B$r7W;;$7$?8e$K!"%7%9%F%`(BDB$B$G=87W(B(sum)$B$r$9$k$3$H$K$h(B +$B$j!"L\E*$,C#@.$G$-$^$9!#(B +

    + +

    +$B>e5-$N$h$&$J%/%(%j=q$-49$($,9T$o$l$k>r7o$O0J2<$N>l9g$G$9!#(B +

    +
      +
    1. FROM $B6g$,(BP $B>uBV(B +
    2. $B%?!<%2%C%H%j%9%H$K=8Ls4X?t(B(count, sum, min, max,avg$B$N$_BP1~(B),GROUP BY$B$K;XDj$7$?%+%i%`$,;H$o$l$F$$$k(B +
    3. WHERE $B6g$,(BP $B>uBV(B +
    4. HAVING $B6g(B $B$K;H$o$l$F$$$k=8Ls4X?t(B(count, sum, min, max,avg$B$N$_BP1~(B),FROM$B6g$GDj5A$5$l$F$$$k%+%i%`(B,GROUP BY$B$K;XDj$7$?%+%i%`$N$_;H$o$l$F$$$k!#(B +
    +
    +  $BNc(B)
    +     select P1-table.col,L1-table.col,count(*),avg(P1-table.col) from P1-table,L1-table wehre P1-table.col %2 = 0 group by P1-table.col,L1-table.coli having count(*) < 100
    +
    + +

    $B%Q%i%l%k%b!<%I$NCm0U;v9`(B

    +

    +$B%Q%i%l%k%b!<%I$G$O!"%/%(%j$N2r@O$N:]$K%+%i%`L>$H%?%$%W$,I,MW$K$J$j$^$9!#$=$N$?$a!"%5%V%/%(%j$N(BTARGETLIST$B$K<0!"4X?t$r;H$C$F$$$k>l9g$K$OJLL>$H7?L>$r%-%c%9%H$G$D$1$kI,MW$,$"$j$^$9!#<0!"4X?t$K7?$N%-%c%9%H$,$J$$>l9g$K$O!"(Btext$B7?$H$7$F=hM}$5$l$^$9$N$GCm0U$7$F$/$@$5$$!#(B +$B$J$*!"=8Ls4X?t$N>l9g$G$+$D=8Ls$K$h$k%/%(%j=q$-49$($,9T$o$l$k>l9g$K$O!"(Bcount$B$O(Bbigint$B7?!"(Bsum$B$O(Bnumeric$B7?$H$J$j$^$9!#(Bmin,max$B$N>l9g$K$O!"0z?t$,F|IU7?$N>l9g$K$OF|IU7?$H$7$F7W;;$5$l!"$=$l0J30$O(Bnumeric$B$H$7$F7W;;$5$l$^$9!#(Bavg$B$O(Bsum/count$B$H$7$F=hM}$5$l$^$9!#(B +

    + +

    $B%Q%i%l%k%b!<%I$N%Q%U%)!<%^%s%9$K$D$$$F(B

    +

    +

    +SELECT$B$N:G=* +

  • $B$B%Q%U%)!<%^%s%9(B
    L$B%Q%i%l%k%/%(%j$rMxMQ$7$J$$$N$G(Bpgpool-II$B$N%*!<%P!<%X%C%I$r=|$-!"C1BN%N!<%I$H$N@-G=Nt2=$O$J$$(B
    P$BJBNs=hM}$r9T$&$N$G9bB.!"FC$K%7!<%1%s%7%c%k%9%-%c%s$N>l9g$K$O8z2L$,$G$k!#$^$?!"%G!<%?$rJ,3d$9$k$3$H$G%F!<%V%k%5%$%:(B(/1$BBf(B)$B$,>.$5$/$J$k$3$H$K$h$j%-%c%C%7%e$K>h$j$d$9$/$J$k(B
    S$B=8Ls$K$h$k%/%(%j=q$-49$($,9T$o$l$k$H9bB.(B
    +

    + +

    + +

    $B%A%e!<%H%j%"%k(B

    +

    +pgpool-II$B$N%A%e!<%H%j%"%k$O(B$B$3$3(B$B$K$"$j$^$9!#@'Hs$4Mw2<$5$$!#(B +

    + +

    $B%j%j!<%9%N!<%H(B

    + +

    2.2.5 (urukiboshi) 2009/10/4

    +

    $B35MW(B

    +

    +$B$3$N%P!<%8%g%s$G$O!"(B2.2.4$B0JA0$N?'!9$J%P%0$,=$@5$5$l$F$$$^$9!#(B +

    +

    $B%P%0=$@5(B

    +
      +
    • $B%3%M%/%7%g%s?t$N%+%&%s%H$N%_%9$K$h$j!"%*%s%i%$%s%j%+%P%j$,=*$o$i$J$/$J$k%P%0$r=$@5$7$^$7$?(B(Tatsuo) +
    • $BFbItE*$K%m%C%/$rH/9T$9$k:]$K$b%U%m%s%H%(%s%I$,0[>o=*N;$7$?$3$H$r8!=P$7$F(BSQL$B%3%^%s%I$r%-%c%s%;%k$9$k$h$&$K$7$^$7$?(B(Tatsuo) +
    • $B@\B3$N=*N;=hM}$GL58B%k!<%W$K4Y$k$3$H$,$"$k%P%0$r=$@5$7$^$7$?(B(Xavier Noguer, Tatsuo) +
    • $B3HD%%W%m%H%3%k$N%Q!<%9=hM}$G(Bkind mismatch error$B$,5/$-$?:]$K@5$7$$(BSQL$BJ8$rI=<($9$k$h$&$K$7$^$7$?(B(Tatsuo) +
    • $B%I%-%e%a%s%H$r2~A1$7$^$7$?(B(Tatsuo) +
    +

    + +

    2.2.4 (urukiboshi) 2009/8/24

    +

    $B35MW(B

    +

    +$B$3$N%P!<%8%g%s$G$O!"(B2.2.3$B0JA0$N?'!9$J%P%0$,=$@5$5$l$F$$$^$9!#(B +

    +

    $B%P%0=$@5(B

    +
      +
    • pgpool-II 2.2.2$B$GF~$C$F$7$^$C$?%P%0$r=$@5$7$^$7$?!#%U%m%s%H%(%s%I$,%"%\!<%H$9$k%?%$%_%s%0$K$h$C$F$O!"0J8eFbIt>uBV$,%j%;%C%H$5$l$:!"pgpool-II 2.2.3$B$G%P!<%8%g%s(B2$B%W%m%H%3%k$N%/%i%$%"%s%H$,F0$+$J$/$J$C$F$7$^$C$F$$$?$N$r=$@5$7$^$7$?!#(B + $B$^$?!";~4V$N$+$+$k%/%(%j$rBT$C$F$$$k4V$K%U%m%s%H%(%s%I$,0[>o=*N;$7$?$3$H$r8!CN$9$k4V3V$r(B1$BIC$+$i(B30$BIC$KJQ99$7$^$7$?!#$3$N%A%'%C%/$O!"(B2.2.4$B$G$O%W%m%H%3%k%P!<%8%g%s$,(B3$B$N$H$-$N$_M-8z$G$9(B(Tatsuo) +
    • $B;R%W%m%;%9$r5/F0$9$kA0$K%7%0%J%k$N%V%m%C%/$d%O%s%I%i$N@_Dj$r9T$J$&$h$&$K$7$^$7$?!#(B +$B$3$l$O!"(Bpgpool-II$B$r5/F0$7$?D>8e$K%U%!%$%k%*!<%P$J$I$N;v>]$,H/@8$7$F;R%W%m%;%9$+$i?F%W%m%;%9$K%7%0%J%k$,Aw$i$l$k$H!"(Bpgpool-II$B$N?F%W%m%;%9$,;`$s$G$7$^$&$3$H$,$"$k$+$i$G$9(B(Tatsuo) +
    +

    + +

    2.2.3 (urukiboshi) 2009/8/11

    +

    $B35MW(B

    +

    +$B$3$N%P!<%8%g%s$G$O!"(B2.2.2$B0JA0$N?'!9$J%P%0$,=$@5$5$l$F$$$^$9!#(B +

    +

    $B%P%0=$@5(B

    +
      +
    • $B%P%C%/%(%s%I$K?7$7$$%3%M%/%7%g%s$rD%$k:]$K!"%P%C%/%(%s%I$N0l$D$,>c32$r5/$7$F$$$k%1!<%9$G!"8e=hM}$NCf$G(Bpgpool-II$B$N;R%W%m%;%9$,Mn$A$k$3$H$,$"$k%P%0$r=$@5$7$^$7$?(B(Tatsuo) +
    • $B%Q%i%l%k%/%(%j$N%P%0$r=$@5$7$^$7$?(B(Yoshiharu Mori) +
    • $B3HD%%W%m%H%3%k$N>l9g$K$b%(%i!<%a%C%;!<%8$NCf$G:G8e$K;HMQ$7$?%/%(%j$,I=<($G$-$k$h$&$K$J$j$^$7$?(B(Akio Ishida) +
    • kind mismatch error$B%a%C%;!<%8$N:n@.$G!"%a%C%;!<%8FbMF$,2u$l$k$3$H$,$"$k%P%0$r=$@5$7$^$7$?(B(Tatsuo, Akio Ishida) +
    • $B%P%C%/%(%s%I$X$N@\B35-=R;R$N;2>H%?%$%_%s%0$K$h$C$F$O(Bpgpool-II$B$N;R%W%m%;%9$,Mn$A$k$3$H$,$"$k%P%0$r=$@5$7$^$7$?(B(Tatsuo)$B!#(B +
    • pool_error$B$d(Bpool_log$B$N0z?t$,4V0c$C$F$$$?8D=j$r=$@5$7$^$7$?(B(Akio Ishida)$B!#(B +
    • statement_timeout$B$N%?%$%`%"%&%H$K$h$k%(%i!<=hM}$r2~NI$7$^$7$?!#$7$^$7$?!#$^$?!"(Bmaster$B$@$1$,(Bstatement_timeout$B$rJV$7$?>l9g$K$bBP1~$G$-$k$h$&$K$7$^$7$?!#0JA0$O(Bkind mismatch$B%(%i!<$K$J$C$F$$$^$7$?(B(Tatsuo)$B!#(B +(master$B0J30$,(Bstatement_timeout$B$rJV$5$J$$%1!<%9$G$O(Bkind mismatch$B%(%i!<$K$J$j$^$9(B)$B!#(B + +
    • health check$B$r$h$j6/2=$7!"(Bpostmaster$B$,(BSIGSTOP$B$G;_$C$F$7$^$C$F$$$k>l9g$b>c328!CN$G$-$k$h$&$K$7$^$7$?!#(B + +
    • $B%P%C%/%(%s%I$K(BSQL$B$rEj$2!"$=$N1~Ez$rBT$C$F$$$k4V$K%/%i%$%"%s%H$,(Bpgpool$B$KBP$9$k%3%M%/%7%g%s$r@ZCG$7$?$3$H$,8!=P$G$-$k$h$&$K$J$j$^$7$?!#(B +$B$?$H$($P!"(BWeb$B%"%W%j%1!<%7%g%s$G$O(BDB$B$KBP$7$F%j%/%(%9%H$rEj$2$F!"1~Ez$,$J$$$H%-%c%s%;%k$9$k$h$&$J$3$H$,IQHK$K5/$j$^$9!#(B +$B$3$N>l9g!":#$^$G$O(Bpgpool$B$d(BPostgreSQL$B$N%W%m%;%9$,;D$C$F$7$^$$!"F1;~@\B3?t$,8O3i$7$?$j!"%m%C%/$ru67$,8!=P$G$-$k$h$&$K$J$C$?$@$1$G$J$/!"(BSQL$B$N1~EzBT$A$N4V$K%/%i%$%"%s%H$,%3%M%/%7%g%s$r@ZCG$7$?:]$K$O!"(BSQL$B%3%^%s%I$N%-%c%s%;%k$r(Bpgpool$B$,9T$J$C$F!"%m%C%/BT$A$J$I$N%P%C%/%(%s%I%W%m%;%9$,;D$k$N$rKI$0$3$H$,$G$-$k$h$&$K$J$j$^$7$?(B(Tatsuo)$B!#(B + +
    • $B0z?t$J$7$N(BCLUSTER$B%3%^%s%I$O%H%i%s%6%/%7%g%s$NCf$G$O$BJ#?t$N%W%j%Z%"%I%9%F!<%H%a%s%H$r;H$C$F$$$k:]$K!"%;%C%7%g%s$N=*$j$G$=$N0lIt$@$1$,2rJ|$5$l$k%P%0$r=$@5$7$^$7$?(B(Akio Ishida) +$B!#(B +
    • sql/pgpool-recovery/pgpool-recovery.c$B$,(BPostgreSQL 8.4$B$G%3%s%Q%$%k$G$-$k$h$&$K$7$^$7$?(B(Tatsuo)$B!#(B + +
    • $B3HD%%W%m%H%3%k$r;H$C$F$$$k>l9g$K!"%/%i%$%"%s%H$H(Bpgpool$B$N4V$G$*8_$$$KBT$A>uBV$K$J$C$F$7$^$&$3$H$,$"$k%P%0$r=$@5$7$^$7$?(B(Gavin Sherry)$B!#(B + +
    • COPY FROM$B$rl9g$K!"%P%C%/%(%s%I%W%m%;%9$,;D$C$F$7$^$&%P%0$r=$@5$7$^$7$?(B(Tatsuo)$B!#(B + +
    + +

    2.2.2 (urukiboshi) 2009/5/5

    +

    $B35MW(B

    +

    +$B$3$N%P!<%8%g%s$G$O!"(B2.2.1$B0JA0$N?'!9$J%P%0$,=$@5$5$l$F$$$^$9!#(B +$B$H$j$o$1!"(Bpgpool$B$,%/%i%$%"%s%H$H$N4V$G%G!<%?$N$d$jl9g$K5/$k2DG=@-$,$"$j$^$9!#(B +$B$3$N%P%0$O2a5n$N$9$Y$F$N(Bpgpool$B$KB8:_$7$F$$$^$9!#(B +

    +

    $B%P%0=$@5(B

    +
      +
    • $B%U%m%s%H%(%s%I$K(Bpgpool$B$,%G!<%?$rAw?.$9$k:]$N%(%i!<$rL5;k$9$k$h$&$K$7$^$7$?!#$3$l$K$h$C$F!"%P%C%/%(%s%I$H$N4V$GI,MW$J=hM}$,CfCG$5$l$J$$$h$&$K$J$j!"%P%C%/%(%s%I$N4V$G%G!<%?$N0l4S@-$,$J$/$J$kLdBj$,2sHr$5$l$k$h$&$K$J$j$^$7$?(B(Tatsuo)$B!#(B + +
    • $B%^%9%?!<%9%l!<%V%b!<%I$K4X$9$k(B2.2.1$B$N=$@5$N:]$K@8$8$?%P%0$r=$@5$7$^$7$?!#%W%j%Z%"%I%9%F!<%H%a%s%H$r;H$$2s$9$H%O%s%0%"%C%W$9$k2DG=@-$,$"$j$^$7$?(B(Toshihiro)$B!#(B + +
    • SQL$B%3%^%s%I$N(BPREPARE$B$H%W%m%H%3%k%l%Y%k$N(BEXECUTE$B$,:.:_$9$k$H%P%C%/%(%s%I$,%/%i%C%7%e$9$k%P%0$r=$@5$7$^$7$?!#$3$N%P%0$,!"(B2.2$B$G;}$A9~$^$l$?$b$N$G$9(B(Tatsuo)$B!#(B + +
    • $B%3%M%/%7%g%s$N%j%;%C%HMQ$NLd9g$o$;$rl9g$K!"(BPostgreSQL$B$N%m%0$K(B"unexpected EOF on client connection"$B$,5-O?$5$l$kLdBj$r=$@5$7$^$7$?(B(Tatsuo)$B!#(B +
    + +

    2.2.1 (urukiboshi) 2009/4/25

    +

    $B35MW(B

    +

    +$B$3$N%P!<%8%g%s$G$O!"(B2.2$B$N?'!9$J%P%0$,=$@5$5$l$F$$$^$9!#(B +

    +

    $B%P%0=$@5(B

    +
      +
    • master/slave$B%b!<%I$G!"(BDEALLOCATE$B$,<:GT$9$k$3$H$,$"$kLdBj$r=$@5$7$^$7$?!#(B + $B$3$l$O!":G=i$N(BPREPARE$B$,(Bslave$B$Gpgpool.spec$B$J$I$r(B2.2$BBP1~$K$7$^$7$?(B(Devrim) + +
    • Version 2$B%W%m%H%3%k$G$O(Binsert_lock$B$,L5;k$5$l$k$h$&$K$7$^$7$?(B(Tatsuo) + +
    • $B%Q%i%a!<%?JQ99%a%C%;!<%8$,%P%C%/%(%s%I$+$iFO$/EY$K%m%0$,=PNO$5$l$k$N$r;_$a$^$7$?(B(Tatsuo) + +
    • $B%I%-%e%a%s%H$GDI2C$7K:$l$?%U%!%$%k$rEPO?$7$^$7$?(B(Tatsuo) +
    + +

    2.2 (urukiboshi) 2009/2/28

    +

    $B35MW(B

    +

    +$B$3$N%P!<%8%g%s$G$O!"(BSERIAL$B%G!<%?$N07$$$H%*%s%i%$%s%j%+%P%j$K2~NI$,9T$J$o$l$F$$$^$9!#(B +$B$^$?!"%H%i%s%6%/%7%g%sJ,N%%l%Y%k$,%7%j%"%i%$%6%V%k$N>l9g$K!"(BDB$B%N!<%I4V$G%G!<%?$N0l4S@-$,$J$/$J$k2DG=@-$,$"$kLdBj!"%/%(%j$N%-%c%s%;%k$,$G$-$J$$LdBj$,=$@5$5$l$^$7$?!#(B +

    + +

    $B?75!G=(B

    +

    +

      +
    • insert_lock$B$,M-8z$J>l9g!"(BSERIAL$B7?$r;}$D%F!<%V%k$@$1$,%m%C%/$5$l$k$h$&$K$J$j$^$7$?(B(Tatsuo)$B!#(B +
    • $B@_Dj9`L\(Bclient_idle_limit_in_recovery$B$,DI2C$5$l$^$7$?!#(B + $B%*%s%i%$%s%j%+%P%j$NBh(B2$B%9%F!<%8$G%/%i%$%"%s%H$,%"%$%I%k$N$^$^5o:B$k$3$H$K$h$C$F!"(B + $B%*%s%i%$%s%j%+%P%j$,?J9T$7$J$/$J$k$3$H$rKI$0$3$H$,$G$-$^$9(B(Tatsuo)$B!#(B +
    • $B@_Dj9`L\(Bpid_file_name$B$,DI2C$5$l$^$7$?!#$3$l$O!"(Bpgpool-II$B$N(Bpid$B%U%!%$%k$r;XDj$7$^$9!#(B + $B$3$l$K$h$j!"(Blogdir$B$O;HMQ$5$l$J$/$J$j$^$7$?(B(Tatsuo)$B!#(B +
    • DECLARE, FETCH, CLOSE$B$GIi2YJ,;6$5$l$k$h$&$K$J$j$^$7$?(B(Tatsuo)$B!#(B +
    • pcp$B%3%^%s%I$K%G%P%C%0%*%W%7%g%s(B(-d)$B$,DI2C$5$l$^$7$?(B(Jun Kuriyama)$B!#(B +
    • "kind mismatch"$B%(%i!<$N:]$K!"860x$H$J$C$?%/%(%j$rI=<($9$k$h$&$K$7$^$7$?(B(Tatsuo)$B!#(B +
    +

    + +

    $B8_49@-(B

    +
      +
    • $B%U%'%$%k%*!<%P;~$KI,$:(Bpgpool$B$N;R%W%m%;%9$r:F5/F0$9$k$h$&$K$7$^$7$?!#(B + $B$3$N7k2L!"%U%'%$%k%*!<%P;~$K$OI,$:(Bpgpool$B$X$N%;%C%7%g%s$,0lC<@Z$l$k$3$H$K$J$j$^$9!#(B + $B$3$&$7$J$$$H!"%M%C%H%o!<%/%1!<%V%kH4$1$J$I$N:]$K!"(B + TCP/IP$B$N%l%$%d$G:FAw$,9T$J$o$l!"D9$$;~4V$=$N$^$^$K$J$C$F$7$^$&$3$H$,(B + $B$"$k$+$i$G$9(B(Tatsuo)$B!#(B +
    • $B@_Dj9`L\(Blogdir$B$O;H$o$l$J$/$J$j$^$7$?!#Be$j$K!"(Bpid_file_name$B$r;H$C$F$/$@$5$$(B(Tatsuo)$B!#(B + +
    • insert_lock$B$N%G%U%)%k%HCM$,(Btrue$B$K$J$j$^$7$?(B(Tatsuo)$B!#(B +
    + +

    $B%P%0=$@5(B

    +
      +
    • pgpool$B$,%G!<%b%s%b!<%I$G5/F0$5$l$k:]$K!"$9$Y$F$N%U%!%$%k%G%#%9%/%j%W%?$r(B + $BJD$8$k$h$&$K$7$^$7$?!#$3$&$7$J$$$H!"(BpgpoolAdmin$B$+$i5/F0$5$l$?:]$K(B + apache$B$N%=%1%C%H%U%!%$%k$r0z$-7Q$$$G$7$^$$!"(B80$BHV%]!<%H$,(B + $B@lM-$5$l$F$7$^$$$^$9(B(Akio Ishida)$B!#(B +
    • $B%H%i%s%6%/%7%g%s$r%7%j%"%i%$%:$G$-$J$$%(%i!<$,H/@8$7$?$H$-$K!"(B + $B$9$Y$F$N(BDB$B%N!<%I$N%H%i%s%6%/%7%g%s$r%"%\!<%H$9$k$h$&$K$7$^$7$?!#(B + $B$3$&$7$J$$$H!"(BDB$B%N!<%I$N4V$G%G!<%?$NIT@09g$,5/$-$k$3$H$,$"$j$^$9(B(Tatsuo)$B!#(B + $BNc$r<($7$^$9(B(M$B$O%^%9%?!"(BS$B$O%9%l!<%V$r<($7$^$9(B)$B!#(B +
      +	   M:S1:BEGIN;
      +	   M:S2:BEGIN;
      +	   S:S1:BEGIN;
      +	   S:S2:BEGIN;
      +	   M:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
      +	   M:S2:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
      +	   S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
      +	   S:S2:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
      +	   M:S1:UPDATE t1 SET i = i + 1;
      +	   S:S1:UPDATE t1 SET i = i + 1;
      +	   M:S2:UPDATE t1 SET i = i + 1; <-- blocked
      +	   S:S1:COMMIT;
      +	   M:S1:COMMIT;
      +	   M:S2:ERROR:  could not serialize access due to concurrent update
      +	   S:S2:UPDATE t1 SET i = i + 1; <-- success in UPDATE and data becomes inconsistent!
      +	   
      + +
    • raw$B%b!<%I$G(BMD5$BG'>Z$,;H$($k$h$&$K$7$^$7$?!#%I%-%e%a%s%H>e$G$O;H$($k$O$:$G$7$?(B(Tatsuo)$B!#(B + +
    • "SET TRANSACTION ISOLATION LEVEL must be called before any query"$B$N(B + $B%(%i!<$,H/@8$7$?>l9g$K(B"kind mimatch"$B%(%i!<$K$J$k$3$H$rKI$0$h$&$K$7$^$7$?(B(Tatsuo)$B!#(B + $B0J2<$N%7%J%j%*$GLdBj$,H/@8$7$^$9!#(B +
      +	   M:S1:BEGIN;
      +	   S:S1:BEGIN;
      +	   M:S1:SELECT 1; <-- only sent to MASTER
      +	   M:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
      +	   S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
      +	   M: <-- error
      +	   S: <-- ok since no previous SELECT is sent. kind mismatch error occurs!
      +	   
      + +
    • FreeBSD$B$K$*$$$F!"(Bps$B$G$N(Bprocess status$B$NI=<($GM>7W$J%9%Z!<%9$,4^$^$l$F$7$^$&$N$r=$@5$7$^$7$?(B(Jun Kuriyama) + +
    • BEGIN;$B$r(B2$BEYB3$1$k$H(Bkind mismatch error$B$,H/@8$9$k$N$r=$@5$7$^$7$?(B(Tatsuo) + +
    • PostgreSQL$B$,$?$/$5$s$N(BDEBUG$B%a%C%;!<%8$r=PNO$9$k>l9g$K!"8m$C$F%(%i!<$H8+$J$9%P%0$r=$@5$7$^$7$?(B(Tatsuo) + +
    • $B%/%(%j$N%-%c%s%;%k$,F0$/$h$&$K$J$j$^$7$?(B(Tatsuo) + +
    • $B%*%s%i%$%s%j%+%P%j$N8e%/%i%$%"%s%H$+$i$N@\B3$rSELECT, INSERT, UPDATE, DELETE$B0J30$N%3%^%s%I$G$bI,MW$J$i$P%H%i%s%6%/%7%g%s%V%m%C%/$NFbB&$G$B%*%s%i%$%s%j%+%P%j8e!"(Bpgpool-II$B$N;R%W%m%;%9$,%/%i%C%7%e$9$k$3$H$,$"$k%P%0$r=$@5$7$^$7$?!#(B +$B$3$l$O!"%*%s%i%$%s%j%+%P%j$N8e!"?7$7$/%"%?%C%A$5$l$?%N!<%I$K@\B3$,$J$$$N$K!"$=$N%N!<%I$K;R%W%m%;%9$,=*N;;~$K=*N;%a%C%;!<%8$r%P%C%/%(%s%I$KAw?.$7$h$&$H$7$F5/$C$F$$$^$7$?(B(Tatsuo) + +
    • PostgreSQL$B$,(Bpostgresql.conf$B$r:FFI$_9~$_$7$?:]$K(Bpgpool$B$,%(%i!<$r8!=P$7$F$7$^$&%P%0$r=$@5$7$^$7$?!#(B +$B$3$l$O!"(BPostgreSQL$B$,!J$?$V$s!K%I%-%e%a%s%H$K=q$+$l$F$$$J$$%?%$%_%s%0$G!V%Q%i%a!<%?JQ99!W%Q%1%C%H$rAw?.$7$F$/$k$?$a$K5/$j!"=$@5$O$=$N$3$H$KBP1~$7$?$b$N$G$9(B(Tatsuo) + +
    + +

    2.1 (inamiboshi) 2008/7/25

    +

    $B?75!G=(B

    +
      +
    • failover_command $B$H(B failback_command $B$K!"?7$7$$%^%9%?%N!<%I(B ID + $B$rI=$9(B '%m' $B$r%5%]!<%H$7$^$7$?!#(B(Yoshiyuki) +
    • failover_command $B$H(B failback_command $B$K!"8E$$%^%9%?%N!<%I(B ID $B$r(B + $BI=$9(B '%M' $B$r%5%]!<%H$7$^$7$?!#(B(Yoshiyuki) +
    • $B%j%+%P%j$N%?%$%`%"%&%H;~4V$r;XDj$9$k(B recovery_timeout $B%Q%i%a!<(B + $B%?$rDI2C$7$^$7$?!#(B(Taiki) +
    • pg_md5 $B%3%^%s%I$K(B -p $B%*%W%7%g%s$rDI2C$7$^$7$?!#(B(Volkan Yazici, + Taiki) +
    • pgpool -v $B$r + +

      $B8_49@-(B

      +
        +
      • pgpool_recovery $B$H(B pgpool_remote_start $B4X?t$O%9!<%Q!<%f!<%6$N$_ raw $B%b!<%I$G%9%?%s%P%$%N!<%I$K$O%3%M%/%7%g%s%W!<%k$r:n@.$7$J$$(B + $B$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
      • replication_timeout $B%Q%i%a!<%?$r:o=|$7$^$7$?!#(B(Yoshiyuki) +
      • PCP $B%/%i%$%"%s%H%3%^%s%I$N%?%$%`%"%&%H$rL58z$K$7$^$7$?!#(B(Taiki) +
      • replicate_select = false $B$N>l9g$K!"(BCOPY TO STDOUT $B$r%l%W%j%1!<(B + $B%7%g%s$5$;$J$$$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
      + +

      $B=$@5(B

      +

      $BA4HL(B

      +
        +
      • CloseComplete $B%a%C%;!<%8$r $B%a%C%;!<%8E>Aw=hM}$r8zN($h$/$7$^$7$?!#(B(Yoshiyuki) +
      • Solaris 10 $B$G%3%s%Q%$%k$G$-$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
      • $B%X%k%9%A%'%C%/$H%j%+%P%j$N%m%0=PNO$r2~NI$7$^$7$?!#(B(Tatsuo) +
      • $BMM!9$J%a%b%j%j!<%/$r=$@5$7$^$7$?!#(B(Yoshiyuki) +
      • "failed to read kind from frontend" $B$H$$$&%(%i!<%a%C%;!<%8$r(B + ERROR$B%l%Y%k$+$i(B LOG $B%l%Y%k$K2<$2$^$7$?!#(B(Yoshiyuki) +
      • raw $B%b!<%I$G%U%'%$%k%*!<%P$K<:GT$9$kIT6q9g$r=$@5$7$^$7$?!#(B + (Taiki) +
      • $BIT@5$J%N!<%I$rDI2C!&@Z$jN%$7$r9T$&$H%>%s%S%W%m%;%9$,H/@8$9$kIT(B + $B6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) +
      • health_check_timeout $B$,@5$7$/F0:n$7$J$$IT6q9g$r=$@5$7$^$7$?!#(B + (Kenichi Sawada) +
      • FreeBSD $B$G(B ps $B%3%^%s%I$N=PNO$,@5$7$/$J$$IT6q9g$r=$@5$7$^$7$?!#(B + (ISHIDA Akio) +
      • Unix domain $B%=%1%C%H$,;D$C$F$$$k>l9g$N%(%i!<%a%C%;!<%8$r6/2=$7(B + $B$^$7$?!#(B(Jun Kuriyama) +
      • $BG'>Z$K<:GT$7$?>l9g$N%(%i!<%a%C%;!<%8$r6/2=$7$^$7$?!#(B(Tatsuo) +
      + +

      $B%l%W%j%1!<%7%g%s(B

      +
        +
      • replicate_select $B$r@_Dj$7$F$b!">o$K(B false $B$N5sF0$K$J$kIT6q9g$r(B + $B=$@5$7$^$7$?!#(B(Tatsuo) +
      • $B3HD%Ld$$9g$o$;%W%m%H%3%k$r;H$C$F$$$k$H!"%H%i%s%6%/%7%g%s$r8m$C$F%m!<(B + $B%k%P%C%/$7$F$7$^$&IT6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) +
      • $BHsF14|%/%(%j$r;H$C$F$$$k$H(B pgpool $B$,IT0BDj$K$J$kIT6q9g$r=$@5$7(B + $B$^$7$?!#(B(Yoshiyuki) +
      • $B3HD%Ld9g$;%W%m%H%3%k$r;H$&$H(B /* REPLICATION */$B$J$I$N%R%s%H6g$,>C$($F(B + $B$7$^$&IT6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) +
      • DEALLOCATE ALL $B$r immediate shutdown $B$9$k$H%O%s%0%"%C%W$9$kIT6q9g$r=$@5$7$^$7$?!#(B + (Yoshiyuki) +
      • $B9bIi2Y;~$K%*%s%i%$%s%j%+%P%j$r $B3HD%Ld9g$;%W%m%H%3%k$r;H$C$F(B SELECT $B$r + +

        $B%^%9%?!<%9%l!<%V(B

        +
          +
        • $B%H%i%s%6%/%7%g%s%V%m%C%/Fb$G!"(BSET, PREPARE, DEALLOCATE $B$r $B%^%9%?!<%9%l!<%V%b!<%I$G%m!<%I%P%i%s%9$,@5$7$/F0:n$7$F$$$J$$IT(B + $B6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) +
        + +

        $B%Q%i%l%k%/%(%j(B

        +
          +
        • INSERT $B$K<:GT$9$kIT6q9g$r=$@5$7$^$7$?!#(B(Yoshiharu) +
        • FROM $B6g$K(B AS $B$,4^$^$l$k$H9=J8%(%i!<$K$J$kIT6q9g$r=$@5$7$^$7$?!#(B(sho) +
        • $B%/%(%j$rJ#?t2s JOIN $B$K<:GT$9$kIT6q9g$r=$@5$7$^$7$?!#(B(Yoshiharu) +
        • DISTINCT$B9=J8(B $B$N2r@O$K<:GT$9$kIT6q9g$r=$@5$7$^$7$?!#(B(Yoshiharu) +
        + +
        + +

        2.0.1 (hikitsuboshi) 2007/11/21

        +
          +
        • UPDATE $B$b$7$/$O(B DELETE $B$r master_slave $B$r(B true $B$K@_Dj$7$F$$$k>l9g$K!"(BSQL $B9=J8%(%i!<$r8!CN(B + $B$7$?;~$K%^%9%?$K$N$_$=$N%/%(%j$rAw?.$9$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
        + +
        + +

        2.0 (hikitsuboshi) 2007/11/16

        +

        $B8_49@-(B

        +
          +
        • ignore_leading_white_space $B$N%G%U%)%k%HCM$r(B true $B$K$7$^$7$?!#(B + (Yoshiyuki) +
        • replicate_strict $B$rGQ;_$7$^$7$?!#>o$K(B replicate_strict $B$,(B true + $B$N5sF0$K$J$j$^$9!#(B(Yoshiyuki) +
        + +

        $BA4HL(B

        +
          +
        • pgpool.conf $B$r%j%m!<%I$G$-$k$h$&$K$7$^$7$?!#%j%m!<%I;~$KJ,;6%k!<(B + $B%k$bF1;~$K%j%m!<%I$7$^$9!#(B(Yoshiyuki) +
        • SQL $B%Q!<%5$r(B PostgreSQL 8.3 $B$KBP1~$7$^$7$?!#(B(Yoshiyuki) +
        • $B%N!<%I$r@Z$jN%$7$?:]$K%f!<%6$,@_Dj$7$?%3%^%s%I$r $B%N!<%I$rI|5"$7$?:]$K%f!<%6$,@_Dj$7$?%3%^%s%I$r pgpool.conf $B$K(B client_idle_limit $B$H$$$&%Q%i%a!<%?$rDI2C$7$^$7$?!#(B + $B$3$N%Q%i%a!<%?$G$O%/%i%$%"%s%H$+$i$N%/%(%j$N:GBgBT$A;~4V$r@_Dj$9$k$3(B + $B$H$,$G$-$^$9!#(B(Tatsuo) +
        + +

        $B%l%W%j%1!<%7%g%s(B

        +
          +
        • $B%H%i%s%6%/%7%g%s%V%m%C%/$K0O$^$l$F$$$J$$%/%(%j$r%l%W%j%1!<%7%g(B + $B%s$5$;$k>l9g!"FbItE*$K%H%i%s%6%/%7%g%s$r3+;O$5$;$k$h$&$K$7$^$7$?!#(B + (Yoshiyuki) +
        • $B%l%W%j%1!<%7%g%s$r9bB.2=$5$;$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
        • $B%N!<%I$r:FF14|$5$;$FI|5"$5$;$k!"%*%s%i%$%s%j%+%P%j5!G=$r INSERT, UPDATE, DELETE $B$7$?9T?t$,$9$Y$F0lCW$7$J$+$C$?>l9g$K!"%H(B + $B%i%s%6%/%7%g%s$r%"%\!<%H$5$;$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
          +   x=# update t set a = a + 1;
          +   ERROR:  pgpool detected difference of the number of update tuples
          +   HINT:  check data consistency between master and other db node
          +
          +
        • $BJ#?t$N%P%C%/%(%s%I$+$i0[$J$k7k2L$,JV$C$F$-$?>l9g$K!"F1$87k2L$,(B + $BB??tJV$C$F$-$?7k2L$r?.Mj$9$kB??t7hJ}<0$r V2 $BLd9g$;%W%m%H%3%k$G%m!<%I%P%i%s%9$G$-$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
        + +

        $B%Q%i%l%k%/%(%j(B

        +
          +
        • $B%Q%i%l%k%b!<%I$GItJ,%l%W%j%1!<%7%g%s$r%5%]!<%H$7$^$7$?!#(B(Yoshiharu) +
        + +
        + +

        1.3 (sohiboshi) 2007/10/23

        +
          +
        • $B?7$7$/(B authentication_timeout $B$H$$$&%Q%i%a!<%?$rDI2C$7$^$7$?!#(B(Yoshiyuki) +
            +
          • $B$3$N%Q%i%a!<%?$G$OG'>Z;~4V$N%?%$%`%"%&%H$r@_Dj$7$^$9!#(B +
          • $B%G%U%)%k%HCM$O(B 60 (1 $BJ,(B)$B$G$9!#(B +
          +
        • $B%9%?!<%H%"%C%W%Q%1%C%H$ND9$5$,(B 10000 $B%P%$%H1[$($F$$$k>l9g$K$O!"@\B3$r@ZCG$9$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
        • DEALLOCATE $B$r $B%H%i%s%6%/%7%g%sFb$G(B SELECT $B$r +
        • $B$3$NIT6q9g$O(B 1.2 $B$G:.F~$7$?IT6q9g$G$9!#(B +
        +
      • 64bit $B4D6-$G%/%(%j%-%c%C%7%e5!G=$rM-8z$K$9$k$H!"%/%i%C%7%e$9$k2DG=@-$N$"$kIT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      + +
      + +

      1.2.1 (tomoboshi) 2007/09/28

      +
        +
      • $B3HD%Ld9g$;%W%m%H%3%k$N(B Parse $B%a%C%;!<%8$N=hM}$G%G%C%I%m%C%/$,H/(B + $B@8$9$k2DG=@-$,$"$kIT6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • Prepared statement $B$r4IM}$9$kNN0h$,%a%b%j%j!<%/$7$F$$$kIT6q9g$r(B + $B=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • $B0lIt$N(B OS $B$G%3%s%Q%$%k%(%i!<$K$J$kIT6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • master/slave $B%b!<%IFb$G(B SET, PREPARE, DEALLOCATE $BJ8$r%l%W%j%1!<%7%g%s$5$;$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
      + +
      + +

      1.2 (tomoboshi) 2007/08/01

      +
        +
      • pgpool.conf $B$K(B replicate_select $B$H$$$&?75,%Q%i%a!<%?$rDI2C$7$^(B + $B$7$?!#%G%U%)%k%HCM$O(B false $B$G$9!#(B(Yoshiyuki) +
          +
        • true $B$K@_Dj$7$?>l9g$O!"%m!<%I%P%i%s%9$5$l$J$$(B SELECT $BJ8$r%l%W(B + $B%j%1!<%7%g%s$7$^$9(B(pgpool-II 1.0 $B$N5sF0(B)$B!#(Bfalse $B$N>l9g$O%^%9%?$K$N(B + $B$_(B SELECT $B$rAw?.$7$^$9!#(B +
        + +
      • $B%7%0%J%k=hM}$r0BA4$K9T$&$h$&$K$7$^$7$?!#(B(Yoshiyuki) +
          +
        • $B$^$l$K%>%s%S%W%m%;%9$,;D$C$F$7$^$C$?$j!"IT0BDj$K$J$k$3$H$,$"$j$^$7$?!#(B +
        + +
      • $B%H%i%s%6%/%7%g%sCf$K(B SELECT $BJ8$,%(%i!<$K$J$k$H!"%O%s%0%"%C%W$7(B + $B$F$7$^$&IT6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) +
          +
        • $B$3$NIT6q9g$O(B 1.1 $B$KF~$C$?IT6q9g$G$9!#(B +
        + +
      • PREPARE/EXECUTE $B$,(B master/slave $B%b!<%I$G@5$7$/F0:n$7$J$$IT6q9g(B + $B$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • $B%G%C%I%m%C%/$r8!CN$9$k$H!"(Bkind mismatch error $B$,H/@8$9$kIT6q9g(B + $B$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • $B3HD%Ld$$9g$o$;%W%m%H%3%k$r;H$C$?%I%i%$%P$r;HMQ$7$?>l9g$K!"9=J8(B + $B2r@O;~$K7Y9p$,H/@8$9$k(B SQL $BJ8$r $B%3%M%/%7%g%s%-%c%C%7%e$,0lGU$K$J$k$H%a%b%j%j!<%/$,H/@8$9$kIT6q(B + $B9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • $B%;%C%7%g%s$,;D$C$?>uBV$G(B PostgreSQL $B$r(B fast shutdown $B$b$7$/$O(B + immediate shutdown $B$9$k$H!";D$C$?%;%C%7%g%s$,%O%s%0%"%C%W$9$kIT6q9g(B + $B$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      • $B%m!<%I%P%i%s%9@h$r@\B33+;O;~$K7hDj$7!"F1$8%;%C%7%g%sFb$G$O$9$Y(B + $B$FF1$8%N!<%I$K%/%(%j$rAw?.$9$k$h$&$K$7$^$7$?!#(B(Yoshiyuki) + +
      • connection_life_time $B$r@_Dj$7$F$$$k>l9g$K%P%C%U%!%*!<%P%i%s$,H/(B + $B@8$9$k2DG=@-$,$"$kIT6q9g$r=$@5$7$^$7$?!#(B(Yoshiyuki) + +
      + +
      + +

      1.1.1 (amiboshi) 2007/06/15

      +
        +
      • load_balance_mode $B$rM-8z$K$7$F$$$k$H!"(B"kind mismatch" $B%(%i!<$,(B + $BH/@8$7$F$7$^$&IT6q9g$r=$@5$7$^$7$?!#$3$l$O(B 1.1 $B$GF~$C$?IT6q9g$G$9!#(B + (Yoshiyuki) +
      • $B%W%m%H%3%k%P!<%8%g%s(B 2 $B$r;H$C$?%I%i%$%P$G%l%W%j%1!<%7%g%s;HMQ$9(B + $B$k$H!"(Bpgpool $B$,%O%s%0%"%C%W$9$kIT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      • $B3HD%Ld9g$;%W%m%H%3%k$r;HMQ$9$k$H!"$^$l$K%G%C%I%m%C%/$,H/@8$9$k(B + $BIT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      + +
      + +

      1.1 (amiboshi) 2007/05/25

      +
        +
      • HBA $BG'>Z$r%5%]!<%H$7$^$7$?(B(Taiki) +
      • log_connections $B$r%5%]!<%H$7$^$7$?(B(Taiki) +
      • log_hostname $B$r%5%]!<%H$7$^$7$?(B(Taiki) +
      • ps $B%3%^%s%I$G(B pgpool $B$N>uBV$,$o$+$k$h$&$K$7$^$7$?(B(Taiki) +
      • MacOS X $B$G%3%s%Q%$%k%(%i!<$K$J$kIT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      • $B3HD%Ld$$9g$o$;%W%m%H%3%k$r;H$C$?%/%(%j$r%m!<%I%P%i%s%9$G$-$k$h(B + $B$&$K$7$^$7$?(B(Yoshiyuki) +
      • $B%l%W%j%1!<%7%g%s@_Dj;~!"(BSELECT $B$O(B master $B$K$N$_Aw?.$9$k$h$&$K$7(B + $B$^$7$?(B(Yoshiyuki) +
          +
        • $B$b$7(B SELECT $B$r%l%W%j%1!<%7%g%s$5$;$k>l9g$O(B /*REPLICATION*/ + $B$N$h$&$K(B SELECT $B$NA0$K%3%a%s%H$rIU$1$kI,MW$,$"$j$^$9(B +
        +
      • $B%l%W%j%1!<%7%g%s@_Dj;~!"(BSELECT nextval() $B$*$h$S(B SELECT setval() + $B$r<+F0E*$K%l%W%j%1!<%7%g%s$5$;$k$h$&$K$7$^$7$?(B(Yoshiyuki) +
      • $B%P%C%/%(%s%I$X@\B3Cf$K%7%0%J%k$K3d$j9~$^$l$k$H!"%U%'%$%k%*!<%P(B + $B$7$F$7$^$&IT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      • PAM $BG'>Z$N%5%s%W%k%U%!%$%k(B pgpool.pam $B$r(B + $PREFIX/share/pgpool-II/ $B$K%$%s%9%H!<%k$9$k$h$&$K$7$^$7$?(B(Taiki) +
      • $B5pBg$J(B SQL $B$rl9g$K(B pgpool $B$,L58B%k!<%W$KF~$kIT(B + $B6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      + +
      + +

      1.0.2 (suboshi) 2007/02/13

      +
        +
      • $B5pBg$J(B SQL $B$rl9g$K(B pgpool $B$,L58B%k!<%W$KF~$kIT(B + $B6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      • $B3HD%Ld9g$;%W%m%H%3%k$r;H$C$?>l9g$K$^$l$K(B pgpool $B$,;_$^$C$F$7$^(B + $B$&IT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      • $B%U%'%$%k%*!<%P!"%U%'%$%k%P%C%/;~$N%m%0=PNO$r2~A1$7$^$7$?(B + (Tatsuo) +
      • SHOW pool_status $B$N7k2L$K%P%C%/%(%s%I%9%F!<%?%9>pJs$rDI2C$7$^$7(B + $B$?(B(Tatsuo) +
      • $B%l%W%j%1!<%7%g%s;~$K(B UPDATE/DELETE $B$N7o?t$, $B8E$$(B gcc $B$r;H$&$H(B libpq $B$N%j%s%/$K<:GT$9$kIT6q9g$r=$@5$7$^$7$?(B + (Yoshiyuki) +
      • PHP:PDO $B$d(B DBD-Pg $B$r;H$C$?>l9g$K!"<+F0(B DEALLOCATE $B$,<:GT$7$F$7(B + $B$^$&IT6q9g$r=$@5$7$^$7$?(B(Yoshiyuki) +
      • SELECT FOR UPDATE, SELECT INTO $B$r%m!<%I%P%i%s%9$5$;$J$$$h$&$K$7(B + $B$^$7$?!#$^$?!"(BSELECT $B$NA0$K%3%a%s%H$,$"$k>l9g$b%m!<%I%P%i%s%9$5$;$J(B + $B$$$h$&$K$7$^$7$?!#$3$l$O(B pgpool-I $B$H$N8_49@-$N$?$a$G$9!#(B(Yoshiyuki) +
      • configure $B;~$N(B libpq $B$N%G%U%)%k%H%Q%9$r(B pg_config $B%3%^%s%I$r;H$C(B + $B$F $B%3%M%/%7%g%s%W!<%k:FMxMQ;~$K!"%=%1%C%H$,2u$l$F$$$k>l9g$O:F@\B3(B + $B$9$k$h$&$K$7$^$7$?(B(Yoshiyuki) +
      • PostgreSQL 7.4.x $B$N(B libpq $B$r;H$C$F%S%k%I$7$h$&$H$9$k$H!"(B + configure $B%9%/%j%W%H$G%(%i!<$H$J$C$F$7$^$&IT6q9g$r=$@5$7$^$7$?(B + (Yoshiyuki) +
      + + + + diff --git a/doc/pgpool.css b/doc/pgpool.css new file mode 100644 index 0000000..6fe66a7 --- /dev/null +++ b/doc/pgpool.css @@ -0,0 +1,145 @@ +ul#navlist + { + width: 158px; + \width: 160px; + w\idth: 158px; + padding: 0px; + border: 1px solid #808080; + border-top: 0px; + margin: 0px; + font: bold 12px verdana,helvetica,arial,sans-serif; + background: #808080; + } + + ul#navlist li + { + list-style: none; + margin: 0px; + border: 0px; + border-top: 1px solid #808080; + font-size:7pt; + } + + ul#navlist li a + { + display: block; + width: 122px; + \width: 158px; + w\idth: 122px; + padding: 4px 8px 4px 8px; + border: 0px; + border-left: 20px solid #aaaabb; + background: #ccccdd; + text-decoration: none; + text-align: right; + + } + + ul#navlist li a:link { color: #666677; } + div#navcontainer li a:visited { color: #666677; } + + ul#navlist li a:hover + { + border-color: #ff9000; + color: #ffffff; + background: #000d33; + } + +/* --------------------------- */ +body { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:9pt; + margin: 0px; + color: black; + border-left: 20px solid #ccc; +} +td { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:9pt; + margin: 0px; + color: black; + border-left: 2px dotted #ccc; +} +pre { + font-size:10px; + background-color:#f0f0f0; + color: brown; + padding: 5px; + margin-left:40px; + margin-right:30px; +} +h1 { + border-bottom: 2px solid #6699CC; + padding: 5px; + margin-left:10px; + background:#F9FBF9; +} +h2 { + border-bottom: 2px solid #669966; + padding: 5px; + margin-left:30px; + background: #F4F8F1; +} + +h3 { + border-bottom: 2px solid #669966; + padding: 5px; + margin-left:40px; + background: #F4F8F1; +} + +h4 { + border-bottom: 2px solid #669966; + padding: 5px; + margin-left:50px; + background: #F4F8F1; +} + +p { + padding-left: 15px; + padding-right: 15px; + margin-left:25px; + margin-right:25px; + +} + +ul, ol,dl { + margin-left:40px; +} +dt { + font-weight:bold; +} + +ul li { + list-style:square; + color: #663333; +} + +ol li { + color: #663333; +} + + + a:link { color: blue; } + a:hover{ color: red; } + + +.header_small { + font-size: 0.9em; + background-color: #f0f0f0; + +} +.header_text { + border-bottom: 2px solid #663366; + padding: 5px; + background-color: #E9F8F8; + font-size: 2em; + font-weight:bold; + padding:25px; +} + +.copyright { + padding: 5px; + padding:25px; + text-align:center; +} diff --git a/doc/tutorial-en.html b/doc/tutorial-en.html new file mode 100644 index 0000000..33d60ab --- /dev/null +++ b/doc/tutorial-en.html @@ -0,0 +1,697 @@ + + + + + +pgpool-II Tutorial + + + + + +

      pgpool-II Tutorial

      +

      Welcome to the Tutorial for pgpool-II. From here, you can learn how +to install, setup, and run parallel queries or do replication using +pgpool-II. We assume that you already know basic PostreSQL operations, +so please refer to the PostgreSQL document if needed.

      + +
      +
      Table of Contents
      +
      1. Let's Begin!
      +
      1.1. Installing pgpool-II
      +
      1.2. Configuration Files
      +
      1.3. Configuring PCP commands
      +
      1.4. Preparing Database Nodes
      +
      1.5. Starting/Stopping pgpool-II
      +
      2. Your First Replication
      +
      2.1. Configuring Replication
      +
      2.2. Checking Replication
      +
      3. Your First Parallel Query
      +
      3.1. Configuring Parallel Query
      +
      3.2. Configuring the System Database
      +
      3.3. Partitioning Rule Definition
      +
      3.4. Replication Rule Definition
      +
      3.5. Checking Parallel Query
      +
      + + +

      1. Let's Begin!

      + +

      First, we must learn how to install, configure pgpool-II and +database nodes before using replication or parallel query.

      + +

      1.1. Installing pgpool-II

      + +

      Installing pgpool-II is very easy. In the directory which you have +extracted the source tar ball, execute the following commands.

      + +
      +$ ./configure
      +$ make
      +$ make install
      +
      + +

      configure script collects your system information +and use it for the compilation procedure. You can pass command line +arguments to configure script to change the default +behavior, such as the installation directory. pgpool-II will be +installed to /usr/local directory by default.

      + +

      make command compiles the source code, and make +install will install the executables. You must have write +permission on the installation directory.

      + +

      In this tutorial, we will install pgpool-II in the default +/usr/local directory.

      + +

      Note: pgpool-II requires libpq library in PostgreSQL 7.4 +or later (version 3 protocol). If configure script +displays the following error message, libpq library may not be +installed, or it is not of version 3.

      + +
      configure: error: libpq is not installed or libpq is old
      + +

      If the library is version 3, but above message is still displayed, +your libpq library is probably not recognized by +configure script.

      + +

      configure script searches for libpq library under +/usr/local/pgsql libaray. If you have installed +PostgreSQL to a directory other than /usr/local/pgsql, +use --with-pgsql, or --with-pgsql-includedir +and --with-pgsql-libdir command line options when you +execute configure.

      + +

      1.2. Configuration Files

      + +

      pgpool-II configuration parameters are saved in +pgpool.conf file. The file is in "parameter = +value" per line format. When you install pgpool-II, +pgpool.conf.sample is automatically created. We recommend +copying and renaming it to pgpool.conf, and edit it as +you like.

      + +
      $ cp /usr/local/etc/pgpool.conf.sample /usr/local/etc/pgpool.conf
      + +

      pgpool-II only accepts connections from the local host using port +9999. If you wish to receive conenctions from other hosts, set +listen_addresses to '*'.

      + +
      +listen_addresses = 'localhost'
      +port = 9999
      +
      + +

      We will use the default parameters in thie tutorial.

      + +

      1.3. Configuring PCP Commands

      + +

      pgpool-II has an interface for administration purpose to retrieve +information on database nodes, shutdown pgpool-II, etc. via +network. To use PCP commands, user authentication is required. This +authentication is different from PostgreSQL's user authentication. A +username and password need to be defined in pcp.conf +file. In the file, a username and password are listed as a pair on +each line, and they are separated by a colon (:). Passwords are +encrypted in md5 hash format.

      + +
      postgres:e8a48653851e28c69d0506508fb27fc5
      +

      +When you install pgpool-II, pcp.conf.sample is +automatically created. We recommend copying and renaming it to +pcp.conf, and edit it. +

      +
      $ cp /usr/local/etc/pcp.conf.sample /usr/local/etc/pcp.conf
      + +

      To encrypt your password into md5 hash format, use pg_md5 command, +which is installed as a part of pgpool-II +executables. pg_md5 takes text as an command line +argument, and displays its md5-hashed text.

      + +

      For example, give "postgres" as the command line argument, at +pg_md5 displays md5-hashed text to the standard +output.

      + +
      +$ /usr/bin/pg_md5 postgres
      +e8a48653851e28c69d0506508fb27fc5
      +
      + +

      PCP commands are executed via network, so the port number must be +configured with pcp_port parameter in +pgpool.conf file.

      + +

      We will use the default 9898 for pcp_port in this tutorial.

      + +
      pcp_port = 9898
      + +

      1.4. Preparing Database Nodes

      + +

      Now, we need to set up backend PostgreSQL servers for +pgpool-II. These servers can be placed within the same host as +pgpool-II, or on separate machines. If you decide to place the servers +on the same host, different port numbers must be assigned for each +server. If the servers are placed on separate machines, they must be +configured properly so that they can accept network connections from +pgpool-II.

      + +

      In this tutorial, we will place three servers within the same host +as pgpool-II, and assign 5432, 5433, 5434 port numbers +respectively. To configure pgpool-II, edit pgpool.conf as +follows. + +

      +backend_hostname0 = 'localhost'
      +backend_port0 = 5432
      +backend_weight0 = 1
      +backend_hostname1 = 'localhost'
      +backend_port1 = 5433
      +backend_weight1 = 1
      +backend_hostname2 = 'localhost'
      +backend_port2 = 5434
      +backend_weight2 = 1
      +
      + +

      For backend_hostname, backend_port, +backend_weight, set the node's hostname, port number, and +ratio for load balancing. At the end of each parameter string, node ID +must be specified by adding positive integers starting with 0 (i.e. 0, +1, 2, …).

      + +

      backend_weight parameters are all 1, meaning that +SELECT queries are equally distributed among three servers.

      + +

      1.5. Starting/Stopping pgpool-II

      + +

      To fire up pgpool-II, execute the following command on a terminal.

      + +
      $ pgpool
      + +

      The above command, however, prints no log messages because pgpool +detaches the terminal. If you want to show pgpool log messages, you +pass -n option to pgpool command. pgpool-II is executed +as non-daemon process, and the terminal will not be detached. +

      + +
      +$ pgpool -n &
      +
      + +

      +The log messages are printed on the terminal, so the recommended +options to use are like the following. +

      + +
      $ pgpool -n -d > /tmp/pgpool.log 2>&1 &
      + +

      -d option enables debug messages to be generated.

      + +

      +The above command keeps appending log messages to /tmp/pgpool.log. If +you need to rotate log files, pass the logs to a external command +which have log rotation function. + +For example, you can use rotatelogs coming with Apache2: +

      +$ pgpool -n 2>&1 | /usr/local/apache2/bin/rotatelogs \
      +  -l -f /var/log/pgpool/pgpool.log.%A 86400 &
      +
      +This will generate a log file named "pgpool.log.Thursday" everyday then +rotate it 00:00 at midnight. Rotatelogs adds log to a file if it already +exists. To delete old log files before rotation, you could use cron: +
      +55 23 * * * /usr/bin/find /var/log/pgpool -type f -mtime +5 -exec /bin/rm -f '{}' \;
      +
      +Please note that rotaelogs may exist as /usr/sbin/rotatelogs2 in some +distributions. +-f option generates a log file as soon as rotatelogs starts and is +available apache2 2.2.9 or greater. +

      +

      +Also cronolog helps you. +

      + +
      +$ pgpool -n 2>&1 | /usr/sbin/cronolog \
      +  --hardlink=/var/log/pgsql/pgpool.log \
      +  '/var/log/pgsql/%Y-%m-%d-pgpool.log' &
      +
      + +

      To stop pgpool-II process, execute the following command.

      + +
      $ pgpool stop
      + +

      If any client is still connected, pgpool-II waits for them to +disconnect, and then terminate itself. Execute the following command +instead if you want to shutdown pgpool-II forcibly. + +

      $ pgpool -m fast stop
      + +

      2. Your First Replication

      + +

      Replication enables the same data to be copied to multiple database +nodes.

      + +

      In this section, we'll use three database nodes, which we have +already set up in section "1. Let's Begin!", and +takes you step by step to create a database replication system. Sample +data to be replicated will be generated by pgbench benchmark +program.

      + +

      2.1. Configuring Replication

      + +

      To enable the database replication function, set +replication_mode to true in pgpool.conf +file.

      + +
      replication_mode = true
      + +

      When replication_mode is set to true, pgpool-II will send a +copy of a received query to all the database nodes.

      + +

      When load_balance_mode is set to true, pgpool-II will +distribute SELECT queries among the database nodes.

      + +
      load_balance_mode = true
      + +

      In this section, we enable both replication_mode and +load_balance_mode.

      + +

      2.2. Checking Replication

      + +

      To reflect the changes in pgpool.conf, pgpool-II must +be restarted. Please refer to section "1.5 Starting/Stopping pgpool-II".

      + +

      After configuring pgpool.conf and restarting +pgpool-II, let's try the actual replication and see if everything is +working OK.

      + +

      First, we need to create a database to be replicated. We will name +it "bench_replication". This database needs to be created on all the +nodes. Use createdb commands through pgpool-II, and the +database will be created on all the nodes.

      + +
      $ createdb -p 9999 bench_replication
      + +

      Then, we'll execute pgbench with -i +option. -i option initializes the database with +pre-defined tables and data.

      + +
      $ pgbench -i -p 9999 bench_replication
      + +

      The following table is the summary of tables and data, which will +be created by pgbench -i. If, on all the nodes, the +listed tables and data are created, replication is working correctly. + + + + + + + + + + + + + + + + + + + + + + +
      Table NameNumber of Rows
      branches1
      tellers10
      accounts100000
      history0
      + +

      Let's use a simple shell script to check the above on all the +nodes. The following script will display the number of rows in +branches, tellers, accounts, and history tables on all the nodes (5432, +5433, 5434).

      + +
      $ for port in 5432 5433 5434; do
      +>     echo $port
      +>     for table_name in branches tellers accounts history; do
      +>         echo $table_name
      +>         psql -c "SELECT count(*) FROM $table_name" -p $port bench_replication
      +>     done
      +> done
      +
      + +

      3. Your First Parallel Query

      +

      +Data within the different range is stored in two or more data base nodes in a parallel Query. This is called a partitioning. Moreover, the same data as two or more data base nodes can be reproduced with partitioning. +

      + +

      To enable parallel query in pgpool-II, you must set up another +database called "System Database" (we will denote it as SystemDB from +this point).

      + +

      SystemDB holds the user-defined rules to decide what data will be +saved in which database node. Another use of SystemDB is to merge +results sent back from the database nodes using dblink.

      + +

      In this section, we will use three database nodes which we have set +up in section "1. Let's Begin!", and takes you +step by step to create a parallel query database system. We will use +pgbench again to create sample data.

      + +

      3.1. Configuring Parallel Query

      + +

      To enable the parallel query function, set parallel_mode to true in pgpool.conf file.

      + +
      parallel_mode = true
      + +

      Setting paralle_mode to true does not start parallel +query automatically. pgpool-II needs SystemDB and the rules +to know how to distribute data to the database nodes.

      + +

      Also, dblink used by SystemDB makes connections to +pgpool-II. Therefore, listen_addresses needs to be +configured so that pgpool-II accepts those connections.

      + +
      listen_addresses = '*'
      + +

      +Attention: The replication is not done for the table that does the partitioning +though a parallel Query and the replication can be made effective at the same time. +The data base made by Moreover, because the composition of the data stored in +the data base is different in a parallel Query and the replication, that is, +"bench_replication" created in section "2. Your +First Replication" cannot be reused.

      + +
      +replication_mode = true
      +load_balance_mode = false
      +
      +

      +OR +

      +
      +replication_mode = false
      +load_balance_mode = true
      +
      + +

      In this section, we will set parallel_mode and load_balance_mode to true, +listen_addresses to '*', replication_modeto false.

      + +

      3.2. Configuring SystemDB

      + +

      +There is no difference in the data base the system data base and usually. +However, the function of dblink is defined in the system data base, and +the table that stores a distribution rule.. It is necessary to define dist_def. Moreover, +the data base node One can make the system data base, and pgpool-II can be +distributed in the load by connecting the cascade. +

      + +

      In this section, we will create SystemDB within the 5432 port +node. The following list is the configuration parameters for +SystemDB

      + +
      +system_db_hostname = 'localhost'
      +system_db_port = 5432
      +system_db_dbname = 'pgpool'
      +system_db_schema = 'pgpool_catalog'
      +system_db_user = 'pgpool'
      +system_db_password = ''
      +
      + +

      Actually, the above are the default settings of +pgpool.conf. Now, we must create a user called "pgpool", +and a database called "pgpool" owned by user "pgpool".

      + +
      +$ createuser -p 5432 pgpool
      +$ createdb -p 5432 -O pgpool pgpool
      +
      + +

      3.2.1. Installing dblink

      + +

      Next, we must install dblink into "pgpool" database. dblink is one +of the tools included in contrib directory in the +PostgreSQL source code.

      + +

      To install dblink to your system, execute the following commands.

      + +
      +$ USE_PGXS=1 make -C contrib/dblink
      +$ USE_PGXS=1 make -C contrib/dblink install
      +
      + +

      After dblink has been installed into your system, we will define +dblink functions in "pgpool" database. If PostgreSQL is installed in +/usr/local/pgsql, dblink.sql (a file with +function definitions) should have been installed in +/usr/local/pgsql/share/contrib. Now, execute the +following command to define dblink functions.

      + +
      $ psql -f /usr/local/pgsql/share/contrib/dblink.sql -p 5432 pgpool
      + +

      3.2.2. Defining dist_def table

      + +

      Next, we will define a table called "dist_def" to hold the +distribution rules. When pgpool-II was installed, a file called +system_db.sql should have been installed in +/usr/local/share/system_db.sql (note that in this +tutorial, we are using the default installation directory, +/usr/local). systeym_db.sql contains +definitions to create special tables including "dist_def" +table. Execute the following command to define "dist_def" table.

      + +
      $ psql -f /usr/local/share/system_db.sql -p 5432 -U pgpool pgpool
      + +

      In system_db.sql, tables including "dist_def" are +installed in "pgpool_catalog" schema. If you have configured +system_db_schema to use other schema, you need to edit +system_db.sql accordingly.

      + +

      The definition for "dist_def" is as shown here, and the table name +cannot be changed.

      + +
      +CREATE TABLE pgpool_catalog.dist_def (
      +    dbname text, -- database name
      +    schema_name text, -- schema name
      +    table_name text, -- table name
      +    col_name text NOT NULL CHECK (col_name = ANY (col_list)), -- distribution key-column
      +    col_list text[] NOT NULL, -- list of column names
      +    type_list text[] NOT NULL, -- list of column types
      +    dist_def_func text NOT NULL, -- distribution function name
      +    PRIMARY KEY (dbname, schema_name, table_name)
      +);
      +
      + +

      A tuple stored in "dist_def" can be classified into two types.

      + +
        +
      • Distribution Rule (col_name, dist_def_func)
      • +
      • Table's meta-information (dbname, schema_name, table_name, col_list, type_list)
      • +
      + +

      A distribution rule decides how to distribute data to a +particular node. Data will be distributed depending on the value of +"col_name" column. "dist_def_func" is a function that takes the value +of "col_name" as its argument, and returns an integer which +points to the appropriate database node ID where the data should be +stored.

      + +

      A meta-information is used to rewrite queries. Parallel query +must rewrite queries so that the results sent back from the backend +nodes can be merged into one result.

      + +

      3.2.2. Defining replicate_def table

      +

      +When the table that does the replication to one SQL sentence with the table +registered in dist_def by uniting tables is specified, information on the +table that does the replication (replication rule) is registered in the table +named replicate_def beforehand. +The replicate_def table has already been made when making it from the +system_db.sql file when dist_def is defined. +The replicate_def table is defined as follows. +

      +
      +CREATE TABLE pgpool_catalog.replicate_def (
      +    dbname text, -- database name
      +    schema_name text, -- schema name
      +    table_name text, -- table name
      +    col_list text[] NOT NULL, -- list of column names
      +    type_list text[] NOT NULL, -- list of column types
      +    PRIMARY KEY (dbname, schema_name, table_name)
      +);
      +
      + + +

      3.3. Defining Distribution Rules

      + +

      In this tutorial, we will define rules to distribute pgbench's +sample data into three database nodes. The sample data will be created +by "pgbench -i -s 3" (i.e. scale factor of 3). We will create a new +database called "bench_parallel" for this section.

      + +

      In pgpool-II's source code, you can find +dist_def_pgbench.sql file in sample +directoy. We will use this sample file here to create distribution +rules for pgbench. Execute the following command in extracted +pgpool-II source code directory.

      + +
      $ psql -f sample/dist_def_pgbench.sql -p 5432 pgpool
      + +

      Here is the explanation of dist_def_pgbench.sql.

      + +

      Inside dist_def_pgbench.sql, we are inserting one +row into "dist_def" table. There is a distribution +function for accounts table. +For key-column, aid is defined for accounts respectively (which is primary keys)

      + +
      +INSERT INTO pgpool_catalog.dist_def VALUES (
      +    'bench_parallel',
      +    'public',
      +    'accounts',
      +    'aid',
      +    ARRAY['aid', 'bid', 'abalance', 'filler'],
      +    ARRAY['integer', 'integer', 'integer', 'character(84)'],
      +    'pgpool_catalog.dist_def_accounts'
      +);
      +
      + +

      Now, we must define the distribution function for accounts table. Note +that you can use the same function from different tables. Also, you +can define functions using languages other than SQL (e.g. PL/pgSQL, +PL/Tcl, etc.).

      + +

      +The accounts table when data is initialized specifying 3 scale factor, +The value of the aid is 1 to 300000. +The function is defined so that data is evenly distributed to three data base nodes. +

      +

      +SQL function will be defined as the return of the number of the data base node. +

      + +

      +
      CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_branches(anyelement)
      +RETURNS integer AS $$
      +    SELECT CASE WHEN $1 > 0 AND $1 <= 1 THEN 0
      +        WHEN $1 > 1 AND $1 <= 2 THEN 1
      +        ELSE 2
      +    END;
      +$$ LANGUAGE sql;
      +
      + +

      3.4. Defining Replication Rules

      +

      +The replication rule is the one that which table decides the replication whether to be done. +

      + +

      +Here, it is made with pgbench With the branches table and tellers table are registered. + +As a result, the accounts table and the inquiry that uses the branches table +and the tellers table become possible. +

      +
      +INSERT INTO pgpool_catalog.replicate_def VALUES (
      +    'bench_parallel',
      +    'public',
      +    'branches',
      +    ARRAY['bid', 'bbalance', 'filler'],
      +    ARRAY['integer', 'integer', 'character(88)']
      +);
      +
      +INSERT INTO pgpool_catalog.replicate_def VALUES (
      +    'bench_parallel',
      +    'public',
      +    'tellers',
      +    ARRAY['tid', 'bid', 'tbalance', 'filler'],
      +    ARRAY['integer', 'integer', 'integer', 'character(84)']
      +);
      +
      +

      +Replicate_def_pgbench.sql is prepared in sample directory. + +In the directory that progresses the source code to define a replicate rule by using this as follows The psql command is executed. +

      +
      +$ psql -f sample/replicate_def_pgbench.sql -p 5432 pgpool
      +
      + +

      3.5. Checking Parallel Query

      + +

      To reflect the changes in pgpool.conf, pgpool-II must +be restarted. Please refer to section "1.5 Starting/Stopping pgpool-II".

      + +

      After configuring pgpool.conf and restarting +pgpool-II, let's try and see if parallel query is working OK.

      + +

      First, we need to create a database to be distributed. We will name +it "bench_parallel". This database needs to be created on all the +nodes. Use createdb commands through pgpool-II, and the +database will be created on all the nodes.

      + +
      $ createdb -p 9999 bench_parallel
      + +

      Then, we'll execute pgbench with -i -s 3 +options. -i option initializes the database with +pre-defined tables and data. -s option specifies the +scale factor for initialization.

      + +
      $ pgbench -i -s 3 -p 9999 bench_parallel
      + +

      The tables and data created are shown in "3.3. Defining Distribution Rules".

      + +

      One way to check if the data have been distributed correctly is to +execute a SELECT query via pgpool-II and directly on the backend, and +compare two results. If everything is configured right, +"bench_parallel" should be distributed as follows.

      + + + + + + + + + + + + + + + + + + + + + + +
      Table Namethe number of lines
      branches3
      tellers30
      accounts300000
      history0
      + +

      Let's use a simple shell script to check the above on all the nodes +and via pgpool-II. The following script will display the minimum and +maximum values in accounts table using port 5432, 5433, 5434, and +9999.

      + +
      $ for port in 5432 5433 5434 9999; do
      +>     echo $port
      +>     psql -c "SELECT min(aid), max(aid) FROM accounts" -p $port bench_parallel
      +> done
      +
      + + + + diff --git a/doc/tutorial-ja.html b/doc/tutorial-ja.html new file mode 100644 index 0000000..723a405 --- /dev/null +++ b/doc/tutorial-ja.html @@ -0,0 +1,422 @@ + + + +pgpool-II $B%A%e!<%H%j%"%k(B + + + + +

      pgpool-II $B%A%e!<%H%j%"%k(B

      +

      pgpool-II $B$N%A%e!<%H%j%"%k$K$h$&$3$=!#(B +$B$3$3$G$O!"(Bpgpool-II $B$N%$%s%9%H!<%k$+$i4pK\E*$J@_Dj!"%l%W%j%1!<%7%g%s$*$h$S%Q%i%l%k%/%(%j$NH$7$F$/$@$5$$!#(B

      +
      +
      $BL\
      +
      1. $B$5$";O$a$^$7$g$&(B
      +
      1.1. pgpool-II $B$N%$%s%9%H!<%k(B
      +
      1.2. $B@_Dj%U%!%$%k$N:n@.(B
      +
      1.3. PCP $B%3%^%s%I$N@_Dj(B
      +
      1.4. $B%G!<%?%Y!<%9%N!<%I$N=`Hw(B
      +
      1.5. pgpool-II $B$N5/F0$HDd;_(B
      +
      2. $B=i$a$F$N%l%W%j%1!<%7%g%s(B
      +
      2.1. $B%l%W%j%1!<%7%g%s$N@_Dj(B
      +
      2.2. $B%l%W%j%1!<%7%g%s$N3NG'(B
      +
      3. $B%Q%i%l%k%/%(%j$r;H$C$F$_$h$&(B
      +
      3.1. $B%Q%i%l%k%/%(%j$N@_Dj(B
      +
      3.2. $B%7%9%F%`%G!<%?%Y!<%9$N:n@.(B
      +
      3.3. $BJ,;6%k!<%k$NDj5A(B
      +
      3.4. $BJ#@=%k!<%k$N3NG'(B
      +
      3.5. $B%Q%i%l%k%/%(%j$N3NG'(B
      +
      +

      1. $B$5$";O$a$^$7$g$&(B

      +

      $B$3$3$G$O!"%l%W%j%1!<%7%g%s$*$h$S%Q%i%l%k%/%(%j$N +

      1.1. pgpool-II $B$N%$%s%9%H!<%k(B

      +

      pgpool-II $B$r%$%s%9%H!<%k$9$k$K$O%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K%3%^%s%I$r +

      $ ./configure
      +$ make
      +$ make install
      +

      configure $B%9%/%j%W%H$G$O(B pgpool-II $B$r%$%s%9%H!<%k$9$k4D6-$K9g$o$;$?@_Dj$,9T$o$l$^$9!#(B +$B$^$?!"(Bconfigure $B%9%/%j%W%H$r/usr/local $B%G%#%l%/%H%j0J2<$K%$%s%9%H!<%k$5$l$^$9!#(B

      +

      make $B%3%^%s%I$rmake install $B%3%^%s%I$G$Omake install $B%3%^%s%I$r +

      $B$3$3$G$O!"(Bpgpool-II $B$r(B /usr/local $B%G%#%l%/%H%j0J2<$K%$%s%9%H!<%k$7$^$9!#(B

      +

      $BCm0U(B: pgpool-II $B$N%=!<%9%3!<%I$r%3%s%Q%$%k$9$k$K$O(B PostgreSQL 7.4 $B0J9_$Gconfigure $B%9%/%j%W%H$rl9g!"(Blibpq $B%i%$%V%i%j$,%$%s%9%H!<%k$5$l$F$$$J$$$+!"%$%s%9%H!<%k$5$l$F$$$F$b%W%m%H%3%k$N%P!<%8%g%s$,(B 3.0 $B$G$J$$2DG=@-$,$"$j$^$9!#(B

      +
      configure: error: libpq is not installed or libpq is old
      +

      $B$^$?!"%W%m%H%3%k$N%P!<%8%g%s$,(B 3.0 $B$N(B libpq $B%i%$%V%i%j$,%$%s%9%H!<%k$5$l$F$$$k$K$b78$o$i$:!">e5-$N%(%i!<%a%C%;!<%8$,I=<($5$l$k>l9g!"(Bconfigure $B%9%/%j%W%H$r +

      configure $B%9%/%j%W%H$OI8=`$G$O(B /usr/local/pgsql $B%G%#%l%/%H%j0J2<$+$i%X%C%@%U%!%$%k$d(B libpq $B%i%$%V%i%j$r8!:w$7$^$9!#(B +PostgreSQL $B$N%$%s%9%H!<%k@h$,(B /usr/local/pgsql $B%G%#%l%/%H%j0J2<$G$J$1$l$P!"(Bconfigure $B%9%/%j%W%H$r--with-pgsql $B$d(B --with-pgsql-includedir$B!"(B--with-pgsql-libdir $B%*%W%7%g%s$r;XDj$7$F$/$@$5$$!#(B

      +

      1.2. $B@_Dj%U%!%$%k$N:n@.(B

      +

      pgpool-II $B$K$D$$$F$N@_Dj$O(B pgpool.conf $B%U%!%$%k$K5-=R$7$^$9!#(B +pgpool.conf $B%U%!%$%k$N=q<0$O(B 1 $B9T$4$H$K%Q%i%a!<%?L>$HCM$r(B = $B$G6h@Z$C$?$b$N$G$9!#(B +pgpool-II $B$r%$%s%9%H!<%k$9$k$H%5%s%W%k$H$7$F(B pgpool.conf.sample $B%U%!%$%k$,:n@.$5$l$k$N$G!"$=$l$r(B pgpool.conf $B$H$$$&%U%!%$%kL>$K%3%T!<$7$F$+$iJT=8$9$k$H$$$$$G$7$g$&!#(B

      +
      $ cp /usr/local/etc/pgpool.conf.sample /usr/local/etc/pgpool.conf
      +

      pgpool.conf $B%U%!%$%k$N=i4|@_Dj$G$O!"(Bpgpool-II $B$O(B pgpool-II $B$HF1$8%[%9%H$+$i$N%]!<%HHV9f(B 9999 $B$X$N@\B3$rl9g$O(B listen_addresses $B%Q%i%a!<%?$K(B * $B$r@_Dj$7$^$9!#(B

      +
      listen_addresses = 'localhost'
      +port = 9999
      +

      $B$3$3$G$O!"(Bpgpool.conf $B%U%!%$%k$N=i4|@_Dj$r$=$N$^$^;HMQ$7$^$9!#(B

      +

      1.3. PCP $B%3%^%s%I$N@_Dj(B

      +

      pgpool-II $B$G$O(B PCP $B%3%^%s%I$H8F$P$l$k%$%s%?%U%'!<%9$rDL$7$F(B pgpool-II $B$NDd;_$d%G!<%?%Y!<%9%N!<%I$K4X$9$k>pJs$NI=<($r9T$$$^$9!#(B +PCP $B%3%^%s%I$r;HMQ$9$k$K$O%f!<%6G'>Z$,I,MW$K$J$k$N$G!"%f!<%6L>$H%Q%9%o!<%I$r(B pcp.conf $B%U%!%$%k$K@_Dj$7$^$9!#(B +pcp.conf $B%U%!%$%k$N=q<0$O0J2<$N$h$&$K(B 1 $B9T$4$H$K%f!<%6L>$H(B MD5 $B%O%C%7%e$KJQ49$5$l$?%Q%9%o!<%I$r(B : $B$G6h@Z$C$?$b$N$G$9!#(B

      +
      postgres:e8a48653851e28c69d0506508fb27fc5
      +

      pgpool-II $B$r%$%s%9%H!<%k$9$k$H%5%s%W%k$H$7$F(B pcp.conf.sample $B%U%!%$%k$,:n@.$5$l$k$N$G!"$=$l$r(B pcp.conf $B$H$$$&%U%!%$%kL>$K%3%T!<$7$F$+$iJT=8$9$k$H$$$$$G$7$g$&!#(B

      +
      $ cp /usr/local/etc/pcp.conf.sample /usr/local/etc/pcp.conf
      +

      $B$J$*!"%Q%9%o!<%I$r(B MD5 $B%O%C%7%e$KJQ49$9$k:]$K$O(B pgpool-II $B$H$H$b$K%$%s%9%H!<%k$5$l$k(B pg_md5 $B%3%^%s%I$r;HMQ$7$^$9!#(B +pg_md5 $B%3%^%s%I$O!"%3%^%s%I%i%$%s0z?t$H$7$F%Q%9%o!<%I$r;XDj$9$k$H!"$=$l$r(B MD5 $B%O%C%7%e$KJQ49$7$?$b$N$rI=<($7$^$9!#(B

      +

      $BNc$($P!"0J2<$N$h$&$K(B pg_md5 $B%3%^%s%I$N%3%^%s%I%i%$%s0z?t$H$7$F(B postgres $B$r;XDj$7$F +

      $ /usr/bin/pg_md5 postgres
      +e8a48653851e28c69d0506508fb27fc5
      +

      $B$^$?!"(BPCP $B%3%^%s%I$O%M%C%H%o!<%/$rDL$7$Fpgpool.conf $B%U%!%$%k$N(B pcp_port $B%Q%i%a!<%?$K@_Dj$7$^$9!#(B

      +

      $B$3$3$G$O!"(Bpcp_port $B%Q%i%a!<%?$K:G=i$+$i@_Dj$5$l$F$$$k%]!<%HHV9f(B 9898 $B$r$=$N$^$^;HMQ$7$^$9!#(B

      +
      pcp_port = 9898
      +

      1.4. $B%G!<%?%Y!<%9%N!<%I$N=`Hw(B

      +

      $B%G!<%?%Y!<%9%N!<%I$H$7$F;HMQ$9$k%G!<%?%Y!<%9%5!<%P$r=`Hw$7$^$9!#(B +$B%G!<%?%Y!<%9%5!<%P$O!"(Bpgpool-II $B$HF1$8%[%9%H$G5/F0$7$F$b!"0[$J$k%[%9%H$G$"$C$F$b9=$$$^$;$s!#(B +$B$b$A$m$s!"(Bpgpool-II $B$HF1$8%[%9%H$G5/F0$9$k>l9g$O0[$J$k%]!<%HHV9f$r3d$j9g$F!"0[$J$k%[%9%H$G5/F0$9$k>l9g$O(B pgpool-II $B$,5/F0$9$k%[%9%H$+$i%G!<%?%Y!<%9%5!<%P$K@\B3$G$-$k$h$&$K@_Dj$9$kI,MW$,$"$j$^$9!#(B +pgpool-II $B$G$O%G!<%?%Y!<%9%5!<%P$4$H$K%l%W%j%1!<%7%g%s$r9T$&$N$G!"%A%e!<%H%j%"%k$N$?$a$N%G!<%?%Y!<%9%/%i%9%?$r:n@.$7$?$[$&$,$$$$$G$7$g$&!#(B

      +

      $B$3$3$G$O!"(B3 $BBf$N%G!<%?%Y!<%9%5!<%P$r(B pgpool-II $B$HF1$8%[%9%H$N0[$J$k%]!<%HHV9f(B 5432$B!"(B5433$B!"(B5434 $B$G5/F0$7$^$9!#(B +$B%G!<%?%Y!<%9%5!<%P$r%G!<%?%Y!<%9%N!<%I$H$7$F;HMQ$9$k$K$O!"(Bpgpool.conf $B%U%!%$%k$K0J2<$N$h$&$K%Q%i%a!<%?$r@_Dj$7$^$9!#(B

      +
      backend_hostname0 = 'localhost'
      +backend_port0 = 5432
      +backend_weight0 = 1
      +backend_hostname1 = 'localhost'
      +backend_port1 = 5433
      +backend_weight1 = 1
      +backend_hostname2 = 'localhost'
      +backend_port2 = 5434
      +backend_weight2 = 1
      +

      backend_hostname$B!"(Bbackend_port$B!"(Bbackend_weight $B%Q%i%a!<%?$K$O!"%G!<%?%Y!<%9%N!<%I$N%[%9%HL>!"%]!<%HHV9f!"Ii2YJ,;6$9$k:]$N=E$_IU$1$r@_Dj$7$^$9!#(B +$B%Q%i%a!<%?L>$N8e$m$K$O(B 0$B!"(B1$B!"(B2$B!"(B… $B$H$$$&$h$&$KJ#?t$N%G!<%?%Y!<%9%N!<%I$r6hJL$9$k$?$a$N?t;z$r;XDj$7$^$9!#(B +backend_weight $B%Q%i%a!<%?$O!"J#?t$N%G!<%?%Y!<%9%N!<%I$KLd$$9g$o$;$rIi2YJ,;6$9$k:]!"$I$N%G!<%?%Y!<%9%N!<%I$K$I$N$/$i$$$N3d9g$GLd$$9g$o$;$r9T$&$+$H$$$&$3$H$r@_Dj$9$k%Q%i%a!<%?$G$9!#(B +$B$3$3$G$O!"(B3 $BBf$N%G!<%?%Y!<%9%N!<%I$N=E$_IU$1$,$9$Y$F(B 1 $B$K@_Dj$7$F$"$k$N$G!"Ld$$9g$o$;$O(B 1 $BBP(B 1 $BBP(B 1 $B$N3d$j9g$$$GIi2YJ,;6$5$l$k$3$H$K$J$j$^$9!#(B

      +

      1.5. pgpool-II $B$N5/F0$HDd;_(B

      +

      pgpool-II $B$r5/F0$9$k$K$O0J2<$N$h$&$K(B pgpool $B%3%^%s%I$r +

      $ pgpool
      +

      +$B$?$@$7!"$3$N$^$^$G$O(B pgpool $B%W%m%;%9$O@)8fCl9g$O(B -n $B%*%W%7%g%s$r;XDj$7$^$9!#(B +

      + +
      +$ pgpool -n &
      +
      + +

      +$B%3%^%s%I$r +

      $ pgpool -n -d > /var/log/pgpool/pgpool.log 2>&1 &
      +

      -d $B%*%W%7%g%s$O%G%P%C%0%a%C%;!<%8$N=PNO$rM-8z$K$7$^$9!#(B

      +

      +$B>e5-$NNc$O%U%!%$%k$K%j%@%$%l%/%H$5$;$F$$$k$?$a!"%m%0$,DI2C$5$lB3$1$^$9!#(B +$B%m%0$r%m!<%F!<%H$5$;$?$$>l9g$O!"%m!<%F!<%H5!G=$r;}$C$?%3%^%s%I$K%m%0$r(B +$BEO$7$F$/$@$5$$!#(B + +$B$?$H$($P!"(BApache2$B$KIUB0$9$k(Brotatelogs$B$r;H$&$N$G$"$l$P!"(B + +

      +$ pgpool -n 2>&1 | /usr/local/apache2/bin/rotatelogs \
      +  -l -f /var/log/pgpool/pgpool.log.%A 86400 &
      +
      + +$B$H$9$l$PKhF|LkCf$N(B0$B;~$K%m%0$,%m!<%F!<%H$5$l!"(Bpgpool.log.Thursday $B$N$h$&$JL>A0$N%m%0%U%!%$%k$,KhF|:n@.$5$l$^$9!#(B +$B$?$@$7!"$9$G$KF1$8L>A0$N%U%!%$%k$,$"$k>l9g$K$O%m%0$,$=$N%U%!%$%k$KDI2C$5$l$F$7$^$&$N$G!"(Bcron$B$r;H$C$F8E$$%m%0%U%!%$%k$r>C5n$9$k@_Dj$rJ;$;$F9T$C$F$*$/J}$,NI$$$G$7$g$&!#(B +$BNc$r<($7$^$9!#(B +
      +55 23 * * * /usr/bin/find /var/log/pgpool -type f -mtime +5 -exec /bin/rm -f '{}' \;
      +
      +

      +

      +$BCm0U(B: Linux$B%G%#%9%H%j%S%e!<%7%g%s$K$h$C$F$O!"(Brotatelogs $B$O(B /usr/sbin/rotatelogs2 $B$N$h$&$JL>A0$G%$%s%9%H!<%k$5$l$F$$$k$+$bCN$l$^$;$s!#(B +-f $B%*%W%7%g%s$O(B rotatelogs $B$,5/F0$5$l$?D>8e$KD>$A$K%m%0%U%!%$%k$r:n$k%*%W%7%g%s$G!"(Bapache2 2.2.9 $B0J9_$G$N$_M-8z$G$9!#(B +

      + +

      +cronolog $B$r;H$&>l9g$G$"$l$P!"0J2<$N$h$&$K%Q%$%W$G%m%0%a%C%;!<%8$rEO$7$F$/$@$5$$!#(B + +

      +$ pgpool -n 2>&1 | /usr/sbin/cronolog \
      +  --hardlink=/var/log/pgpool/pgpool.log \
      +  '/var/log/pgpool/%Y-%m-%d-pgpool.log' &
      +
      +

      + +

      pgpool-II $B$rDd;_$9$k$K$O0J2<$N$h$&$K(B pgpool $B%3%^%s%I$r +

      $ pgpool stop
      +

      pgpool-II $B$rDd;_$9$k:]$K%/%i%$%"%s%H$,@\B3$7$F$$$k>l9g!"$=$N@\B3$,@ZCG$5$l$k$^$GBT$C$F$+$iDd;_$7$^$9!#(B +$B%/%i%$%"%s%H$N@\B3$,@ZCG$5$l$k$^$GBT$?$:$KDd;_$9$k$K$O0J2<$N$h$&$K(B pgpool $B%3%^%s%I$r +

      $ pgpool -m fast stop
      +

      2. $B=i$a$F$N%l%W%j%1!<%7%g%s(B

      +

      $B%l%W%j%1!<%7%g%s$G$OJ#?t$N%G!<%?%Y!<%9%N!<%I$KF1$8%G!<%?$rJ#@=$7$F3JG<$7$^$9!#(B

      +

      $B$3$3$G$O!"!V(B1. $B$5$";O$a$^$7$g$&(B$B!W$G=`Hw$7$?(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$r;HMQ$7!"(Bpgbench $B$,:n@.$9$k%G!<%?%Y!<%9$N%l%W%j%1!<%7%g%s$r9T$&$^$G$N +

      2.1. $B%l%W%j%1!<%7%g%s$N@_Dj(B

      +

      $B%G!<%?%Y!<%9%N!<%I$N%l%W%j%1!<%7%g%s$rM-8z$K$9$k$K$O!"(Bpgpool.conf $B%U%!%$%k$N(B replication_mode $B%Q%i%a!<%?$r(B true $B$K@_Dj$7$^$9!#(B

      +
      replication_mode = true
      +

      $B>e5-$N$h$&$K(B replication_mode $B%Q%i%a!<%?$r(B true $B$K@_Dj$9$k$3$H$K$h$j!"(Bpgpool-II $B$X$NLd$$9g$o$;$,$9$Y$F$N%G!<%?%Y!<%9%N!<%I$KBP$7$F$B$5$i$K!"(Bload_balance_mode $B%Q%i%a!<%?$r(B true $B$K@_Dj$9$k$3$H$K$h$j!"(Bpgpool-II $B$KBP$9$k(B SELECT $BJ8$rJ#?t$N%G!<%?%Y!<%9%N!<%I$KBP$7$F?6$jJ,$1!"Ii2YJ,;6$r9T$&$3$H$,$G$-$^$9!#(B

      +
      load_balance_mode = true
      +

      $B$3$3$G$O!"(Breplication_mode$B!"(Bload_balance_mode $B%Q%i%a!<%?$r(B true $B$K@_Dj$7$^$9!#(B

      +

      2.2. $B%l%W%j%1!<%7%g%s$N3NG'(B

      +

      $B%l%W%j%1!<%7%g%s$N@_Dj$r(B pgpool-II $B$KH?1G$5$;$k$K$O(B pgpool-II $B$r:F5/F0$9$kI,MW$,$"$j$^$9!#(B +pgpool-II $B$N:F5/F0$K$D$$$F$O!V(B1.5. pgpool-II $B$N5/F0$HDd;_(B$B!W$r;2>H$7$F$/$@$5$$!#(B

      +

      $B%l%W%j%1!<%7%g%s$rM-8z$K$7$F(B pgpool-II $B$r5/F0$G$-$?$i!" +

      $B$^$:!"(Bpgbench $B$,;HMQ$9$k%G!<%?%Y!<%9(B bench_replication $B$r:n@.$7$^$9!#(B +createdb $B%3%^%s%I$r(B pgpool-II $B$KBP$7$F +

      $ createdb -p 9999 bench_replication
      +

      $B$=$7$F!"(Bpgbench $B%3%^%s%I$K(B -i $B%*%W%7%g%s$r;XDj$7$F +

      $ pgbench -i -p 9999 bench_replication
      +

      pgbench $B%3%^%s%I$K(B -i $B%*%W%7%g%s$r;XDj$7$F$l$N%F!<%V%k$N9T?t$O0J2<$N$H$*$j$G$9!#(B +$B$9$Y$F$N%G!<%?%Y!<%9%N!<%I$N%G!<%?%Y!<%9(B bench_replication $B$K0J2<$N9T?t$N%G!<%?$,3JG<$5$l$F$$$l$P!"@5>o$K%l%W%j%1!<%7%g%s$,9T$o$l$F$$$k$3$H$K$J$j$^$9!#(B

      + +
      + + + + + + + + + + + + + + + + + + + + + +
      $B%F!<%V%kL>(B$B9T?t(B
      branches1
      tellers10
      accounts100000
      history0
      +
      +

      $BNc$($P!"0J2<$N$h$&$K%3%^%s%I$r +

      $ for port in 5432 5433 5434; do
      +>     echo $port
      +>     for table_name in branches tellers accounts history; do
      +>         echo $table_name
      +>         psql -c "SELECT count(*) FROM $table_name" -p $port bench_replication
      +>     done
      +> done
      +
      +

      3. $B%Q%i%l%k%/%(%j$r;H$C$F$_$h$&(B

      +

      $B%Q%i%l%k%/%(%j$G$OJ#?t$N%G!<%?%Y!<%9%N!<%I$K0[$J$kHO0O$N%G!<%?$r3JG<$7$^$9!#$3$l$r%Q!<%F%#%7%g%K%s%0$H8F$S$^$9!#$^$?%Q!<%F%#%7%g%s%K%s%0$H6&$KJ#?t$N%G!<%?%Y!<%9%N!<%I$KF1$8%G!<%?$rJ#@=$9$k$3$H$b$G$-$^$9!#$D$^$j%Q!<%F%#%7%g%K%s%0$7$F$$$k%F!<%V%k$H%l%W%j%1!<%7%g%s$7$F$$$k%F!<%V%k$r6&B8$5$;$k$3$H$,$G$-$^$9!#(B

      +

      $B%Q%i%l%k%/%(%j$r;HMQ$9$k$K$O%7%9%F%`%G!<%?%Y!<%9$H8F$P$l$kFCJL$J%G!<%?%Y!<%9$,I,MW$G$9!#(B

      +

      $B%7%9%F%`%G!<%?%Y!<%9$G$O!"$I$N%G!<%?%Y!<%9%N!<%I$KBP$7$F$I$N%G!<%?$r3JG<$9$k$+$H$$$&J,;6%k!<%k$r3JG<$7$F$*$j!"$=$l$K$h$C$F%G!<%?$rJ#?t$N%G!<%?%Y!<%9%N!<%I$KJ,;6$5$;$^$9!#(B +$B$^$?!"%7%9%F%`%G!<%?%Y!<%9$O!"(Bdblink $B$r;HMQ$9$k$3$H$K$h$C$FJ#?t$N%G!<%?%Y!<%9%N!<%I$KLd$$9g$o$;$r?6$jJ,$1!"$=$l$>$l$N%G!<%?%Y!<%9%N!<%I$G +

      $B$3$3$G$O!"!V(B1. $B$5$";O$a$^$7$g$&(B$B!W$G=`Hw$7$?(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$r;HMQ$7!"(Bpgbench $B$,:n@.$9$k%G!<%?%Y!<%9$KBP$7$F%Q%i%l%k%/%(%j$r +

      3.1. $B%Q%i%l%k%/%(%j$N@_Dj(B

      +

      $B%Q%i%l%k%/%(%j$rM-8z$K$9$k$K$O(B pgpool.conf $B%U%!%$%k$N(B parallel_mode $B%Q%i%a!<%?$r(B true $B$K@_Dj$7$^$9!#(B

      +
      parallel_mode = true
      +

      $B$?$@$7!">e5-$N$h$&$K(B parallel_mode $B%Q%i%a!<%?$r(B true $B$K@_Dj$7$?$@$1$G$O!"J#?t$N%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?$rJ,;6$G$-$^$;$s!#(B +$B$5$i$K!"%7%9%F%`%G!<%?%Y!<%9$r:n@.$7!"J,;6%k!<%k$NDj5A$HEPO?$r9T$&I,MW$,$"$j$^$9!#(B

      +

      $B$^$?!"(Bdblink $B$G$O%7%9%F%`%G!<%?%Y!<%9$+$i(B pgpool-II $B$X$N(B TCP/IP $B@\B3$,9T$o$l$k$?$a!"(Blisten_addresses $B%Q%i%a!<%?$rE,@Z$K@_Dj$9$kI,MW$,$"$j$^$9!#(B

      +
      listen_addresses = '*'
      +

      $BCm0U(B: $B%Q%i%l%k%/%(%j$H%l%W%j%1!<%7%g%s$rF1;~$KM-8z$K$9$k$3$H$,$G$-$^$9$,!"%Q!<%F%#%7%g%K%s%0$7$F$$$k%F!<%V%k$KBP$7$F$O!"%l%W%j%1!<%7%g%s$5$l$^$;$s!#(B +$B$^$?!"%Q%i%l%k%/%(%j$H%l%W%j%1!<%7%g%s$G$O%G!<%?%Y!<%9$K3JG<$5$l$k%G!<%?$N9=@.$,0[$J$k$?$a!"!V(B2. $B=i$a$F$N%l%W%j%1!<%7%g%s(B$B!W$G:n@.$7$?%G!<%?%Y!<%9(B bench_replication $B$r$=$N$^$^;HMQ$9$k$3$H$O$G$-$^$;$s!#(B

      +
      replication_mode = true
      +load_balance_mode = false
      +

      $B$^$?$O!"(B

      +
      replication_mode = false
      +load_balance_mode = true
      +

      $B$3$3$G$O!"(Bparallel_mode $B%Q%i%a!<%?$r(B true $B$K!"(Blisten_addresses $B%Q%i%a!<%?$r(B * $B$K!"(Breplication_mode$B!"(Bload_balance_mode $B%Q%i%a!<%?$r(B false $B$K@_Dj$7$^$9!#(B

      +

      3.2. $B%7%9%F%`%G!<%?%Y!<%9$N:n@.(B

      +

      $B%7%9%F%`%G!<%?%Y!<%9$HDL>o$N%G!<%?%Y!<%9$K0c$$$O$"$j$^$;$s!#(B +$B$?$@$7!"%7%9%F%`%G!<%?%Y!<%9$K$O!"(Bdblink $B$N4X?t$,Dj5A$5$l$F$*$j!"J,;6%k!<%k$r3JG<$9$k%F!<%V%k(B dist_def $B$,Dj5A$5$l$F$$$kI,MW$,$"$j$^$9!#(B +$B$^$?!"%G!<%?%Y!<%9%N!<%I$N(B 1 $BBf$K%7%9%F%`%G!<%?%Y!<%9$r:n@.$9$k$3$H$b$G$-$^$9$7!"(Bpgpool-II$B$r%+%9%1!<%I@\B3$9$k$3$H$GIi2YJ,;6$9$k$3$H$b$G$-$^$9!#(B

      +

      $B$3$3$G$O!"0J2<$N(B pgpool.conf $B%U%!%$%k$N=i4|@_Dj$K=>$C$F%7%9%F%`%G!<%?%Y!<%9$r:n@.$7$^$9!#(B

      +
      system_db_hostname = 'localhost'
      +system_db_port = 5432
      +system_db_dbname = 'pgpool'
      +system_db_schema = 'pgpool_catalog'
      +system_db_user = 'pgpool'
      +system_db_password = ''
      +

      pgpool.conf $B%U%!%$%k$N=i4|@_Dj$G$O!"%7%9%F%`%G!<%?%Y!<%9$O(B pgpool-II $B$HF1$8%[%9%H$N%]!<%HHV9f(B 5432 $B$G5/F0$9$k%G!<%?%Y!<%9%5!<%P!"$D$^$j!"(B1 $BBfL\$N%G!<%?%Y!<%9%N!<%I$K:n@.$9$k$3$H$K$J$j$^$9!#(B +$B$^$?!"%7%9%F%`%G!<%?%Y!<%9$N%G!<%?%Y!<%9L>$O(B pgpool $B$K!"%7%9%F%`%G!<%?%Y!<%9$K@\B3$9$k%f!<%6L>$b(B pgpool $B$K@_Dj$5$l$F$$$k$N$G!"(Bpgpool $B$H$$$&%f!<%6$r:n@.$7$F$+$i%f!<%6(B pgpool $B$r=jM- +

      $ createuser -p 5432 pgpool
      +$ createdb -p 5432 -O pgpool pgpool
      +

      3.2.1. dblink $B$N%$%s%9%H!<%k(B

      +

      $B%7%9%F%`%G!<%?%Y!<%9$H$7$F%G!<%?%Y!<%9(B pgpool $B$,:n@.$G$-$?$i!"(Bdblink $B$r%$%s%9%H!<%k$7$^$9!#(B +dblink $B$O(B PostgreSQL $B$N%=!<%9%3!<%I$N(B contrib $B%G%#%l%/%H%j$K4^$^$l$k%D!<%k$N(B 1 $B$D$G$9!#(B

      +

      dblink $B$r%$%s%9%H!<%k$9$k$K$O(B PostgreSQL $B$N%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K%3%^%s%I$r +

      $ USE_PGXS=1 make -C contrib/dblink
      +$ USE_PGXS=1 make -C contrib/dblink install
      +

      $B%G!<%?%Y!<%9(B pgpool $B$KBP$7$F(B dblink $B$N4X?t$rDj5A$7$^$9!#(B +PostgreSQL $B$N%$%s%9%H!<%k@h$,(B /usr/local/pgsql $B%G%#%l%/%H%j0J2<$G$"$l$P!"(B/usr/local/pgsql/share/contrib $B%G%#%l%/%H%j$K(B dblink $B$N4X?t$rDj5A$9$k$?$a$N(B dblink.sql $B%U%!%$%k$,B8:_$7$^$9!#(B +$B$=$l$r;HMQ$7$F0J2<$N$h$&$K(B psql $B%3%^%s%I$r +

      $ psql -f /usr/local/pgsql/share/contrib/dblink.sql -p 5432 pgpool
      +

      3.2.2. $B%F!<%V%k(B dist_def $B$NDj5A(B

      +

      $BJ,;6%k!<%k$r3JG<$9$k%F!<%V%k(B dist_def $B$r%7%9%F%`%G!<%?%Y!<%9(B pgpool $B$KDj5A$7$^$9!#(B +pgpool-II $B$r%$%s%9%H!<%k$9$k$H%F!<%V%k(B dist_def $B$r4^$a$F%7%9%F%`%G!<%?%Y!<%9$r:n@.$9$k$?$a$N(B system_db.sql $B%U%!%$%k$,:n@.$5$l$k$N$G!"$=$l$r;HMQ$7$F0J2<$N$h$&$K(B psql $B%3%^%s%I$r +

      $ psql -f /usr/local/share/system_db.sql -p 5432 -U pgpool pgpool
      +

      system_db.sql $B%U%!%$%k$G$O!"%9%-!<%^(B pgpool_catalog $B$K%F!<%V%k(B dist_def $B$J$I$rDj5A$7$F$$$^$9!#(B +$B=>$C$F!"(Bpgpool.conf $B%U%!%$%k$N(B system_db_schema $B%Q%i%a!<%?$G(B pgpool_catalog $B$G$J$$%9%-!<%^L>$r;XDj$7$F$$$k>l9g!"(Bsystem_db.sql $B%U%!%$%k$rJT=8$7$F%9%-!<%^L>$rJQ99$9$kI,MW$,$"$j$^$9!#(B

      +

      $B%F!<%V%k(B dist_def $B$O0J2<$N$h$&$KDj5A$5$l$F$*$j!"%F!<%V%kL>$rJQ99$9$k$3$H$O$G$-$^$;$s!#(B

      +
      CREATE TABLE pgpool_catalog.dist_def (
      +    dbname text, -- $B%G!<%?%Y!<%9L>(B
      +    schema_name text, -- $B%9%-!<%^L>(B
      +    table_name text, -- $B%F!<%V%kL>(B
      +    col_name text NOT NULL CHECK (col_name = ANY (col_list)), -- $BJ,;6%-!(B
      +    col_list text[] NOT NULL, -- $B%F!<%V%k$NNsL>(B
      +    type_list text[] NOT NULL, -- $B%F!<%V%k$N%G!<%?7?L>(B
      +    dist_def_func text NOT NULL, -- $BJ,;6%k!<%k4X?t(B
      +    PRIMARY KEY (dbname, schema_name, table_name)
      +);
      +

      $B%F!<%V%k(B dist_def $B$K3JG<$5$l$k%G!<%?$OBg$-$/J,$1$F0J2<$N(B 2 $B$D$G$9!#(B

      +
        +
      • $BJ,;6%k!<%k(B (col_name$B!"(Bdist_def_func)
      • +
      • $B%F!<%V%k$N%a%?>pJs(B (dbname$B!"(Bschema_name$B!"(Btable_name$B!"(Bcol_list$B!"(Btype_list)
      • +
      +

      $B$^$:!"J,;6%k!<%k$O$I$N%G!<%?$r$I$N%G!<%?%Y!<%9%N!<%I$K3JG<$9$k$+$H$$$&$3$H$r7hDj$9$k$?$a$N%G!<%?$G$9!#(B +col_name $BNs$K$O%F!<%V%k$N$I$NNs$NCM$K$h$C$F3JG<$9$k%G!<%?%Y!<%9%N!<%I$r7hDj$9$k$+$H$$$&$3$H$r;XDj$7$^$9!#(B +dist_def_func $BNs$K$O!"(Bcol_name $BNs$K;XDj$5$l$?Ns$NCM$r0z?t$H$7$F +

      $B%F!<%V%k$N%a%?>pJs$OLd$$9g$o$;$N=q$-49$($r9T$&:]$K;HMQ$5$l$k%G!<%?$G$9!#(B +$B%Q%i%l%k%/%(%j$G$O!"Ld$$9g$o$;$rJ#?t$N%G!<%?%Y!<%9%N!<%I$K?6$jJ,$1!"$=$l$>$l$N%G!<%?%Y!<%9%N!<%I$G + + +

      3.2.3. $B%F!<%V%k(B replicate_def $B$NDj5A(B

      +

      +$B0l$D$N(BSQL$BJ8$K%F!<%V%k$N7k9gEy$G(Bdist_def$B$KEPO?$7$?%F!<%V%k$H6&$K%l%W%j%1!<%7%g%s$r9T$&%F!<%V%k$r;XDj$9$k>l9g$K$O!"(B +$B%l%W%j%1!<%7%g%s$r9T$&%F!<%V%k$N>pJs(B($BJ#@=%k!<%k(B)$B$r$"$i$+$8$a!"(Breplicate_def $B$H$$$&%F!<%V%k$KEPO?$7$F$*$-$^$9!#(B +$B%F!<%V%k(B dist_def $B$NDj5A$N:]$K!"(Bsystem_db.sql$B%U%!%$%k$+$i:n@.$7$?>l9g$K$O!"$9$G$K(Breplicate_def$B%F!<%V%k$,:n@.$5$l$F$$$^$9!#(B +replicate_def$B%F!<%V%k$O0J2<$N$h$&$KDj5A$5$l$F$$$^$9!#(B +

      +CREATE TABLE pgpool_catalog.replicate_def(
      +  dbname TEXT, -- $B%G!<%?%Y!<%9L>(B
      +  schema_name TEXT, -- $B%9%-!<%^L>(B
      +  table_name TEXT, -- $B%F!<%V%kL>(B
      +  col_list TEXT[] NOT NULL, -- $B%F!<%V%k$NNsL>(B
      +  type_list TEXT[] NOT NULL, -- $B%F!<%V%k$N%G!<%?7?L>(B
      +  PRIMARY KEY (dbname,schema_name,table_name)
      +);
      +
      +

      +

      +$B%F!<%V%k(B replicate_def $B$K3JG<$5$l$k%G!<%?$O%F!<%V%k$N%a%?>pJs(B(dbname$B!"(Bschema_name$B!"(Btable_name$B!"(Bcol_list$B!"(Btype_list)$B$H$J$j$^$9!#(B +

      + +

      +pgpool-ll $B$O!"%/%(%j$K;H$o$l$F$$$k!"$9$Y$F$N%F!<%V%k!"%+%i%`!"7?>pJs$r(Bdist_def$B$^$?$O!"(Breplicate_def$B%F!<%V%k$KEPO?$7$F$$$k>pJs(B +$B$rMQ$$$F!"%/%(%j$N2r@O$H%/%(%j$N=q$-49$($r9T$$$^$9!#$=$N$?$a(B replicate_def$B%F!<%V%k$K@5$7$$>pJs$rEPO?$7$F$*$+$J$$$H!"@5$7$$ + +

      3.3. $BJ,;6%k!<%k$NDj5A(B

      +

      $BJ,;6%k!<%k$O$I$N%G!<%?$r$I$N%G!<%?%Y!<%9%N!<%I$K3JG<$9$k$+$H$$$&$3$H$r7hDj$9$k$b$N$G$9!#(B

      +

      $B$3$3$G$O!"%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F%G!<%?$r=i4|2=$7$?(B pgbench $B$N%F!<%V%k$r(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$K?6$jJ,$1$k$?$a$NJ,;6%k!<%k$rDj5A$7$^$9!#(B +$B$J$*!"%G!<%?%Y!<%9$O!V(B2. $B=i$a$F$N%l%W%j%1!<%7%g%s(B$B!W$G;HMQ$7$?%G!<%?%Y!<%9(B bench_replication $B$H$OJL$K%G!<%?%Y!<%9(B bench_parallel $B$r:n@.$9$k$3$H$K$7$^$9!#(B

      +

      $B$J$*!"%=!<%9%3!<%I$N(B sample $B%G%#%l%/%H%j$K$O0J2<$N@bL@$G;HMQ$9$kJ,;6%k!<%k$,Dj5A$5$l$?%U%!%$%k(B dist_def_pgbench.sql $B$,=`Hw$5$l$F$$$^$9!#(B +$B$3$l$r;HMQ$7$FJ,;6%k!<%k$rDj5A$9$k$K$O%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K(B psql $B%3%^%s%I$r +

      $ psql -f sample/dist_def_pgbench.sql -p 5432 pgpool
      +

      $B$^$:!"J,;6%k!<%k$H%F!<%V%k$N%a%?>pJs$r%7%9%F%`%G!<%?%Y!<%9(B pgpool $B$N%F!<%V%k(B dist_def $B$K3JG<$7$^$9!#(B +$B$3$3$G$O(Baccounts$B%F!<%V%k$r3F%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?J,3d$r9T$$$^$9!#(B +$BJ,;6%-!$O!"(Baccounts $B$K$D$$$F$O%W%i%$%^%j%-!<@)Ls$,;XDj$5$l$?Ns(B aid $B$K;XDj$7$^$9!#(B

      +
      +INSERT INTO pgpool_catalog.dist_def VALUES (
      +    'bench_parallel',
      +    'public',
      +    'accounts',
      +    'aid',
      +    ARRAY['aid', 'bid', 'abalance', 'filler'],
      +    ARRAY['integer', 'integer', 'integer', 'character(84)'],
      +    'pgpool_catalog.dist_def_accounts'
      +);
      +
      +

      $B +

      $B%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F%G!<%?$r=i4|2=$7$?>l9g!"(Baccounts $B%F!<%V%k$N(B aid $BNs$NCM$O(B 1 $B$+$i(B 300000 $B$^$G$K$J$k$N$G!"$3$l$i$NCM$r$b$H$K(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$KBP$7$F%G!<%?$,6QEy$KJ,;6$5$l$k$h$&$K4X?t$rDj5A$7$^$9!#(B

      +

      $B$3$3$G$O!"0z?t$H$7$F +

      +CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_accounts(anyelement)
      +RETURNS integer AS $$
      +    SELECT CASE WHEN $1 > 0 AND $1 <= 100000 THEN 0
      +        WHEN $1 > 100000 AND $1 <= 200000 THEN 1
      +        ELSE 2
      +    END;
      +$$ LANGUAGE sql;
      +
      + +

      3.4 $BJ#@=%k!<%k$NDj5A(B

      +

      $BJ#@=%k!<%k$O$I$N%F!<%V%k$,%l%W%j%1!<%7%g%s$5$l$F$$$k$+$I$&$+$r7hDj$9$k$b$N$G$9!#(B

      +

      $B$3$3$G$O!"(Bpgbench$B$G:n@.$5$l$k!!(Bbranches $B%F!<%V%k$H(B tellers $B$rEPO?$7$F$*$-$^$9!#$3$l$K$h$j!"(Baccounts$B%F!<%V%k!"(Bbranches$B%F!<%V%k$H(Btellers$B%F!<%V%k$r(B +$B;H$C$?Ld$$9g$o$;$,2DG=$H$J$j$^$9!#(B +

      +INSERT INTO pgpool_catalog.replicate_def VALUES (
      +    'bench_parallel',
      +    'public',
      +    'branches',
      +    ARRAY['bid', 'bbalance', 'filler'],
      +    ARRAY['integer', 'integer', 'character(88)']
      +);
      +
      +INSERT INTO pgpool_catalog.replicate_def VALUES (
      +    'bench_parallel',
      +    'public',
      +    'tellers',
      +    ARRAY['tid', 'bid', 'tbalance', 'filler'],
      +    ARRAY['integer', 'integer', 'integer', 'character(84)']
      +);
      +
      +

      $B$J$*!"%=!<%9%3!<%I$N(B sample $B%G%#%l%/%H%j$K$O>e5-$N@bL@$G;HMQ$9$kJ#@=%k!<%k$,Dj5A$5$l$?%U%!%$%k(B replicate_def_pgbench.sql $B$,=`Hw$5$l$F$$$^$9!#(B +$B$3$l$r;HMQ$7$FJ,;6%k!<%k$rDj5A$9$k$K$O%=!<%9%3!<%I$rE83+$7$?%G%#%l%/%H%j$G0J2<$N$h$&$K(B psql $B%3%^%s%I$r +

      +$ psql -f sample/replicate_def_pgbench.sql -p 5432 pgpool
      +
      + + +

      3.5. $B%Q%i%l%k%/%(%j$N3NG'(B

      +

      $B%Q%i%l%k%/%(%j$N@_Dj$r(B pgpool-II $B$KH?1G$5$;$k$K$O(B pgpool-II $B$r:F5/F0$9$kI,MW$,$"$j$^$9!#$J$*!"%F!<%V%k(B dist_def$B!"(Breplicate_def $B$r99?7$7$?>l9g$b(B pgpool-II $B$N:F5/F0$,I,MW$G$9!#(B +pgpool-II $B$N:F5/F0$K$D$$$F$O!V(B1.5. pgpool-II $B$N5/F0$HDd;_(B$B!W$r;2>H$7$F$/$@$5$$!#(B

      +

      $B%Q%i%l%k%/%(%j$rM-8z$K$7$F(B pgpool-II $B$r5/F0$G$-$?$i!" +

      $B$^$:!"(Bpgbench $B$,;HMQ$9$k%G!<%?%Y!<%9(B bench_parallel $B$r:n@.$7$^$9!#(B +createdb $B%3%^%s%I$r(B pgpool-II $B$KBP$7$F +

      $ createdb -p 9999 bench_parallel
      +

      $B$=$7$F!"0J2<$N$h$&$K%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F(B pgbench $B$G;HMQ$9$k%F!<%V%k$r:n@.$7!"%G!<%?$r=i4|2=$7$^$9!#(B

      +
      $ pgbench -i -p 9999 -s 3 bench_parallel
      +

      $B%9%1!<%k%U%!%/%?!<(B 3 $B$r;XDj$7$F%G!<%?$r=i4|2=$7$?(B pgbench $B$N%F!<%V%k$H$=$l$>$l$N9T?t$O0J2<$N$H$*$j$G$9!#(B +$B%G!<%?$r=i4|2=$9$k$3$H$K$h$C$F3JG<$5$l$k%G!<%?$O!"%F!<%V%k(B dist_def $B$KEPO?$5$l$F$$$k%F!<%V%k$KBP$7$F$OJ,;6%k!<%k$K=>$C$F(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$KJ,;6$5$l$^$9!#(B

      +
      + + + + + + + + + + + + + + + + + + + + + +
      $B%F!<%V%kL>(B$B9T?t(B
      branches3
      tellers30
      accounts300000
      history0
      +
      +

      $B%G!<%?$,(B 3 $BBf$N%G!<%?%Y!<%9%N!<%I$KJ,;6$5$l$F$$$k$3$H$O!"(Bpgpool-II $B$KBP$7$FLd$$9g$o$;$r@\Ld$$9g$o$;$r.CM!":GBgCM$,I=<($5$l$^$9!#(B

      +
      $ for port in 5432 5433 5434 9999; do
      +>     echo $port
      +>     psql -c "SELECT min(aid), max(aid) FROM accounts" -p $port bench_parallel
      +> done
      +
      + + + diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..e9de238 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/ltmain.sh b/ltmain.sh new file mode 100644 index 0000000..d74b5a6 --- /dev/null +++ b/ltmain.sh @@ -0,0 +1,6997 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, +# 2007 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +basename="s,^.*/,,g" + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# The name of this program: +progname=`echo "$progpath" | $SED $basename` +modename="$progname" + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.5.24 +TIMESTAMP=" (1.1220.2.456 2007/06/24 02:25:32)" + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +duplicate_deps=no +preserve_args= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" +extracted_archives= +extracted_serial=0 + +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $mkdir "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || { + $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 + exit $EXIT_FAILURE + } + fi + + $echo "X$my_tmpdir" | $Xsed +} + + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () +{ + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | \ + $SED -n -e '1,100{ + / I /{ + s,.*,import, + p + q + } + }'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $echo $win32_libid_type +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + # user sometimes does CC=-gcc so we need to match that to 'gcc' + trimedcc=`echo ${CC} | $SED -e "s/${host}-//g"` + # and sometimes libtool has CC=-gcc but user does CC=gcc + extendcc=${host}-${CC} + # and sometimes libtool has CC=-gcc but user has CC=-gcc + # (Gentoo-specific hack because we always export $CHOST) + mungedcc=${CHOST-${host}}-${trimedcc} + case "$@ " in + "cc "* | " cc "* | "${host}-cc "* | " ${host}-cc "*|\ + "gcc "* | " gcc "* | "${host}-gcc "* | " ${host}-gcc "*) + tagname=CC + break ;; + "$trimedcc "* | " $trimedcc "* | "`$echo $trimedcc` "* | " `$echo $trimedcc` "*|\ + "$extendcc "* | " $extendcc "* | "`$echo $extendcc` "* | " `$echo $extendcc` "*|\ + "$mungedcc "* | " $mungedcc "* | "`$echo $mungedcc` "* | " `$echo $mungedcc` "*|\ + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit $EXIT_FAILURE +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi +} + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + + $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" + $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 + exit $EXIT_FAILURE + fi +} + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + my_status="" + + $show "${rm}r $my_gentop" + $run ${rm}r "$my_gentop" + $show "$mkdir $my_gentop" + $run $mkdir "$my_gentop" + my_status=$? + if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then + exit $my_status + fi + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + extracted_serial=`expr $extracted_serial + 1` + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir="$my_gentop/$my_xlib_u" + + $show "${rm}r $my_xdir" + $run ${rm}r "$my_xdir" + $show "$mkdir $my_xdir" + $run $mkdir "$my_xdir" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then + exit $exit_status + fi + case $host in + *-darwin*) + $show "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + if test -z "$run"; then + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` + darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` + if test -n "$darwin_arches"; then + darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + $show "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we have a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + lipo -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + ${rm}r unfat-$$ + cd "$darwin_orig_dir" + else + cd "$darwin_orig_dir" + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + fi # $run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + func_extract_archives_result="$my_oldobjs" +} +# End of Shell function definitions +##################################### + +# Darwin sucks +eval std_shrext=\"$shrext_cmds\" + +disable_libs=no + +# Parse our command line options once, thoroughly. +while test "$#" -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + tag) + tagname="$arg" + preserve_args="${preserve_args}=$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + echo "\ +$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP + +Copyright (C) 2007 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit $? + ;; + + --config) + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" + done + exit $? + ;; + + --debug) + $echo "$progname: enabling shell trace mode" + set -x + preserve_args="$preserve_args $arg" + ;; + + --dry-run | -n) + run=: + ;; + + --features) + $echo "host: $host" + if test "$build_libtool_libs" = yes; then + $echo "enable shared libraries" + else + $echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + $echo "enable static libraries" + else + $echo "disable static libraries" + fi + exit $? + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --preserve-dup-deps) duplicate_deps="yes" ;; + + --quiet | --silent) + show=: + preserve_args="$preserve_args $arg" + ;; + + --tag) + prevopt="--tag" + prev=tag + preserve_args="$preserve_args --tag" + ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + preserve_args="$preserve_args --tag" + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE +fi + +case $disable_libs in +no) + ;; +shared) + build_libtool_libs=no + build_old_libs=yes + ;; +static) + build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` + ;; +esac + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 + case $nonopt in + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + srcfile="$nonopt" # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + + for arg + do + case $arg_mode in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal + ;; + + target ) + libobj="$arg" + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit $EXIT_FAILURE + fi + arg_mode=target + continue + ;; + + -static | -prefer-pic | -prefer-non-pic) + later="$later $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + case $lastarg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, and some SunOS ksh mistreat backslash-escaping + # in scan sets (worked around with variable expansion), + # and furthermore cannot handle '|' '&' '(' ')' in scan sets + # at all, so we specify them separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + base_compile="$base_compile $lastarg" + done # for arg + + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit $EXIT_FAILURE + ;; + target) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit $EXIT_FAILURE + ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSifmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.[fF][09]?) xform=[fF][09]. ;; + *.for) xform=for ;; + *.java) xform=java ;; + *.obj) xform=obj ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` + case $qlibobj in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qlibobj="\"$qlibobj\"" ;; + esac + test "X$libobj" != "X$qlibobj" \ + && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ + && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $run ln "$srcfile" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + $echo "$srcfile" > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` + case $qsrcfile in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qsrcfile="\"$qsrcfile\"" ;; + esac + + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit $EXIT_FAILURE + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat $save_arg` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit $EXIT_FAILURE + fi + arg=$save_arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + darwin_framework|darwin_framework_skip) + test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit $EXIT_FAILURE + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework|-arch|-isysroot) + case " $CC " in + *" ${arg} ${1} "* | *" ${arg} ${1} "*) + prev=darwin_framework_skip ;; + *) compiler_flags="$compiler_flags $arg" + prev=darwin_framework ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + notinst_path="$notinst_path $dir" + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs -framework System" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + -model) + compile_command="$compile_command $arg" + compiler_flags="$compiler_flags $arg" + finalize_command="$finalize_command $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m* pass through architecture-specific compiler args for GCC + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) + + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d "$output_objdir"; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then + exit $exit_status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplications in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + esac + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if test "X$duplicate_deps" = "Xyes" ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + for pass in $passes; do + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + if eval $echo \"$deplib\" 2>/dev/null \ + | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + $echo + $echo "*** Warning: Trying to link with static lib archive $deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because the file extensions .$libext of this argument makes me believe" + $echo "*** that it is just a static archive that I should not used here." + else + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + if test "$found" = yes || test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 + exit $EXIT_FAILURE + fi + + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + elif test "$linkmode" != prog && test "$linkmode" != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit $EXIT_FAILURE + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $absdir" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes ; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || test -z "$old_library"; }; then + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + # This is a shared library + + # Warn about portability, can't link against -module's on + # some systems (darwin) + if test "$shouldnotlink" = yes && test "$pass" = link ; then + $echo + if test "$linkmode" = prog; then + $echo "*** Warning: Linking the executable $output against the loadable module" + else + $echo "*** Warning: Linking the shared library $output against the loadable module" + fi + $echo "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$extract_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$old_archive_from_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a module then we can not link against + # it, someone is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | + $EGREP ": [^:]* bundle" >/dev/null ; then + $echo "** Warning, lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $echo + $echo "** And there doesn't seem to be a static archive available" + $echo "** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit $EXIT_FAILURE + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $echo + $echo "*** Warning: This system can not link to static lib archive $lib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $echo "*** But as you try to build a module library, libtool will still create " + $echo "*** a static module, that should work as long as the dlopening application" + $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="$absdir/$objdir" + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="$absdir" + fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, + # but need to link against shared + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$path/$depdepl" ; then + depdepl="$path/$depdepl" + fi + # do not add paths which are already there + case " $newlib_search_path " in + *" $path "*) ;; + *) newlib_search_path="$newlib_search_path $path";; + esac + fi + path="" + ;; + *) + path="-L$path" + ;; + esac + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac + ;; + *) continue ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$depdepl $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit $EXIT_FAILURE + else + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test "$#" -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$2" + number_minor="$3" + number_revision="$4" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows|none) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_minor" + lt_irix_increment=no + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test "$age" -gt "$current"; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; then + major=`expr $current - $age` + else + major=`expr $current - $age + 1` + fi + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=.`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$echo "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` + # deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` + # dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for file magic test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a file magic. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name=`expr $a_deplib : '-l\(.*\)'` + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval $echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a regex pattern. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $echo + if test "X$deplibs_check_method" = "Xnone"; then + $echo "*** Warning: inter-library dependencies are not supported in this platform." + else + $echo "*** Warning: inter-library dependencies are not known to be supported." + fi + $echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $echo + $echo "*** Warning: libtool could not satisfy all declared inter-library" + $echo "*** dependencies of module $libname. Therefore, libtool will create" + $echo "*** a static module, that should work as long as the dlopening" + $echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $echo "*** The inter-library dependencies that have been dropped here will be" + $echo "*** automatically added whenever a program is linked with this library" + $echo "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $echo + $echo "*** Since this library must not contain undefined symbols," + $echo "*** because either the platform does not support them or" + $echo "*** it was explicitly requested with -no-undefined," + $echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + case $archive_cmds in + *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;; + *) eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;; + esac + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && + len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + output_la=`$echo "X$output" | $Xsed -e "$basename"` + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$output_la-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$output_la-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadable object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~\$rm $delfiles\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit $EXIT_FAILURE + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec and hope we can get by with + # turning comma into space.. + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $run eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $run $rm $export_symbols + $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + else + $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + case $host in + *cygwin* | *mingw* ) + $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + $echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +" + + case $host in + *cygwin* | *mingw* ) + $echo >> "$output_objdir/$dlsyms" "\ +/* DATA imports from DLLs on WIN32 can't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs */ +struct { +" + ;; + * ) + $echo >> "$output_objdir/$dlsyms" "\ +const struct { +" + ;; + esac + + + $echo >> "$output_objdir/$dlsyms" "\ + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + case $host in + *cygwin* | *mingw* ) + if test -f "$output_objdir/${outputname}.def" ; then + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP` + else + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + fi + ;; + * ) + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP` + ;; + esac + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP` + fi + + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + exit_status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $exit_status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run eval "$link_command" || exit $? + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + output_name=`basename $output` + output_path=`dirname $output` + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + cat > $cwrappersource <> $cwrappersource<<"EOF" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +# define HAVE_DOS_BASED_FILE_SYSTEM +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +/* -DDEBUG is fairly common in CFLAGS. */ +#undef DEBUG +#if defined DEBUGWRAPPER +# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) +#else +# define DEBUG(format, ...) +#endif + +const char *program_name = NULL; + +void * xmalloc (size_t num); +char * xstrdup (const char *string); +const char * base_name (const char *name); +char * find_executable(const char *wrapper); +int check_executable(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup (base_name (argv[0])); + DEBUG("(main) argv[0] : %s\n",argv[0]); + DEBUG("(main) program_name : %s\n",program_name); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" + newargz[1] = find_executable(argv[0]); + if (newargz[1] == NULL) + lt_fatal("Couldn't find %s", argv[0]); + DEBUG("(main) found exe at : %s\n",newargz[1]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; + + for (i=0; i> $cwrappersource <> $cwrappersource <> $cwrappersource <<"EOF" + return 127; +} + +void * +xmalloc (size_t num) +{ + void * p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL +; +} + +const char * +base_name (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha ((unsigned char)name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return base; +} + +int +check_executable(const char * path) +{ + struct stat st; + + DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) && + ( + /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ +#if defined (S_IXOTH) + ((st.st_mode & S_IXOTH) == S_IXOTH) || +#endif +#if defined (S_IXGRP) + ((st.st_mode & S_IXGRP) == S_IXGRP) || +#endif + ((st.st_mode & S_IXUSR) == S_IXUSR)) + ) + return 1; + else + return 0; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise */ +char * +find_executable (const char* wrapper) +{ + int has_slash = 0; + const char* p; + const char* p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + int tmp_len; + char* concat_name; + + DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char* path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char* q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR(*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen(tmp); + concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen(tmp); + concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable(concat_name)) + return concat_name; + XFREE(concat_name); + return NULL; +} + +char * +strendzap(char *str, const char *pat) +{ + size_t len, patlen; + + assert(str != NULL); + assert(pat != NULL); + + len = strlen(str); + patlen = strlen(pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp(str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char * mode, + const char * message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE). +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $echo >> $output "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + $echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $echo \"\$relink_command_output\" >&2 + $rm \"\$progdir/\$file\" + exit $EXIT_FAILURE + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + $echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. + + # Make sure env LD_LIBRARY_PATH does not mess us up + if test -n \"\${LD_LIBRARY_PATH+set}\"; then + export LD_LIBRARY_PATH=\$progdir:\$LD_LIBRARY_PATH + fi +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \$*\" + exit $EXIT_FAILURE + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + $echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit $EXIT_FAILURE + fi +fi\ +" + chmod +x $output + fi + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "copying selected object files to avoid basename conflicts..." + + if test -z "$gentop"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + exit_status=$? + if test "$exit_status" -ne 0 && test ! -d "$gentop"; then + exit $exit_status + fi + fi + + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + counter=`expr $counter + 1` + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $run ln "$obj" "$gentop/$newobj" || + $run cp "$obj" "$gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + + eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && + test "$len" -le "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + eval cmd=\"$cmd\" + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + if test "X$EGREP" = X ; then + EGREP=egrep + fi + # We do not want portage's install root ($D) present. Check only for + # this if the .la is being installed. + if test "$installed" = yes && test "$D"; then + eval mynewdependency_lib=`echo "$libdir/$name" |sed -e "s:$D:/:g" -e 's:/\+:/:g'` + else + mynewdependency_lib="$libdir/$name" + fi + # Do not add duplicates + if test "$mynewdependency_lib"; then + my_little_ninja_foo_1=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"` + if test -z "$my_little_ninja_foo_1"; then + newdependency_libs="$newdependency_libs $mynewdependency_lib" + fi + fi + ;; + *) + if test "$installed" = yes; then + # Rather use S=WORKDIR if our version of portage supports it. + # This is because some ebuild (gcc) do not use $S as buildroot. + if test "$PWORKDIR"; then + S="$PWORKDIR" + fi + # We do not want portage's build root ($S) present. + my_little_ninja_foo_2=`echo $deplib |$EGREP -e "$S"` + # We do not want portage's install root ($D) present. + my_little_ninja_foo_3=`echo $deplib |$EGREP -e "$D"` + if test -n "$my_little_ninja_foo_2" && test "$S"; then + mynewdependency_lib="" + elif test -n "$my_little_ninja_foo_3" && test "$D"; then + eval mynewdependency_lib=`echo "$deplib" |sed -e "s:$D:/:g" -e 's:/\+:/:g'` + else + mynewdependency_lib="$deplib" + fi + else + mynewdependency_lib="$deplib" + fi + # Do not add duplicates + if test "$mynewdependency_lib"; then + my_little_ninja_foo_4=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"` + if test -z "$my_little_ninja_foo_4"; then + newdependency_libs="$newdependency_libs $mynewdependency_lib" + fi + fi + ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlprefiles="$newdlprefiles $libdir/$name" + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $rm $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + # Do not add duplicates + if test "$installed" = yes && test "$D"; then + install_libdir=`echo "$install_libdir" |sed -e "s:$D:/:g" -e 's:/\+:/:g'` + fi + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit $EXIT_SUCCESS + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $echo "X$nonopt" | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) prev=$arg ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test "$#" -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP` + else + relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP` + fi + + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + exit $EXIT_FAILURE + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=$postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo and FILE.exe exist: automatic-append-.exe + # behavior happens only for exec(3), not for open(2)! Also, sourcing + # `FILE.' does not work on cygwin managed mounts. + # + # If there is no directory component, then add one. + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + exit $EXIT_FAILURE + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # Note that it is not necessary on cygwin/mingw to append a dot to + # foo even if both foo and FILE.exe exist: automatic-append-.exe + # behavior happens only for exec(3), not for open(2)! Also, sourcing + # `FILE.' does not work on cygwin managed mounts. + # + # If there is no directory component, then add one. + case $wrapper in + */* | *\\*) . ${wrapper} ;; + *) . ./${wrapper} ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir=`func_mktempdir` + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + cmds=$old_postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + cmds=$finish_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit $EXIT_SUCCESS + + $echo "X----------------------------------------------------------------------" | $Xsed + $echo "Libraries have been installed in:" + for libdir in $libdirs; do + $echo " $libdir" + done + $echo + $echo "If you ever happen to want to link against installed libraries" + $echo "in a given directory, LIBDIR, you must either use libtool, and" + $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + $echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + $echo " during execution" + fi + if test -n "$runpath_var"; then + $echo " - add LIBDIR to the \`$runpath_var' environment variable" + $echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $echo + $echo "See any operating system documentation about shared libraries for" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "X----------------------------------------------------------------------" | $Xsed + exit $EXIT_SUCCESS + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit $EXIT_FAILURE + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + if test ! -f "$dir/$dlname"; then + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit $EXIT_FAILURE + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit $EXIT_SUCCESS + fi + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + rm="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) rm="$rm $arg"; rmforce=yes ;; + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + cmds=$postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + cmds=$old_postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles || exit_status=1 + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit $EXIT_FAILURE +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE. + +Report bugs to ." + exit $EXIT_SUCCESS + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; +esac + +$echo +$echo "Try \`$modename --help' for more information about other modes." + +exit $? + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +disable_libs=shared +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +disable_libs=static +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/main.c b/main.c new file mode 100644 index 0000000..8bddccf --- /dev/null +++ b/main.c @@ -0,0 +1,1937 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/main.c,v 1.45.2.6 2009/09/25 07:35:16 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + */ +#include "pool.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#ifdef HAVE_GETOPT_H +#include +#endif + +#include "version.h" +#include "parser/pool_memory.h" +#include "parser/pool_string.h" + +/* + * Process pending signal actions. + */ +#define CHECK_REQUEST \ + do { \ + if (wakeup_request) \ + { \ + wakeup_children(); \ + wakeup_request = 0; \ + } \ + if (failover_request) \ + { \ + failover(); \ + failover_request = 0; \ + } \ + if (sigchld_request) \ + { \ + reaper(); \ + } \ + if (reload_config_request) \ + { \ + reload_config(); \ + reload_config_request = 0; \ + } \ + } while (0) + + +#define PGPOOLMAXLITSENQUEUELENGTH 10000 +static void daemonize(void); +static int read_pid_file(void); +static void write_pid_file(void); +static pid_t pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file); +static pid_t fork_a_child(int unix_fd, int inet_fd, int id); +static int create_unix_domain_socket(struct sockaddr_un un_addr_tmp); +static int create_inet_domain_socket(const char *hostname, const int port); +static void myexit(int code); +static void failover(void); +static void reaper(void); +static void wakeup_children(void); +static void reload_config(void); +static int pool_pause(struct timeval *timeout); +static void pool_sleep(unsigned int second); +static void kill_all_children(int sig); +static int get_next_master_node(void); + +static RETSIGTYPE exit_handler(int sig); +static RETSIGTYPE reap_handler(int sig); +static RETSIGTYPE failover_handler(int sig); +static RETSIGTYPE reload_config_handler(int sig); +static RETSIGTYPE health_check_timer_handler(int sig); +static RETSIGTYPE wakeup_handler(int sig); + +static void usage(void); +static void show_version(void); +static void stop_me(void); + +static int trigger_failover_command(int node, const char *command_line); + +static struct sockaddr_un un_addr; /* unix domain socket path */ +static struct sockaddr_un pcp_un_addr; /* unix domain socket path for PCP */ + +ProcessInfo *pids; /* shmem child pid table */ + +/* + * shmem connection info table + * this is a two dimension array. i.e.: + * con_info[pool_config->num_init_children][pool_config->max_pool] + */ +ConnectionInfo *con_info; + +static int unix_fd; /* unix domain socket fd */ +static int inet_fd; /* inet domain socket fd */ + +static int pcp_pid; /* pid for child process handling PCP */ +static int pcp_unix_fd; /* unix domain socket fd for PCP (not used) */ +static int pcp_inet_fd; /* inet domain socket fd for PCP */ +static char pcp_conf_file[POOLMAXPATHLEN+1]; /* path for pcp.conf */ +static char conf_file[POOLMAXPATHLEN+1]; +static char hba_file[POOLMAXPATHLEN+1]; + +static int exiting = 0; /* non 0 if I'm exiting */ +static int switching = 0; /* non 0 if I'm fail overing or degenerating */ + +#ifdef NOT_USED +static int degenerated = 0; /* set non 0 if already degenerated */ +#endif + +static int clear_cache = 0; /* non 0 if clear chache option (-c) is given */ +static int not_detach = 0; /* non 0 if non detach option (-n) is given */ +int debug = 0; /* non 0 if debug option is given (-d) */ + +pid_t mypid; /* pgpool parent process id */ + +long int weight_master; /* normalized weight of master (0-RAND_MAX range) */ + +static int stop_sig = SIGTERM; /* stopping signal default value */ + +static volatile sig_atomic_t health_check_timer_expired; /* non 0 if health check timer expired */ + +POOL_REQUEST_INFO *Req_info; /* request info area in shared memory */ +volatile sig_atomic_t *InRecovery; /* non 0 if recovery is started */ +volatile sig_atomic_t reload_config_request = 0; +static volatile sig_atomic_t failover_request = 0; +static volatile sig_atomic_t sigchld_request = 0; +static volatile sig_atomic_t wakeup_request = 0; + +static int pipe_fds[2]; /* for delivering signals */ + +int my_proc_id; + +int myargc; +char **myargv; + +/* +* pgpool main program +*/ +int main(int argc, char **argv) +{ + int opt; + int i; + int pid; + int size; + int retrycnt; + int sys_retrycnt; + + myargc = argc; + myargv = argv; + + snprintf(conf_file, sizeof(conf_file), "%s/%s", DEFAULT_CONFIGDIR, POOL_CONF_FILE_NAME); + snprintf(pcp_conf_file, sizeof(pcp_conf_file), "%s/%s", DEFAULT_CONFIGDIR, PCP_PASSWD_FILE_NAME); + snprintf(hba_file, sizeof(hba_file), "%s/%s", DEFAULT_CONFIGDIR, HBA_CONF_FILE_NAME); + + while ((opt = getopt(argc, argv, "a:cdf:F:hm:nv")) != -1) + { + switch (opt) + { + case 'a': /* specify hba configuration file */ + if (!optarg) + { + usage(); + exit(1); + } + strncpy(hba_file, optarg, sizeof(hba_file)); + break; + + case 'c': /* clear cache option */ + clear_cache = 1; + break; + + case 'd': /* debug option */ + debug = 1; + break; + + case 'f': /* specify configuration file */ + if (!optarg) + { + usage(); + exit(1); + } + strncpy(conf_file, optarg, sizeof(conf_file)); + break; + + case 'F': /* specify PCP password file */ + if (!optarg) + { + usage(); + exit(1); + } + strncpy(pcp_conf_file, optarg, sizeof(pcp_conf_file)); + break; + + case 'h': + usage(); + exit(0); + break; + + case 'm': /* stop mode */ + if (!optarg) + { + usage(); + exit(1); + } + if (*optarg == 's' || !strcmp("smart", optarg)) + stop_sig = SIGTERM; /* smart shutdown */ + else if (*optarg == 'f' || !strcmp("fast", optarg)) + stop_sig = SIGINT; /* fast shutdown */ + else if (*optarg == 'i' || !strcmp("immediate", optarg)) + stop_sig = SIGQUIT; /* immediate shutdown */ + else + { + usage(); + exit(1); + } + break; + + case 'n': /* no detaching control ttys */ + not_detach = 1; + break; + + case 'v': + show_version(); + exit(0); + + default: + usage(); + exit(1); + } + } + + mypid = getpid(); + + if (pool_init_config()) + exit(1); + + if (pool_get_config(conf_file, INIT_CONFIG)) + { + pool_error("Unable to get configuration. Exiting..."); + exit(1); + } + + if (pool_config->enable_pool_hba) + load_hba(hba_file); + + /* + * if a non-switch argument remains, then it should be either "reload", "stop" or "switch" + */ + if (optind == (argc - 1)) + { + if (!strcmp(argv[optind], "reload")) + { + pid_t pid; + + pid = read_pid_file(); + if (pid < 0) + { + pool_error("could not read pid file"); + pool_shmem_exit(1); + exit(1); + } + + if (kill(pid, SIGHUP) == -1) + { + pool_error("could not reload configuration file pid: %d. reason: %s", pid, strerror(errno)); + pool_shmem_exit(1); + exit(1); + } + pool_shmem_exit(0); + exit(0); + } + if (!strcmp(argv[optind], "stop")) + { + stop_me(); + pool_shmem_exit(0); + exit(0); + } + else + { + usage(); + pool_shmem_exit(1); + exit(1); + } + } + /* + * else if no non-switch argument remains, then it should be a start request + */ + else if (optind == argc) + { + pid = read_pid_file(); + if (pid > 0) + { + if (kill(pid, 0) == 0) + { + fprintf(stderr, "pid file found. is another pgpool(%d) is running?\n", pid); + exit(1); + } + else + fprintf(stderr, "pid file found but it seems bogus. Trying to start pgpool anyway...\n"); + } + } + /* + * otherwise an error... + */ + else + { + usage(); + exit(1); + } + + /* set signal masks */ + poolinitmask(); + + if (not_detach) + write_pid_file(); + else + daemonize(); + + if (pool_semaphore_create(MAX_NUM_SEMAPHORES)) + { + pool_error("Unable to create semaphores. Exiting..."); + pool_shmem_exit(1); + exit(1); + } + + /* clear cache */ + if (clear_cache && pool_config->enable_query_cache && SYSDB_STATUS == CON_UP) + { + Interval interval[1]; + + interval[0].quantity = 0; + interval[0].unit = second; + + pool_clear_cache_by_time(interval, 1); + } + + /* set unix domain socket path */ + snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s/.s.PGSQL.%d", + pool_config->socket_dir, + pool_config->port); + + /* set up signal handlers */ + pool_signal(SIGPIPE, SIG_IGN); + + /* create unix domain socket */ + unix_fd = create_unix_domain_socket(un_addr); + + /* create inet domain socket if any */ + if (pool_config->listen_addresses[0]) + { + inet_fd = create_inet_domain_socket(pool_config->listen_addresses, pool_config->port); + } + + size = pool_config->num_init_children * pool_config->max_pool * sizeof(ConnectionInfo); + con_info = pool_shared_memory_create(size); + if (con_info == NULL) + { + pool_error("failed to allocate connection informations"); + myexit(1); + } + memset(con_info, 0, size); + + size = pool_config->num_init_children * (sizeof(ProcessInfo)); + pids = pool_shared_memory_create(size); + if (pids == NULL) + { + pool_error("failed to allocate pids"); + myexit(1); + } + memset(pids, 0, size); + for (i = 0; i < pool_config->num_init_children; i++) + { + pids[i].connection_info = &con_info[i * pool_config->max_pool]; + } + + /* create fail over/switch over event area */ + Req_info = pool_shared_memory_create(sizeof(POOL_REQUEST_INFO)); + if (Req_info == NULL) + { + pool_error("failed to allocate Req_info"); + myexit(1); + } + + /* initialize Req_info */ + Req_info->kind = NODE_UP_REQUEST; + memset(Req_info->node_id, -1, sizeof(int) * MAX_NUM_BACKENDS); + Req_info->master_node_id = get_next_master_node(); + Req_info->conn_counter = 0; + + InRecovery = pool_shared_memory_create(sizeof(int)); + if (InRecovery == NULL) + { + pool_error("failed to allocate InRecovery"); + myexit(1); + } + *InRecovery = 0; + + /* + * We need to block signal here. Otherwise child might send some + * signals, for example SIGUSR1(fail over). Children will inherit + * signal blocking but they do unblock signals at the very beginning + * of process. So this is harmless. + */ + POOL_SETMASK(&BlockSig); + + /* fork the children */ + for (i=0;inum_init_children;i++) + { + pids[i].pid = fork_a_child(unix_fd, inet_fd, i); + pids[i].start_time = time(NULL); + } + + /* set up signal handlers */ + + pool_signal(SIGTERM, exit_handler); + pool_signal(SIGINT, exit_handler); + pool_signal(SIGQUIT, exit_handler); + pool_signal(SIGCHLD, reap_handler); + pool_signal(SIGUSR1, failover_handler); + pool_signal(SIGUSR2, wakeup_handler); + pool_signal(SIGHUP, reload_config_handler); + + /* create pipe for delivering event */ + if (pipe(pipe_fds) < 0) + { + pool_error("failed to create pipe"); + myexit(1); + } + + pool_log("pgpool successfully started"); + + /* fork a child for PCP handling */ + snprintf(pcp_un_addr.sun_path, sizeof(pcp_un_addr.sun_path), "%s/.s.PGSQL.%d", + pool_config->pcp_socket_dir, + pool_config->pcp_port); + pcp_unix_fd = create_unix_domain_socket(pcp_un_addr); + /* maybe change "*" to pool_config->pcp_listen_addresses */ + pcp_inet_fd = create_inet_domain_socket("*", pool_config->pcp_port); + pcp_pid = pcp_fork_a_child(pcp_unix_fd, pcp_inet_fd, pcp_conf_file); + + retrycnt = 0; /* reset health check retry counter */ + sys_retrycnt = 0; /* reset SystemDB health check retry counter */ + + /* + * This is the main loop + */ + for (;;) + { + CHECK_REQUEST; + + /* do we need health checking for PostgreSQL? */ + if (pool_config->health_check_period > 0) + { + int sts; + int sys_sts = 0; + unsigned int sleep_time; + + if (retrycnt == 0) + { + pool_debug("starting health checking"); + } + else + { + pool_debug("retrying %d th health checking", retrycnt); + } + + if (pool_config->health_check_timeout > 0) + { + /* + * set health checker timeout. we want to detect + * communication path failure much earlier before + * TCP/IP stack detects it. + */ + pool_signal(SIGALRM, health_check_timer_handler); + alarm(pool_config->health_check_timeout); + } + + /* + * do actual health check. trying to connect to the backend + */ + errno = 0; + health_check_timer_expired = 0; + POOL_SETMASK(&UnBlockSig); + sts = health_check(); + POOL_SETMASK(&BlockSig); + if (pool_config->parallel_mode || pool_config->enable_query_cache) + sys_sts = system_db_health_check(); + + if ((sts > 0 || sys_sts < 0) && (errno != EINTR || (errno == EINTR && health_check_timer_expired))) + { + if (sts > 0) + { + sts--; + + if (!pool_config->parallel_mode) + { + pool_log("set %d th backend down status", sts); + Req_info->kind = NODE_DOWN_REQUEST; + Req_info->node_id[0] = sts; + failover(); + /* need to distribute this info to children */ + } + else + { + retrycnt++; + pool_signal(SIGALRM, SIG_IGN); /* Cancel timer */ + + if (retrycnt > NUM_BACKENDS) + { + /* retry count over */ + pool_log("set %d th backend down status", sts); + Req_info->kind = NODE_DOWN_REQUEST; + Req_info->node_id[0] = sts; + failover(); + retrycnt = 0; + } + else + { + /* continue to retry */ + sleep_time = pool_config->health_check_period/NUM_BACKENDS; + pool_debug("retry sleep time: %d seconds", sleep_time); + pool_sleep(sleep_time); + continue; + } + } + } + if (sys_sts < 0) + { + sys_retrycnt++; + pool_signal(SIGALRM, SIG_IGN); + + if (sys_retrycnt > NUM_BACKENDS) + { + pool_log("set SystemDB down status"); + SYSDB_STATUS = CON_DOWN; + sys_retrycnt = 0; + } + else if (sts == 0) /* goes to sleep only when SystemDB alone was down */ + { + sleep_time = pool_config->health_check_period/NUM_BACKENDS; + pool_debug("retry sleep time: %d seconds", sleep_time); + pool_sleep(sleep_time); + continue; + } + } + } + + if (pool_config->health_check_timeout > 0) + { + /* seems ok. cancel health check timer */ + pool_signal(SIGALRM, SIG_IGN); + } + + sleep_time = pool_config->health_check_period; + pool_sleep(sleep_time); + } + else + { + for (;;) + { + int r; + struct timeval t = {3, 0}; + + POOL_SETMASK(&UnBlockSig); + r = pool_pause(&t); + POOL_SETMASK(&BlockSig); + if (r > 0) + break; + } + } + } + + pool_shmem_exit(0); +} + +static void show_version(void) +{ + fprintf(stderr, "%s version %s (%s)\n", PACKAGE, VERSION, PGPOOLVERSION); +} + +static void usage(void) +{ + fprintf(stderr, "%s version %s (%s),\n", PACKAGE, VERSION, PGPOOLVERSION); + fprintf(stderr, " a generic connection pool/replication/load balance server for PostgreSQL\n\n"); + fprintf(stderr, "Usage:\n"); + fprintf(stderr, " pgpool [ -c] [ -f CONFIG_FILE ] [ -F PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ]\n"); + fprintf(stderr, " [ -n ] [ -d ]\n"); + fprintf(stderr, " pgpool [ -f CONFIG_FILE ] [ -F PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ]\n"); + fprintf(stderr, " [ -m SHUTDOWN-MODE ] stop\n"); + fprintf(stderr, " pgpool [ -f CONFIG_FILE ] [ -F PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ] reload\n\n"); + fprintf(stderr, "Common options:\n"); + fprintf(stderr, " -a HBA_CONFIG_FILE Sets the path to the pool_hba.conf configuration file\n"); + fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, HBA_CONF_FILE_NAME); + fprintf(stderr, " -f CONFIG_FILE Sets the path to the pgpool.conf configuration file\n"); + fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, POOL_CONF_FILE_NAME); + fprintf(stderr, " -F PCP_CONFIG_FILE Sets the path to the pcp.conf configuration file\n"); + fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, PCP_PASSWD_FILE_NAME); + fprintf(stderr, " -h Prints this help\n\n"); + fprintf(stderr, "Start options:\n"); + fprintf(stderr, " -c Clears query cache (enable_query_cache must be on)\n"); + fprintf(stderr, " -n Don't run in daemon mode, does not detach control tty\n"); + fprintf(stderr, " -d Debug mode\n\n"); + fprintf(stderr, "Stop options:\n"); + fprintf(stderr, " -m SHUTDOWN-MODE Can be \"smart\", \"fast\", or \"immediate\"\n\n"); + fprintf(stderr, "Shutdown modes are:\n"); + fprintf(stderr, " smart quit after all clients have disconnected\n"); + fprintf(stderr, " fast quit directly, with proper shutdown\n"); + fprintf(stderr, " immediate quit without complete shutdown; will lead to recovery on restart\n"); +} + +/* +* detach control ttys +*/ +static void daemonize(void) +{ + int i; + pid_t pid; + int fdlimit; + + pid = fork(); + if (pid == (pid_t) -1) + { + pool_error("fork() failed. reason: %s", strerror(errno)); + pool_shmem_exit(1); + exit(1); + return; /* not reached */ + } + else if (pid > 0) + { /* parent */ + pool_shmem_exit(0); + exit(0); + } + +#ifdef HAVE_SETSID + if (setsid() < 0) + { + pool_error("setsid() failed. reason:%s", strerror(errno)); + pool_shmem_exit(1); + exit(1); + } +#endif + + mypid = getpid(); + + chdir("/"); + + i = open("/dev/null", O_RDWR); + dup2(i, 0); + dup2(i, 1); + dup2(i, 2); + + fdlimit = sysconf(_SC_OPEN_MAX); + for (i = 3; i < fdlimit; i++) + close(i); + + write_pid_file(); +} + + +/* +* stop myself +*/ +static void stop_me(void) +{ + pid_t pid; + + pid = read_pid_file(); + if (pid < 0) + { + pool_error("could not read pid file"); + pool_shmem_exit(1); + exit(1); + } + + if (kill(pid, stop_sig) == -1) + { + pool_error("could not stop pid: %d. reason: %s", pid, strerror(errno)); + pool_shmem_exit(1); + exit(1); + } + + fprintf(stderr, "stop request sent to pgpool. waiting for termination..."); + + while (kill(pid, 0) == 0) + { + fprintf(stderr, "."); + sleep(1); + } + fprintf(stderr, "done.\n"); +} + +/* +* read the pid file +*/ +static int read_pid_file(void) +{ + FILE *fd; + char pidbuf[128]; + + fd = fopen(pool_config->pid_file_name, "r"); + if (!fd) + { + return -1; + } + if (fread(pidbuf, 1, sizeof(pidbuf), fd) <= 0) + { + pool_error("could not read pid file as %s. reason: %s", + pool_config->pid_file_name, strerror(errno)); + fclose(fd); + return -1; + } + fclose(fd); + return(atoi(pidbuf)); +} + +/* +* write the pid file +*/ +static void write_pid_file(void) +{ + FILE *fd; + char pidbuf[128]; + + fd = fopen(pool_config->pid_file_name, "w"); + if (!fd) + { + pool_error("could not open pid file as %s. reason: %s", + pool_config->pid_file_name, strerror(errno)); + pool_shmem_exit(1); + exit(1); + } + snprintf(pidbuf, sizeof(pidbuf), "%d", (int)getpid()); + fwrite(pidbuf, strlen(pidbuf)+1, 1, fd); + if (fclose(fd)) + { + pool_error("could not write pid file as %s. reason: %s", + pool_config->pid_file_name, strerror(errno)); + pool_shmem_exit(1); + exit(1); + } +} + +/* + * fork a child for PCP + */ +pid_t pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file) +{ + pid_t pid; + + pid = fork(); + + if (pid == 0) + { + close(pipe_fds[0]); + close(pipe_fds[1]); + + myargv = save_ps_display_args(myargc, myargv); + + /* call PCP child main */ + POOL_SETMASK(&UnBlockSig); + reload_config_request = 0; + pcp_do_child(unix_fd, inet_fd, pcp_conf_file); + } + else if (pid == -1) + { + pool_error("fork() failed. reason: %s", strerror(errno)); + myexit(1); + } + return pid; +} + +/* +* fork a child +*/ +pid_t fork_a_child(int unix_fd, int inet_fd, int id) +{ + pid_t pid; + + pid = fork(); + + if (pid == 0) + { + /* Before we unconditionally closed pipe_fds[0] and pipe_fds[1] + * here, which is apparently wrong since in the start up of + * pgpool, pipe(2) is not called yet and it mistakenly closes + * fd 0. Now we check the fd > 0 before close(), expecting + * pipe returns fds greater than 0. Note that we cannot + * unconditionally remove close(2) calls since fork_a_child() + * may be called *after* pgpool starting up. + */ + if (pipe_fds[0] > 0) + { + close(pipe_fds[0]); + close(pipe_fds[1]); + } + + myargv = save_ps_display_args(myargc, myargv); + + /* call child main */ + POOL_SETMASK(&UnBlockSig); + reload_config_request = 0; + my_proc_id = id; + do_child(unix_fd, inet_fd); + } + else if (pid == -1) + { + pool_error("fork() failed. reason: %s", strerror(errno)); + myexit(1); + } + return pid; +} + +/* +* create inet domain socket +*/ +static int create_inet_domain_socket(const char *hostname, const int port) +{ + struct sockaddr_in addr; + int fd; + int status; + int one = 1; + int len; + + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd == -1) + { + pool_error("Failed to create INET domain socket. reason: %s", strerror(errno)); + myexit(1); + } + if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, + sizeof(one))) == -1) + { + pool_error("setsockopt() failed. reason: %s", strerror(errno)); + myexit(1); + } + + memset((char *) &addr, 0, sizeof(addr)); + ((struct sockaddr *)&addr)->sa_family = AF_INET; + + if (strcmp(hostname, "*")==0) + { + addr.sin_addr.s_addr = htonl(INADDR_ANY); + } + else + { + struct hostent *hostinfo; + + hostinfo = gethostbyname(hostname); + if (!hostinfo) + { + pool_error("could not resolve host name \"%s\": %s", hostname, hstrerror(h_errno)); + myexit(1); + } + addr.sin_addr = *(struct in_addr *) hostinfo->h_addr; + } + + addr.sin_port = htons(port); + len = sizeof(struct sockaddr_in); + status = bind(fd, (struct sockaddr *)&addr, len); + if (status == -1) + { + char *host = "", *serv = ""; + char hostname[NI_MAXHOST], servname[NI_MAXSERV]; + if (getnameinfo((struct sockaddr *) &addr, len, hostname, sizeof(hostname), servname, sizeof(servname), 0) == 0) { + host = hostname; + serv = servname; + } + pool_error("bind(%s:%s) failed. reason: %s", host, serv, strerror(errno)); + myexit(1); + } + + status = listen(fd, PGPOOLMAXLITSENQUEUELENGTH); + if (status < 0) + { + pool_error("listen() failed. reason: %s", strerror(errno)); + myexit(1); + } + return fd; +} + +/* +* create UNIX domain socket +*/ +static int create_unix_domain_socket(struct sockaddr_un un_addr_tmp) +{ + struct sockaddr_un addr; + int fd; + int status; + int len; + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd == -1) + { + pool_error("Failed to create UNIX domain socket. reason: %s", strerror(errno)); + myexit(1); + } + memset((char *) &addr, 0, sizeof(addr)); + ((struct sockaddr *)&addr)->sa_family = AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), un_addr_tmp.sun_path); + len = sizeof(struct sockaddr_un); + status = bind(fd, (struct sockaddr *)&addr, len); + if (status == -1) + { + pool_error("bind(%s) failed. reason: %s", addr.sun_path, strerror(errno)); + myexit(1); + } + + if (chmod(un_addr_tmp.sun_path, 0777) == -1) + { + pool_error("chmod() failed. reason: %s", strerror(errno)); + myexit(1); + } + + status = listen(fd, PGPOOLMAXLITSENQUEUELENGTH); + if (status < 0) + { + pool_error("listen() failed. reason: %s", strerror(errno)); + myexit(1); + } + return fd; +} + +static void myunlink(const char* path) +{ + if (unlink(path) == 0) return; + pool_error("unlink(%s) failed: %s", path, strerror(errno)); +} + +static void myexit(int code) +{ + int i; + + if (getpid() != mypid) + return; + + if (pids != NULL) { + POOL_SETMASK(&AuthBlockSig); + exiting = 1; + for (i = 0; i < pool_config->num_init_children; i++) + { + pid_t pid = pids[i].pid; + if (pid) + { + kill(pid, SIGTERM); + } + } + while (wait(NULL) > 0) + ; + if (errno != ECHILD) + pool_error("wait() failed. reason:%s", strerror(errno)); + POOL_SETMASK(&UnBlockSig); + } + + myunlink(un_addr.sun_path); + myunlink(pcp_un_addr.sun_path); + myunlink(pool_config->pid_file_name); + + pool_shmem_exit(code); + exit(code); +} + +void notice_backend_error(int node_id) +{ + int n = node_id; + + degenerate_backend_set(&n, 1); +} + +/* notice backend connection error using SIGUSR1 */ +void degenerate_backend_set(int *node_id_set, int count) +{ + pid_t parent = getppid(); + int i; + + if (pool_config->parallel_mode) + { + return; + } + + pool_semaphore_lock(REQUEST_INFO_SEM); + Req_info->kind = NODE_DOWN_REQUEST; + for (i = 0; i < count; i++) + { + if (node_id_set[i] < 0 || node_id_set[i] >= MAX_NUM_BACKENDS || + !VALID_BACKEND(node_id_set[i])) + { + pool_log("notice_backend_error: node %d is not valid backend.", i); + continue; + } + + pool_log("notice_backend_error: %d fail over request from pid %d", node_id_set[i], getpid()); + Req_info->node_id[i] = node_id_set[i]; + } + kill(parent, SIGUSR1); + pool_semaphore_unlock(REQUEST_INFO_SEM); +} + +/* send failback request using SIGUSR1 */ +void send_failback_request(int node_id) +{ + pid_t parent = getppid(); + + pool_log("send_failback_request: fail back %d th node request from pid %d", node_id, getpid()); + Req_info->kind = NODE_UP_REQUEST; + Req_info->node_id[0] = node_id; + + if (node_id < 0 || node_id >= MAX_NUM_BACKENDS || VALID_BACKEND(node_id)) + { + pool_error("send_failback_request: node %d is alive.", node_id); + return; + } + + kill(parent, SIGUSR1); +} + +static RETSIGTYPE exit_handler(int sig) +{ + int i; + + POOL_SETMASK(&AuthBlockSig); + + /* + * this could happen in a child process if a signal has been sent + * before resetting signal handler + */ + if (getpid() != mypid) + { + pool_debug("exit_handler: I am not parent"); + POOL_SETMASK(&UnBlockSig); + pool_shmem_exit(0); + exit(0); + } + + if (sig == SIGTERM) + pool_log("received smart shutdown request"); + else if (sig == SIGINT) + pool_log("received fast shutdown request"); + else if (sig == SIGQUIT) + pool_log("received immediate shutdown request"); + else + { + pool_error("exit_handler: unknown signal received %d", sig); + POOL_SETMASK(&UnBlockSig); + return; + } + + exiting = 1; + + for (i = 0; i < pool_config->num_init_children; i++) + { + pid_t pid = pids[i].pid; + if (pid) + { + kill(pid, sig); + } + } + + kill(pcp_pid, sig); + + POOL_SETMASK(&UnBlockSig); + + while (wait(NULL) > 0) + ; + + if (errno != ECHILD) + pool_error("wait() failed. reason:%s", strerror(errno)); + + pids = NULL; + myexit(0); +} + +/* + * calculate next master node id + */ +static int get_next_master_node(void) +{ + int i; + for (i=0;ibackend_desc->num_backends;i++) + { + /* + * Do not use VALID_BACKEND macro in raw mode. + * VALID_BACKEND return true only if the argument is master + * node id. In other words, standby nodes are false. So need + * to check backend status without VALID_BACKEND. + */ + if (RAW_MODE) + { + if (BACKEND_INFO(i).backend_status == CON_CONNECT_WAIT) + break; + } + else if (VALID_BACKEND(i)) + break; + } + return i; +} + +/* + * handle SIGUSR1 + * + */ +static RETSIGTYPE failover_handler(int sig) +{ + POOL_SETMASK(&BlockSig); + failover_request = 1; + write(pipe_fds[1], "\0", 1); + POOL_SETMASK(&UnBlockSig); +} + +/* + * backend connection error, failover/failback request, if possible + * failover() must be called under protecting signals. + */ +static void failover(void) +{ + int i; + int node_id; + int new_master; + int nodes[MAX_NUM_BACKENDS]; + + pool_debug("failover_handler called"); + + memset(nodes, 0, sizeof(int) * MAX_NUM_BACKENDS); + + /* + * this could happen in a child process if a signal has been sent + * before resetting signal handler + */ + if (getpid() != mypid) + { + pool_debug("failover_handler: I am not parent"); + kill(pcp_pid, SIGUSR2); + return; + } + + /* + * processing SIGTERM, SIGINT or SIGQUIT + */ + if (exiting) + { + pool_debug("failover_handler called while exiting"); + kill(pcp_pid, SIGUSR2); + return; + } + + /* + * processing fail over or switch over + */ + if (switching) + { + pool_debug("failover_handler called while switching"); + kill(pcp_pid, SIGUSR2); + return; + } + + pool_semaphore_lock(REQUEST_INFO_SEM); + + if (Req_info->kind == CLOSE_IDLE_REQUEST) + { + pool_semaphore_unlock(REQUEST_INFO_SEM); + kill_all_children(SIGUSR1); + kill(pcp_pid, SIGUSR2); + return; + } + + /* + * if not in replication mode/master slave mode, we treat this a restart request. + * otherwise we need to check if we have already failovered. + */ + pool_debug("failover_handler: starting to select new master node"); + switching = 1; + node_id = Req_info->node_id[0]; + + /* failback request? */ + if (Req_info->kind == NODE_UP_REQUEST) + { + if (node_id >= MAX_NUM_BACKENDS || + (Req_info->kind == NODE_UP_REQUEST && VALID_BACKEND(node_id)) || + (Req_info->kind == NODE_DOWN_REQUEST && !VALID_BACKEND(node_id))) + { + pool_semaphore_unlock(REQUEST_INFO_SEM); + pool_error("failover_handler: invalid node_id %d status:%d MAX_NUM_BACKENDS: %d", node_id, + BACKEND_INFO(node_id).backend_status, MAX_NUM_BACKENDS); + kill(pcp_pid, SIGUSR2); + switching = 0; + return; + } + + pool_log("starting fail back. reconnect host %s(%d)", + BACKEND_INFO(node_id).backend_hostname, + BACKEND_INFO(node_id).backend_port); + BACKEND_INFO(node_id).backend_status = CON_CONNECT_WAIT; /* unset down status */ + trigger_failover_command(node_id, pool_config->failback_command); + } + else + { + int cnt = 0; + + for (i = 0; i < MAX_NUM_BACKENDS; i++) + { + if (Req_info->node_id[i] != -1 && + VALID_BACKEND(Req_info->node_id[i])) + { + pool_log("starting degeneration. shutdown host %s(%d)", + BACKEND_INFO(Req_info->node_id[i]).backend_hostname, + BACKEND_INFO(Req_info->node_id[i]).backend_port); + + + BACKEND_INFO(Req_info->node_id[i]).backend_status = CON_DOWN; /* set down status */ + /* save down node */ + nodes[Req_info->node_id[i]] = 1; + cnt++; + } + } + + if (cnt == 0) + { + pool_log("failover: no backends are degenerated"); + pool_semaphore_unlock(REQUEST_INFO_SEM); + kill(pcp_pid, SIGUSR2); + switching = 0; + return; + } + } + + new_master = get_next_master_node(); + + if (new_master == pool_config->backend_desc->num_backends) + { + pool_error("failover_handler: no valid DB node found"); + } + +/* + * Before we tried to minimize restarting pgpool to protect existing + * connections from clients to pgpool children. What we did here was, + * if children other than master went down, we did not fail over. + * This is wrong. Think about following scenario. If someone + * accidentally plugs out the network cable, the TCP/IP stack keeps + * retrying for long time (typically 2 hours). The only way to stop + * the retry is restarting the process. Bottom line is, we need to + * restart all children in any case. See pgpool-general list posting + * "TCP connections are *not* closed when a backend timeout" on Jul 13 + * 2008 for more details. + */ + +#ifdef NOT_USED + else + { + if (Req_info->master_node_id == new_master && *InRecovery == 0) + { + pool_log("failover_handler: do not restart pgpool. same master node %d was selected", new_master); + if (Req_info->kind == NODE_UP_REQUEST) + { + pool_log("failback done. reconnect host %s(%d)", + BACKEND_INFO(node_id).backend_hostname, + BACKEND_INFO(node_id).backend_port); + } + else + { + pool_log("failover done. shutdown host %s(%d)", + BACKEND_INFO(node_id).backend_hostname, + BACKEND_INFO(node_id).backend_port); + } + + /* exec failover_command */ + for (i = 0; i < pool_config->backend_desc->num_backends; i++) + { + if (nodes[i]) + trigger_failover_command(i, pool_config->failover_command); + } + + pool_semaphore_unlock(REQUEST_INFO_SEM); + switching = 0; + kill(pcp_pid, SIGUSR2); + switching = 0; + return; + } + } +#endif + /* kill all children */ + for (i = 0; i < pool_config->num_init_children; i++) + { + pid_t pid = pids[i].pid; + if (pid) + { + kill(pid, SIGQUIT); + pool_debug("failover_handler: kill %d", pid); + } + } + + /* exec failover_command */ + for (i = 0; i < pool_config->backend_desc->num_backends; i++) + { + if (nodes[i]) + trigger_failover_command(i, pool_config->failover_command); + } + + pool_log("failover_handler: set new master node: %d", new_master); + Req_info->master_node_id = new_master; + +/* no need to wait since it will be done in reap_handler */ +#ifdef NOT_USED + while (wait(NULL) > 0) + ; + + if (errno != ECHILD) + pool_error("failover_handler: wait() failed. reason:%s", strerror(errno)); +#endif + + memset(Req_info->node_id, -1, sizeof(int) * MAX_NUM_BACKENDS); + pool_semaphore_unlock(REQUEST_INFO_SEM); + + /* fork the children */ + for (i=0;inum_init_children;i++) + { + pids[i].pid = fork_a_child(unix_fd, inet_fd, i); + pids[i].start_time = time(NULL); + } + + if (Req_info->kind == NODE_UP_REQUEST) + { + pool_log("failback done. reconnect host %s(%d)", + BACKEND_INFO(node_id).backend_hostname, + BACKEND_INFO(node_id).backend_port); + } + else + { + pool_log("failover done. shutdown host %s(%d)", + BACKEND_INFO(node_id).backend_hostname, + BACKEND_INFO(node_id).backend_port); + } + + switching = 0; + + /* kick wakeup_handler in pcp_child to notice that + * faiover/failback done + */ + kill(pcp_pid, SIGUSR2); +} + +/* + * health check timer handler + */ +static RETSIGTYPE health_check_timer_handler(int sig) +{ + POOL_SETMASK(&BlockSig); + health_check_timer_expired = 1; + POOL_SETMASK(&UnBlockSig); +} + + +/* + * check if we can connect to the backend + * returns 0 for ok. otherwise returns backend id + 1 + */ +int health_check(void) +{ + int fd; + int sts; + + /* V2 startup packet */ + typedef struct { + int len; /* startup packet length */ + StartupPacket_v2 sp; + } MySp; + MySp mysp; + char kind; + int i; + + if (*InRecovery) + return 0; + + memset(&mysp, 0, sizeof(mysp)); + mysp.len = htonl(296); + mysp.sp.protoVersion = htonl(PROTO_MAJOR_V2 << 16); + strcpy(mysp.sp.database, "template1"); + strncpy(mysp.sp.user, pool_config->health_check_user, sizeof(mysp.sp.user) - 1); + *mysp.sp.options = '\0'; + *mysp.sp.unused = '\0'; + *mysp.sp.tty = '\0'; + + for (i=0;ibackend_desc->num_backends;i++) + { + pool_debug("health_check: %d th DB node status: %d", i, BACKEND_INFO(i).backend_status); + + if (BACKEND_INFO(i).backend_status == CON_UNUSED || + BACKEND_INFO(i).backend_status == CON_DOWN) + continue; + + if (*(BACKEND_INFO(i).backend_hostname) == '\0') + fd = connect_unix_domain_socket(i); + else + fd = connect_inet_domain_socket(i); + + if (fd < 0) + { + pool_error("health check failed. %d th host %s at port %d is down", + i, + BACKEND_INFO(i).backend_hostname, + BACKEND_INFO(i).backend_port); + + return i+1; + } + + if (write(fd, &mysp, sizeof(mysp)) < 0) + { + pool_error("health check failed during write. host %s at port %d is down. reason: %s", + BACKEND_INFO(i).backend_hostname, + BACKEND_INFO(i).backend_port, + strerror(errno)); + close(fd); + return i+1; + } + + /* + * Don't bother to be blocked by read(2). It will be + * interrupted by ALRAM anyway. + */ + sts = read(fd, &kind, 1); + if (sts == -1) + { + pool_error("health check failed during read. host %s at port %d is down. reason: %s", + BACKEND_INFO(i).backend_hostname, + BACKEND_INFO(i).backend_port, + strerror(errno)); + close(fd); + return i+1; + } + else if (sts == 0) + { + pool_error("health check failed. EOF encountered. host %s at port %d is down", + BACKEND_INFO(i).backend_hostname, + BACKEND_INFO(i).backend_port); + close(fd); + return i+1; + } + + /* + * If a backend raised a FATAL error(max connections error or + * starting up error?), do not send a Terminate message. + */ + if ((kind != 'E') && (write(fd, "X", 1) < 0)) + { + pool_error("health check failed during write. host %s at port %d is down. reason: %s. Perhaps wrong health check user?", + BACKEND_INFO(i).backend_hostname, + BACKEND_INFO(i).backend_port, + strerror(errno)); + close(fd); + return i+1; + } + + close(fd); + } + + return 0; +} + +/* + * check if we can connect to the SystemDB + * returns 0 for ok. otherwise returns -1 + */ +int +system_db_health_check(void) +{ + int fd; + + /* V2 startup packet */ + typedef struct { + int len; /* startup packet length */ + StartupPacket_v2 sp; + } MySp; + MySp mysp; + char kind; + + memset(&mysp, 0, sizeof(mysp)); + mysp.len = htonl(296); + mysp.sp.protoVersion = htonl(PROTO_MAJOR_V2 << 16); + strcpy(mysp.sp.database, "template1"); + strncpy(mysp.sp.user, SYSDB_INFO->user, sizeof(mysp.sp.user) - 1); + *mysp.sp.options = '\0'; + *mysp.sp.unused = '\0'; + *mysp.sp.tty = '\0'; + + pool_debug("health_check: SystemDB status: %d", SYSDB_STATUS); + + /* if SystemDB is already down, ignore */ + if (SYSDB_STATUS == CON_UNUSED || SYSDB_STATUS == CON_DOWN) + return 0; + + if (*SYSDB_INFO->hostname == '\0') + fd = connect_unix_domain_socket_by_port(SYSDB_INFO->port, pool_config->backend_socket_dir); + else + fd = connect_inet_domain_socket_by_port(SYSDB_INFO->hostname, SYSDB_INFO->port); + + if (fd < 0) + { + pool_error("health check failed. SystemDB host %s at port %d is down", + SYSDB_INFO->hostname, + SYSDB_INFO->port); + + return -1; + } + + if (write(fd, &mysp, sizeof(mysp)) < 0) + { + pool_error("health check failed during write. SystemDB host %s at port %d is down", + SYSDB_INFO->hostname, + SYSDB_INFO->port); + close(fd); + return -1; + } + + read(fd, &kind, 1); + + if (write(fd, "X", 1) < 0) + { + pool_error("health check failed during write. SystemDB host %s at port %d is down", + SYSDB_INFO->hostname, + SYSDB_INFO->port); + close(fd); + return -1; + } + + close(fd); + return 0; +} + +/* + * handle SIGCHLD + */ +static RETSIGTYPE reap_handler(int sig) +{ + POOL_SETMASK(&BlockSig); + sigchld_request = 1; + write(pipe_fds[1], "\0", 1); + POOL_SETMASK(&UnBlockSig); +} + +/* + * Attach zombie processes and restart child processes. + * reaper() must be called under protecting signals. + */ +static void reaper(void) +{ + pid_t pid; + int status; + int i; + + pool_debug("reap_handler called"); + + if (exiting) + { + pool_debug("reap_handler: exited due to exiting"); + return; + } + + if (switching) + { + pool_debug("reap_handler: exited due to switching"); + return; + } + + /* clear SIGCHLD request */ + sigchld_request = 0; + +#ifdef HAVE_WAITPID + pool_debug("reap_handler: call waitpid"); + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) +#else + pool_debug("reap_handler: call wait3"); + while ((pid = wait3(&status, WNOHANG, NULL)) > 0) +#endif + { + /* if exiting child process was PCP handler */ + if (pid == pcp_pid) + { + pool_debug("PCP child %d exits with status %d by signal %d", pid, status, WTERMSIG(status)); + + pcp_pid = pcp_fork_a_child(pcp_unix_fd, pcp_inet_fd, pcp_conf_file); + pool_debug("fork a new PCP child pid %d", pcp_pid); + break; + } else { + pool_debug("child %d exits with status %d by signal %d", pid, status, WTERMSIG(status)); + + /* look for exiting child's pid */ + for (i=0;inum_init_children;i++) + { + if (pid == pids[i].pid) + { + /* if found, fork a new child */ + if (!switching && !exiting && status) + { + pids[i].pid = fork_a_child(unix_fd, inet_fd, i); + pids[i].start_time = time(NULL); + pool_debug("fork a new child pid %d", pids[i].pid); + break; + } + } + } + } + } + pool_debug("reap_handler: normally exited"); +} + +/* + * get node information specified by node_number + */ +BackendInfo * +pool_get_node_info(int node_number) +{ + if (node_number >= NUM_BACKENDS) + return NULL; + + return &BACKEND_INFO(node_number); +} + +/* + * get number of nodes + */ +int +pool_get_node_count(void) +{ + return NUM_BACKENDS; +} + +/* + * get process ids + */ +int * +pool_get_process_list(int *array_size) +{ + int *array; + int i; + + *array_size = pool_config->num_init_children; + array = calloc(*array_size, sizeof(int)); + for (i = 0; i < *array_size; i++) + array[i] = pids[i].pid; + + return array; +} + +/* + * get process information specified by pid + */ +ProcessInfo * +pool_get_process_info(pid_t pid) +{ + int i; + + for (i = 0; i < pool_config->num_init_children; i++) + if (pids[i].pid == pid) + return &pids[i]; + + return NULL; +} + +/* + * get System DB information + */ +SystemDBInfo * +pool_get_system_db_info(void) +{ + if (system_db_info == NULL) + return NULL; + + return system_db_info->info; +} + + +/* + * handle SIGUSR2 + * Wakeup all processes + */ +static void wakeup_children(void) +{ + kill_all_children(SIGUSR2); +} + + +static RETSIGTYPE wakeup_handler(int sig) +{ + POOL_SETMASK(&BlockSig); + wakeup_request = 1; + write(pipe_fds[1], "\0", 1); + POOL_SETMASK(&UnBlockSig); +} + +/* + * handle SIGHUP + * + */ +static RETSIGTYPE reload_config_handler(int sig) +{ + POOL_SETMASK(&BlockSig); + reload_config_request = 1; + write(pipe_fds[1], "\0", 1); + POOL_SETMASK(&UnBlockSig); +} + +static void reload_config(void) +{ + pool_log("reload config files."); + pool_get_config(conf_file, RELOAD_CONFIG); + if (pool_config->enable_pool_hba) + load_hba(hba_file); + if (pool_config->parallel_mode) + pool_memset_system_db_info(system_db_info->info); + kill_all_children(SIGHUP); +} + +static void kill_all_children(int sig) +{ + int i; + + /* kill all children */ + for (i = 0; i < pool_config->num_init_children; i++) + { + pid_t pid = pids[i].pid; + if (pid) + { + kill(pid, sig); + } + } + + /* make PCP process reload as well */ + if (sig == SIGHUP) + kill(pcp_pid, sig); +} + +/* + * pause in a period specified by timeout. If any data is coming + * through pipe_fds[0], that means one of: failover request(SIGUSR1), + * SIGCHLD received, children wake up request(SIGUSR2 used in on line + * recovery processing) or config file reload request(SIGHUP) has been + * occurred. In this case this function returns 1. + * otherwise 0: (no signal event occurred), -1: (error) + * XXX: is it ok that select(2) error is ignored here? + */ +static int pool_pause(struct timeval *timeout) +{ + fd_set rfds; + int n; + char dummy; + + FD_ZERO(&rfds); + FD_SET(pipe_fds[0], &rfds); + n = select(pipe_fds[0]+1, &rfds, NULL, NULL, timeout); + if (n == 1) + read(pipe_fds[0], &dummy, 1); + return n; +} + +/* + * sleep for seconds specified by "second". Unlike pool_pause(), this + * function guarantees that it will sleep for specified seconds. This + * function uses pool_pause() internally. If it informs that there is + * a pending signal event, they are processed using CHECK_REQUEST + * macro. Note that most of these processes are done while all signals + * are blocked. + */ +static void pool_sleep(unsigned int second) +{ + struct timeval current_time, sleep_time; + + gettimeofday(¤t_time, NULL); + sleep_time.tv_sec = second + current_time.tv_sec; + sleep_time.tv_usec = current_time.tv_usec; + + POOL_SETMASK(&UnBlockSig); + while (sleep_time.tv_sec > current_time.tv_sec) + { + struct timeval timeout; + int r; + + timeout.tv_sec = sleep_time.tv_sec - current_time.tv_sec; + timeout.tv_usec = sleep_time.tv_usec - current_time.tv_usec; + if (timeout.tv_usec < 0) + { + timeout.tv_sec--; + timeout.tv_usec += 1000000; + } + + r = pool_pause(&timeout); + POOL_SETMASK(&BlockSig); + if (r > 0) + CHECK_REQUEST; + POOL_SETMASK(&UnBlockSig); + gettimeofday(¤t_time, NULL); + } + POOL_SETMASK(&BlockSig); +} + +/* + * get_config_file_name: return full path of pgpool.conf. + */ +char *get_config_file_name(void) +{ + return conf_file; +} + +/* + * get_config_file_name: return full path of pool_hba.conf. + */ +char *get_hba_file_name(void) +{ + return hba_file; +} + +/* + * trigger_failover_command: execute specified command at failover. + * command_line is null-terminated string. + */ +static int trigger_failover_command(int node, const char *command_line) +{ + int r = 0; + String *exec_cmd; + char port_buf[6]; + char buf[2]; + BackendInfo *info; + + if (command_line == NULL || (strlen(command_line) == 0)) + return 0; + + /* check nodeID */ + if (node < 0 || node > NUM_BACKENDS) + return -1; + + info = pool_get_node_info(node); + if (!info) + return -1; + + buf[1] = '\0'; + pool_memory = pool_memory_create(PREPARE_BLOCK_SIZE); + if (!pool_memory) + { + pool_error("trigger_failover_command: pool_memory_create() failed"); + return -1; + } + exec_cmd = init_string(""); + + while (*command_line) + { + if (*command_line == '%') + { + if (*(command_line + 1)) + { + char val = *(command_line + 1); + switch (val) + { + case 'p': /* port */ + snprintf(port_buf, sizeof(port_buf), "%d", info->backend_port); + string_append_char(exec_cmd, port_buf); + break; + + case 'D': /* database directory */ + string_append_char(exec_cmd, info->backend_data_directory); + break; + + case 'd': /* node id */ + snprintf(port_buf, sizeof(port_buf), "%d", node); + string_append_char(exec_cmd, port_buf); + break; + + case 'h': /* host name */ + string_append_char(exec_cmd, info->backend_hostname); + break; + + case 'm': /* new master node id */ + snprintf(port_buf, sizeof(port_buf), "%d", get_next_master_node()); + string_append_char(exec_cmd, port_buf); + break; + + case 'M': /* old master node id */ + snprintf(port_buf, sizeof(port_buf), "%d", MASTER_NODE_ID); + string_append_char(exec_cmd, port_buf); + break; + + case '%': /* escape */ + string_append_char(exec_cmd, "%"); + break; + + default: /* ignore */ + break; + } + command_line++; + } + } else { + buf[0] = *command_line; + string_append_char(exec_cmd, buf); + } + command_line++; + } + + if (strlen(exec_cmd->data) != 0) + { + pool_log("execute command: %s", exec_cmd->data); + r = system(exec_cmd->data); + } + + pool_memory_delete(pool_memory, 0); + pool_memory = NULL; + + return r; +} diff --git a/md5.c b/md5.c new file mode 100644 index 0000000..6f95c72 --- /dev/null +++ b/md5.c @@ -0,0 +1,405 @@ +/* + * md5.c + * + * Implements the MD5 Message-Digest Algorithm as specified in + * RFC 1321. This implementation is a simple one, in that it + * needs every input byte to be buffered before doing any + * calculations. I do not expect this file to be used for + * general purpose MD5'ing of large amounts of data, only for + * generating hashed passwords from limited input. + * + * Sverre H. Huseby + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * This file is imported from PostgreSQL 8.1.3., and modified by + * Taiki Yamaguchi + * + * IDENTIFICATION + * $Header: /cvsroot/pgpool/pgpool-II/md5.c,v 1.1.1.1.6.1 2009/08/22 04:19:49 t-ishii Exp $ + */ + +#include +#include +#include +#include + +#include "md5.h" + +typedef unsigned char uint8; /* == 8 bits */ +typedef unsigned int uint32; /* == 32 bits */ + +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + +#define FF(a, b, c, d, x, s, ac) { \ +(a) += F((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define GG(a, b, c, d, x, s, ac) { \ +(a) += G((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define HH(a, b, c, d, x, s, ac) { \ +(a) += H((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define II(a, b, c, d, x, s, ac) { \ +(a) += I((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +const uint32 T[64] = +{ + 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, + + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, + + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, + + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 +}; + + +/* + * PRIVATE FUNCTIONS + */ + + +/* + * The returned array is allocated using malloc. the caller should free it + * when it is no longer needed. + */ +static uint8 * +createPaddedCopyWithLength(uint8 *b, uint32 *l) +{ + /* + * uint8 *b - message to be digested + * uint32 *l - length of b + */ + uint8 *ret; + uint32 q; + uint32 len, + newLen448; + uint32 len_high, + len_low; /* 64-bit value split into 32-bit sections */ + + len = ((b == NULL) ? 0 : *l); + newLen448 = len + 64 - (len % 64) - 8; + if (newLen448 <= len) + newLen448 += 64; + + *l = newLen448 + 8; + if ((ret = (uint8 *) malloc(sizeof(uint8) * *l)) == NULL) + return NULL; + + if (b != NULL) + memcpy(ret, b, sizeof(uint8) * len); + + /* pad */ + ret[len] = 0x80; + for (q = len + 1; q < newLen448; q++) + ret[q] = 0x00; + + /* append length as a 64 bit bitcount */ + len_low = len; + /* split into two 32-bit values */ + /* we only look at the bottom 32-bits */ + len_high = len >> 29; + len_low <<= 3; + q = newLen448; + ret[q++] = (len_low & 0xff); + len_low >>= 8; + ret[q++] = (len_low & 0xff); + len_low >>= 8; + ret[q++] = (len_low & 0xff); + len_low >>= 8; + ret[q++] = (len_low & 0xff); + ret[q++] = (len_high & 0xff); + len_high >>= 8; + ret[q++] = (len_high & 0xff); + len_high >>= 8; + ret[q++] = (len_high & 0xff); + len_high >>= 8; + ret[q] = (len_high & 0xff); + + return ret; +} + +static void +doTheRounds(uint32 X[16], uint32 state[4]) +{ + uint32 a, + b, + c, + d; + + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + + /* round 1 */ + FF(a, b, c, d, X[ 0], S11, T[ 0]); + FF(d, a, b, c, X[ 1], S12, T[ 1]); + FF(c, d, a, b, X[ 2], S13, T[ 2]); + FF(b, c, d, a, X[ 3], S14, T[ 3]); + FF(a, b, c, d, X[ 4], S11, T[ 4]); + FF(d, a, b, c, X[ 5], S12, T[ 5]); + FF(c, d, a, b, X[ 6], S13, T[ 6]); + FF(b, c, d, a, X[ 7], S14, T[ 7]); + FF(a, b, c, d, X[ 8], S11, T[ 8]); + FF(d, a, b, c, X[ 9], S12, T[ 9]); + FF(c, d, a, b, X[10], S13, T[10]); + FF(b, c, d, a, X[11], S14, T[11]); + FF(a, b, c, d, X[12], S11, T[12]); + FF(d, a, b, c, X[13], S12, T[13]); + FF(c, d, a, b, X[14], S13, T[14]); + FF(b, c, d, a, X[15], S14, T[15]); + + GG(a, b, c, d, X[ 1], S21, T[16]); + GG(d, a, b, c, X[ 6], S22, T[17]); + GG(c, d, a, b, X[11], S23, T[18]); + GG(b, c, d, a, X[ 0], S24, T[19]); + GG(a, b, c, d, X[ 5], S21, T[20]); + GG(d, a, b, c, X[10], S22, T[21]); + GG(c, d, a, b, X[15], S23, T[22]); + GG(b, c, d, a, X[ 4], S24, T[23]); + GG(a, b, c, d, X[ 9], S21, T[24]); + GG(d, a, b, c, X[14], S22, T[25]); + GG(c, d, a, b, X[ 3], S23, T[26]); + GG(b, c, d, a, X[ 8], S24, T[27]); + GG(a, b, c, d, X[13], S21, T[28]); + GG(d, a, b, c, X[ 2], S22, T[29]); + GG(c, d, a, b, X[ 7], S23, T[30]); + GG(b, c, d, a, X[12], S24, T[31]); + + HH(a, b, c, d, X[ 5], S31, T[32]); + HH(d, a, b, c, X[ 8], S32, T[33]); + HH(c, d, a, b, X[11], S33, T[34]); + HH(b, c, d, a, X[14], S34, T[35]); + HH(a, b, c, d, X[ 1], S31, T[36]); + HH(d, a, b, c, X[ 4], S32, T[37]); + HH(c, d, a, b, X[ 7], S33, T[38]); + HH(b, c, d, a, X[10], S34, T[39]); + HH(a, b, c, d, X[13], S31, T[40]); + HH(d, a, b, c, X[ 0], S32, T[41]); + HH(c, d, a, b, X[ 3], S33, T[42]); + HH(b, c, d, a, X[ 6], S34, T[43]); + HH(a, b, c, d, X[ 9], S31, T[44]); + HH(d, a, b, c, X[12], S32, T[45]); + HH(c, d, a, b, X[15], S33, T[46]); + HH(b, c, d, a, X[ 2], S34, T[47]); + + II(a, b, c, d, X[ 0], S41, T[48]); + II(d, a, b, c, X[ 7], S42, T[49]); + II(c, d, a, b, X[14], S43, T[50]); + II(b, c, d, a, X[ 5], S44, T[51]); + II(a, b, c, d, X[12], S41, T[52]); + II(d, a, b, c, X[ 3], S42, T[53]); + II(c, d, a, b, X[10], S43, T[54]); + II(b, c, d, a, X[ 1], S44, T[55]); + II(a, b, c, d, X[ 8], S41, T[56]); + II(d, a, b, c, X[15], S42, T[57]); + II(c, d, a, b, X[ 6], S43, T[58]); + II(b, c, d, a, X[13], S44, T[59]); + II(a, b, c, d, X[ 4], S41, T[60]); + II(d, a, b, c, X[11], S42, T[61]); + II(c, d, a, b, X[ 2], S43, T[62]); + II(b, c, d, a, X[ 9], S44, T[63]); + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; +} + +static int +calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16]) +{ + /* + * uint8 *b - message to be digested + * uint32 len - length of b + * uint8 sum[16] - md5 digest calculated from b + */ + + register uint32 i, + j, + k, + newI; + uint32 l; + uint8 *input; + register uint32 *wbp; + uint32 workBuff[16], + state[4]; + + l = len; + + state[0] = 0x67452301; + state[1] = 0xEFCDAB89; + state[2] = 0x98BADCFE; + state[3] = 0x10325476; + + if ((input = createPaddedCopyWithLength(b, &l)) == NULL) + return 0; + + for (i = 0;;) + { + if ((newI = i + 16 * 4) > l) + break; + k = i + 3; + for (j = 0; j < 16; j++) + { + wbp = (workBuff + j); + *wbp = input[k--]; + *wbp <<= 8; + *wbp |= input[k--]; + *wbp <<= 8; + *wbp |= input[k--]; + *wbp <<= 8; + *wbp |= input[k]; + k += 7; + } + doTheRounds(workBuff, state); + i = newI; + } + free(input); + + j = 0; + for (i = 0; i < 4; i++) + { + k = state[i]; + sum[j++] = (k & 0xff); + k >>= 8; + sum[j++] = (k & 0xff); + k >>= 8; + sum[j++] = (k & 0xff); + k >>= 8; + sum[j++] = (k & 0xff); + } + return 1; +} + +static void +bytesToHex(uint8 b[16], char *s) +{ + static const char *hex = "0123456789abcdef"; + int q, + w; + + for (q = 0, w = 0; q < 16; q++) + { + s[w++] = hex[(b[q] >> 4) & 0x0F]; + s[w++] = hex[b[q] & 0x0F]; + } + s[w] = '\0'; +} + +/* + * PUBLIC FUNCTIONS + */ + +/* + * pool_md5_hash + * + * Calculates the MD5 sum of the bytes in a buffer. + * + * SYNOPSIS int pool_md5_hash(const void *buff, size_t len, char *hexsum) + * + * INPUT buff the buffer containing the bytes that you want + * the MD5 sum of. + * len number of bytes in the buffer. + * + * OUTPUT hexsum the MD5 sum as a '\0'-terminated string of + * hexadecimal digits. an MD5 sum is 16 bytes long. + * each byte is represented by two heaxadecimal + * characters. you thus need to provide an array + * of 33 characters, including the trailing '\0'. + * + * RETURNS false on failure (out of memory for internal buffers) or + * true on success. + * + * STANDARDS MD5 is described in RFC 1321. + * + * AUTHOR Sverre H. Huseby + * MODIFIED by Taiki Yamaguchi + * + */ +int +pool_md5_hash(const void *buff, size_t len, char *hexsum) +{ + uint8 sum[16]; + + if (!calculateDigestFromBuffer((uint8 *) buff, len, sum)) + return 0; /* failed */ + + bytesToHex(sum, hexsum); + return 1; /* success */ +} + +/* + * Computes MD5 checksum of "passwd" (a null-terminated string) followed + * by "salt" (which need not be null-terminated). + * + * Output format is a 32-hex-digit MD5 checksum. + * Hence, the output buffer "buf" must be at least 33 bytes long. + * + * Returns 1 if okay, 0 on error (out of memory). + */ +int +pool_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, + char *buf) +{ + size_t passwd_len = strlen(passwd); + char *crypt_buf = malloc(passwd_len + salt_len); + int ret; + + if (!crypt_buf) + return 0; /* failed */ + + /* + * Place salt at the end because it may be known by users trying to crack + * the MD5 output. + */ + strcpy(crypt_buf, passwd); + memcpy(crypt_buf + passwd_len, salt, salt_len); + + ret = pool_md5_hash(crypt_buf, passwd_len + salt_len, buf); + + free(crypt_buf); + + return ret; +} diff --git a/md5.h b/md5.h new file mode 100644 index 0000000..9f31024 --- /dev/null +++ b/md5.h @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + * + * md5.h + * Interface to md5.c + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $Header: /cvsroot/pgpool/pgpool-II/md5.h,v 1.1.1.1 2006/09/08 03:36:04 t-ishii Exp $ + * + *------------------------------------------------------------------------- + */ + +/* + * This file is imported from PostgreSQL 8.1.3. + * Modified by Taiki Yamaguchi + */ + +#ifndef MD5_H +#define MD5_H + +#define MD5_PASSWD_LEN 32 + +extern int pool_md5_hash(const void *buff, size_t len, char *hexsum); +extern int pool_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, char *buf); + +#endif diff --git a/missing b/missing new file mode 100755 index 0000000..e7ef83a --- /dev/null +++ b/missing @@ -0,0 +1,360 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2003-09-02.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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, 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 0000000..0bad307 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1.1.1 2006/09/08 03:36:02 t-ishii Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/parser/Makefile.am b/parser/Makefile.am new file mode 100644 index 0000000..d44a740 --- /dev/null +++ b/parser/Makefile.am @@ -0,0 +1,13 @@ +noinst_LIBRARIES = libsql-parser.a + +libsql_parser_a_SOURCES = gram.y gramparse.h list.c makefuncs.c makefuncs.h memnodes.h nodes.h nodes.c parsenodes.h parser.c parser.h pg_list.h pool_memory.c pool_memory.h pool_string.c pool_string.h primnodes.h scansup.h value.c value.h keywords.h keywords.c pool_parser.h outfuncs.c copyfuncs.c + +EXTRA_DIST = scan.c scan.l + +AM_CPPFLAGS = -D_GNU_SOURCE -I .. -I @PGSQL_INCLUDE_DIR@ + +AM_YFLAGS = -d + +gram.c: gram.y scan.c +scan.c: scan.l + $(LEX) -o'scan.c' $< diff --git a/parser/Makefile.in b/parser/Makefile.in new file mode 100644 index 0000000..ca0cd55 --- /dev/null +++ b/parser/Makefile.in @@ -0,0 +1,478 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = parser +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in gram.c \ + gram.h +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/ac_func_accept_argtypes.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libsql_parser_a_AR = $(AR) $(ARFLAGS) +libsql_parser_a_LIBADD = +am_libsql_parser_a_OBJECTS = gram.$(OBJEXT) list.$(OBJEXT) \ + makefuncs.$(OBJEXT) nodes.$(OBJEXT) parser.$(OBJEXT) \ + pool_memory.$(OBJEXT) pool_string.$(OBJEXT) value.$(OBJEXT) \ + keywords.$(OBJEXT) outfuncs.$(OBJEXT) copyfuncs.$(OBJEXT) +libsql_parser_a_OBJECTS = $(am_libsql_parser_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) --mode=compile $(YACC) $(YFLAGS) \ + $(AM_YFLAGS) +SOURCES = $(libsql_parser_a_SOURCES) +DIST_SOURCES = $(libsql_parser_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PGCONFIG = @PGCONFIG@ +PGSQL_INCLUDE_DIR = @PGSQL_INCLUDE_DIR@ +PGSQL_LIB_DIR = @PGSQL_LIB_DIR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +YACC = @YACC@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +enable_rpath_FALSE = @enable_rpath_FALSE@ +enable_rpath_TRUE = @enable_rpath_TRUE@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +noinst_LIBRARIES = libsql-parser.a +libsql_parser_a_SOURCES = gram.y gramparse.h list.c makefuncs.c makefuncs.h memnodes.h nodes.h nodes.c parsenodes.h parser.c parser.h pg_list.h pool_memory.c pool_memory.h pool_string.c pool_string.h primnodes.h scansup.h value.c value.h keywords.h keywords.c pool_parser.h outfuncs.c copyfuncs.c +EXTRA_DIST = scan.c scan.l +AM_CPPFLAGS = -D_GNU_SOURCE -I .. -I @PGSQL_INCLUDE_DIR@ +AM_YFLAGS = -d +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj .y +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu parser/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu parser/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +gram.h: gram.c + @if test ! -f $@; then \ + rm -f gram.c; \ + $(MAKE) gram.c; \ + else :; fi +libsql-parser.a: $(libsql_parser_a_OBJECTS) $(libsql_parser_a_DEPENDENCIES) + -rm -f libsql-parser.a + $(libsql_parser_a_AR) libsql-parser.a $(libsql_parser_a_OBJECTS) $(libsql_parser_a_LIBADD) + $(RANLIB) libsql-parser.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copyfuncs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gram.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keywords.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/makefuncs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nodes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/outfuncs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_memory.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_string.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/value.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +.y.c: + $(YACCCOMPILE) $< + if test -f y.tab.h; then \ + to=`echo "$*_H" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \ + sed -e "/^#/!b" -e "s/Y_TAB_H/$$to/g" -e "s|y\.tab\.h|$*.h|" \ + y.tab.h >$*.ht; \ + rm -f y.tab.h; \ + if cmp -s $*.ht $*.h; then \ + rm -f $*.ht ;\ + else \ + mv $*.ht $*.h; \ + fi; \ + fi + if test -f y.output; then \ + mv y.output $*.output; \ + fi + sed '/^#/ s|y\.tab\.c|$@|' y.tab.c >$@t && mv $@t $@ + rm -f y.tab.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f gram.c + -rm -f gram.h +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + + +gram.c: gram.y scan.c +scan.c: scan.l + $(LEX) -o'scan.c' $< +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/parser/copyfuncs.c b/parser/copyfuncs.c new file mode 100644 index 0000000..961c340 --- /dev/null +++ b/parser/copyfuncs.c @@ -0,0 +1,2730 @@ +/*------------------------------------------------------------------------- + * + * copyfuncs.c + * Copy functions for Postgres tree nodes. + * + * NOTE: we currently support copying all node types found in parse and + * plan trees. We do not support copying executor state trees; there + * is no need for that, and no point in maintaining all the code that + * would be needed. We also do not support copying Path trees, mainly + * because the circular linkages between RelOptInfo and Path nodes can't + * be handled easily in a simple depth-first traversal. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.382 2007/09/03 18:46:30 tgl Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pool.h" + +#include +#include "pool_memory.h" +#include "parsenodes.h" + + +/* + * Macros to simplify copying of different kinds of fields. Use these + * wherever possible to reduce the chance for silly typos. Note that these + * hard-wire the convention that the local variables in a Copy routine are + * named 'newnode' and 'from'. + */ + +/* Copy a simple scalar field (int, float, bool, enum, etc) */ +#define COPY_SCALAR_FIELD(fldname) \ + (newnode->fldname = from->fldname) + +/* Copy a field that is a pointer to some kind of Node or Node tree */ +#define COPY_NODE_FIELD(fldname) \ + (newnode->fldname = copyObject(from->fldname)) + +/* Copy a field that is a pointer to a Bitmapset */ +#define COPY_BITMAPSET_FIELD(fldname) \ + (newnode->fldname = bms_copy(from->fldname)) + +/* Copy a field that is a pointer to a C string, or perhaps NULL */ +#define COPY_STRING_FIELD(fldname) \ + (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL) + +/* Copy a field that is a pointer to a simple palloc'd object of size sz */ +#define COPY_POINTER_FIELD(fldname, sz) \ + do { \ + Size _size = (sz); \ + newnode->fldname = palloc(_size); \ + memcpy(newnode->fldname, from->fldname, _size); \ + } while (0) + + +/* **************************************************************** + * primnodes.h copy functions + * **************************************************************** + */ + +/* + * _copyAlias + */ +static Alias * +_copyAlias(Alias *from) +{ + Alias *newnode = makeNode(Alias); + + COPY_STRING_FIELD(aliasname); + COPY_NODE_FIELD(colnames); + + return newnode; +} + +/* + * _copyRangeVar + */ +static RangeVar * +_copyRangeVar(RangeVar *from) +{ + RangeVar *newnode = makeNode(RangeVar); + + COPY_STRING_FIELD(catalogname); + COPY_STRING_FIELD(schemaname); + COPY_STRING_FIELD(relname); + COPY_SCALAR_FIELD(inhOpt); + COPY_SCALAR_FIELD(istemp); + COPY_NODE_FIELD(alias); + + return newnode; +} + +/* + * _copyIntoClause + */ +static IntoClause * +_copyIntoClause(IntoClause *from) +{ + IntoClause *newnode = makeNode(IntoClause); + + COPY_NODE_FIELD(rel); + COPY_NODE_FIELD(colNames); + COPY_NODE_FIELD(options); + COPY_SCALAR_FIELD(onCommit); + COPY_STRING_FIELD(tableSpaceName); + + return newnode; +} + +/* + * We don't need a _copyExpr because Expr is an abstract supertype which + * should never actually get instantiated. Also, since it has no common + * fields except NodeTag, there's no need for a helper routine to factor + * out copying the common fields... + */ + +/* + * _copyVar + */ +static Var * +_copyVar(Var *from) +{ + Var *newnode = makeNode(Var); + + COPY_SCALAR_FIELD(varno); + COPY_SCALAR_FIELD(varattno); + COPY_SCALAR_FIELD(vartype); + COPY_SCALAR_FIELD(vartypmod); + COPY_SCALAR_FIELD(varlevelsup); + COPY_SCALAR_FIELD(varnoold); + COPY_SCALAR_FIELD(varoattno); + + return newnode; +} + +/* + * _copyConst + */ +#if 0 +static Const * +_copyConst(Const *from) +{ + Const *newnode = makeNode(Const); + + COPY_SCALAR_FIELD(consttype); + COPY_SCALAR_FIELD(consttypmod); + COPY_SCALAR_FIELD(constlen); + + if (from->constbyval || from->constisnull) + { + /* + * passed by value so just copy the datum. Also, don't try to copy + * struct when value is null! + */ + newnode->constvalue = from->constvalue; + } + else + { + /* + * passed by reference. We need a palloc'd copy. + */ + newnode->constvalue = datumCopy(from->constvalue, + from->constbyval, + from->constlen); + } + + COPY_SCALAR_FIELD(constisnull); + COPY_SCALAR_FIELD(constbyval); + + return newnode; +} +#endif + +/* + * _copyParam + */ +static Param * +_copyParam(Param *from) +{ + Param *newnode = makeNode(Param); + + COPY_SCALAR_FIELD(paramkind); + COPY_SCALAR_FIELD(paramid); + COPY_SCALAR_FIELD(paramtype); + COPY_SCALAR_FIELD(paramtypmod); + + return newnode; +} + +/* + * _copyAggref + */ +static Aggref * +_copyAggref(Aggref *from) +{ + Aggref *newnode = makeNode(Aggref); + + COPY_SCALAR_FIELD(aggfnoid); + COPY_SCALAR_FIELD(aggtype); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(agglevelsup); + COPY_SCALAR_FIELD(aggstar); + COPY_SCALAR_FIELD(aggdistinct); + + return newnode; +} + +/* + * _copyArrayRef + */ +static ArrayRef * +_copyArrayRef(ArrayRef *from) +{ + ArrayRef *newnode = makeNode(ArrayRef); + + COPY_SCALAR_FIELD(refarraytype); + COPY_SCALAR_FIELD(refelemtype); + COPY_SCALAR_FIELD(reftypmod); + COPY_NODE_FIELD(refupperindexpr); + COPY_NODE_FIELD(reflowerindexpr); + COPY_NODE_FIELD(refexpr); + COPY_NODE_FIELD(refassgnexpr); + + return newnode; +} + +/* + * _copyFuncExpr + */ +static FuncExpr * +_copyFuncExpr(FuncExpr *from) +{ + FuncExpr *newnode = makeNode(FuncExpr); + + COPY_SCALAR_FIELD(funcid); + COPY_SCALAR_FIELD(funcresulttype); + COPY_SCALAR_FIELD(funcretset); + COPY_SCALAR_FIELD(funcformat); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyOpExpr + */ +static OpExpr * +_copyOpExpr(OpExpr *from) +{ + OpExpr *newnode = makeNode(OpExpr); + + COPY_SCALAR_FIELD(opno); + COPY_SCALAR_FIELD(opfuncid); + COPY_SCALAR_FIELD(opresulttype); + COPY_SCALAR_FIELD(opretset); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyDistinctExpr (same as OpExpr) + */ +static DistinctExpr * +_copyDistinctExpr(DistinctExpr *from) +{ + DistinctExpr *newnode = makeNode(DistinctExpr); + + COPY_SCALAR_FIELD(opno); + COPY_SCALAR_FIELD(opfuncid); + COPY_SCALAR_FIELD(opresulttype); + COPY_SCALAR_FIELD(opretset); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyScalarArrayOpExpr + */ +static ScalarArrayOpExpr * +_copyScalarArrayOpExpr(ScalarArrayOpExpr *from) +{ + ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr); + + COPY_SCALAR_FIELD(opno); + COPY_SCALAR_FIELD(opfuncid); + COPY_SCALAR_FIELD(useOr); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyBoolExpr + */ +static BoolExpr * +_copyBoolExpr(BoolExpr *from) +{ + BoolExpr *newnode = makeNode(BoolExpr); + + COPY_SCALAR_FIELD(boolop); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copySubLink + */ +static SubLink * +_copySubLink(SubLink *from) +{ + SubLink *newnode = makeNode(SubLink); + + COPY_SCALAR_FIELD(subLinkType); + COPY_NODE_FIELD(testexpr); + COPY_NODE_FIELD(operName); + COPY_NODE_FIELD(subselect); + + return newnode; +} + +/* + * _copySubPlan + */ +static SubPlan * +_copySubPlan(SubPlan *from) +{ + SubPlan *newnode = makeNode(SubPlan); + + COPY_SCALAR_FIELD(subLinkType); + COPY_NODE_FIELD(testexpr); + COPY_NODE_FIELD(paramIds); + COPY_SCALAR_FIELD(plan_id); + COPY_SCALAR_FIELD(firstColType); + COPY_SCALAR_FIELD(useHashTable); + COPY_SCALAR_FIELD(unknownEqFalse); + COPY_NODE_FIELD(setParam); + COPY_NODE_FIELD(parParam); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyFieldSelect + */ +static FieldSelect * +_copyFieldSelect(FieldSelect *from) +{ + FieldSelect *newnode = makeNode(FieldSelect); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(fieldnum); + COPY_SCALAR_FIELD(resulttype); + COPY_SCALAR_FIELD(resulttypmod); + + return newnode; +} + +/* + * _copyFieldStore + */ +static FieldStore * +_copyFieldStore(FieldStore *from) +{ + FieldStore *newnode = makeNode(FieldStore); + + COPY_NODE_FIELD(arg); + COPY_NODE_FIELD(newvals); + COPY_NODE_FIELD(fieldnums); + COPY_SCALAR_FIELD(resulttype); + + return newnode; +} + +/* + * _copyRelabelType + */ +static RelabelType * +_copyRelabelType(RelabelType *from) +{ + RelabelType *newnode = makeNode(RelabelType); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(resulttype); + COPY_SCALAR_FIELD(resulttypmod); + COPY_SCALAR_FIELD(relabelformat); + + return newnode; +} + +/* + * _copyCoerceViaIO + */ +static CoerceViaIO * +_copyCoerceViaIO(CoerceViaIO *from) +{ + CoerceViaIO *newnode = makeNode(CoerceViaIO); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(resulttype); + COPY_SCALAR_FIELD(coerceformat); + + return newnode; +} + +/* + * _copyArrayCoerceExpr + */ +static ArrayCoerceExpr * +_copyArrayCoerceExpr(ArrayCoerceExpr *from) +{ + ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(elemfuncid); + COPY_SCALAR_FIELD(resulttype); + COPY_SCALAR_FIELD(resulttypmod); + COPY_SCALAR_FIELD(isExplicit); + COPY_SCALAR_FIELD(coerceformat); + + return newnode; +} + +/* + * _copyConvertRowtypeExpr + */ +static ConvertRowtypeExpr * +_copyConvertRowtypeExpr(ConvertRowtypeExpr *from) +{ + ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(resulttype); + COPY_SCALAR_FIELD(convertformat); + + return newnode; +} + +/* + * _copyCaseExpr + */ +static CaseExpr * +_copyCaseExpr(CaseExpr *from) +{ + CaseExpr *newnode = makeNode(CaseExpr); + + COPY_SCALAR_FIELD(casetype); + COPY_NODE_FIELD(arg); + COPY_NODE_FIELD(args); + COPY_NODE_FIELD(defresult); + + return newnode; +} + +/* + * _copyCaseWhen + */ +static CaseWhen * +_copyCaseWhen(CaseWhen *from) +{ + CaseWhen *newnode = makeNode(CaseWhen); + + COPY_NODE_FIELD(expr); + COPY_NODE_FIELD(result); + + return newnode; +} + +/* + * _copyCaseTestExpr + */ +static CaseTestExpr * +_copyCaseTestExpr(CaseTestExpr *from) +{ + CaseTestExpr *newnode = makeNode(CaseTestExpr); + + COPY_SCALAR_FIELD(typeId); + COPY_SCALAR_FIELD(typeMod); + + return newnode; +} + +/* + * _copyArrayExpr + */ +static ArrayExpr * +_copyArrayExpr(ArrayExpr *from) +{ + ArrayExpr *newnode = makeNode(ArrayExpr); + + COPY_SCALAR_FIELD(array_typeid); + COPY_SCALAR_FIELD(element_typeid); + COPY_NODE_FIELD(elements); + COPY_SCALAR_FIELD(multidims); + + return newnode; +} + +/* + * _copyRowExpr + */ +static RowExpr * +_copyRowExpr(RowExpr *from) +{ + RowExpr *newnode = makeNode(RowExpr); + + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(row_typeid); + COPY_SCALAR_FIELD(row_format); + + return newnode; +} + +/* + * _copyRowCompareExpr + */ +static RowCompareExpr * +_copyRowCompareExpr(RowCompareExpr *from) +{ + RowCompareExpr *newnode = makeNode(RowCompareExpr); + + COPY_SCALAR_FIELD(rctype); + COPY_NODE_FIELD(opnos); + COPY_NODE_FIELD(opfamilies); + COPY_NODE_FIELD(largs); + COPY_NODE_FIELD(rargs); + + return newnode; +} + +/* + * _copyCoalesceExpr + */ +static CoalesceExpr * +_copyCoalesceExpr(CoalesceExpr *from) +{ + CoalesceExpr *newnode = makeNode(CoalesceExpr); + + COPY_SCALAR_FIELD(coalescetype); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyMinMaxExpr + */ +static MinMaxExpr * +_copyMinMaxExpr(MinMaxExpr *from) +{ + MinMaxExpr *newnode = makeNode(MinMaxExpr); + + COPY_SCALAR_FIELD(minmaxtype); + COPY_SCALAR_FIELD(op); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyXmlExpr + */ +static XmlExpr * +_copyXmlExpr(XmlExpr *from) +{ + XmlExpr *newnode = makeNode(XmlExpr); + + COPY_SCALAR_FIELD(op); + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(named_args); + COPY_NODE_FIELD(arg_names); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(xmloption); + COPY_SCALAR_FIELD(type); + COPY_SCALAR_FIELD(typmod); + + return newnode; +} + +/* + * _copyNullIfExpr (same as OpExpr) + */ +static NullIfExpr * +_copyNullIfExpr(NullIfExpr *from) +{ + NullIfExpr *newnode = makeNode(NullIfExpr); + + COPY_SCALAR_FIELD(opno); + COPY_SCALAR_FIELD(opfuncid); + COPY_SCALAR_FIELD(opresulttype); + COPY_SCALAR_FIELD(opretset); + COPY_NODE_FIELD(args); + + return newnode; +} + +/* + * _copyNullTest + */ +static NullTest * +_copyNullTest(NullTest *from) +{ + NullTest *newnode = makeNode(NullTest); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(nulltesttype); + + return newnode; +} + +/* + * _copyBooleanTest + */ +static BooleanTest * +_copyBooleanTest(BooleanTest *from) +{ + BooleanTest *newnode = makeNode(BooleanTest); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(booltesttype); + + return newnode; +} + +/* + * _copyCoerceToDomain + */ +static CoerceToDomain * +_copyCoerceToDomain(CoerceToDomain *from) +{ + CoerceToDomain *newnode = makeNode(CoerceToDomain); + + COPY_NODE_FIELD(arg); + COPY_SCALAR_FIELD(resulttype); + COPY_SCALAR_FIELD(resulttypmod); + COPY_SCALAR_FIELD(coercionformat); + + return newnode; +} + +/* + * _copyCoerceToDomainValue + */ +static CoerceToDomainValue * +_copyCoerceToDomainValue(CoerceToDomainValue *from) +{ + CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue); + + COPY_SCALAR_FIELD(typeId); + COPY_SCALAR_FIELD(typeMod); + + return newnode; +} + +/* + * _copySetToDefault + */ +static SetToDefault * +_copySetToDefault(SetToDefault *from) +{ + SetToDefault *newnode = makeNode(SetToDefault); + + COPY_SCALAR_FIELD(typeId); + COPY_SCALAR_FIELD(typeMod); + + return newnode; +} + +/* + * _copyCurrentOfExpr + */ +static CurrentOfExpr * +_copyCurrentOfExpr(CurrentOfExpr *from) +{ + CurrentOfExpr *newnode = makeNode(CurrentOfExpr); + + COPY_SCALAR_FIELD(cvarno); + COPY_STRING_FIELD(cursor_name); + COPY_SCALAR_FIELD(cursor_param); + + return newnode; +} + +/* + * _copyTargetEntry + */ +static TargetEntry * +_copyTargetEntry(TargetEntry *from) +{ + TargetEntry *newnode = makeNode(TargetEntry); + + COPY_NODE_FIELD(expr); + COPY_SCALAR_FIELD(resno); + COPY_STRING_FIELD(resname); + COPY_SCALAR_FIELD(ressortgroupref); + COPY_SCALAR_FIELD(resorigtbl); + COPY_SCALAR_FIELD(resorigcol); + COPY_SCALAR_FIELD(resjunk); + + return newnode; +} + +/* + * _copyRangeTblRef + */ +static RangeTblRef * +_copyRangeTblRef(RangeTblRef *from) +{ + RangeTblRef *newnode = makeNode(RangeTblRef); + + COPY_SCALAR_FIELD(rtindex); + + return newnode; +} + +/* + * _copyJoinExpr + */ +static JoinExpr * +_copyJoinExpr(JoinExpr *from) +{ + JoinExpr *newnode = makeNode(JoinExpr); + + COPY_SCALAR_FIELD(jointype); + COPY_SCALAR_FIELD(isNatural); + COPY_NODE_FIELD(larg); + COPY_NODE_FIELD(rarg); + COPY_NODE_FIELD(using); + COPY_NODE_FIELD(quals); + COPY_NODE_FIELD(alias); + COPY_SCALAR_FIELD(rtindex); + + return newnode; +} + +/* + * _copyFromExpr + */ +static FromExpr * +_copyFromExpr(FromExpr *from) +{ + FromExpr *newnode = makeNode(FromExpr); + + COPY_NODE_FIELD(fromlist); + COPY_NODE_FIELD(quals); + + return newnode; +} + +/* **************************************************************** + * parsenodes.h copy functions + * **************************************************************** + */ + +static RangeTblEntry * +_copyRangeTblEntry(RangeTblEntry *from) +{ + RangeTblEntry *newnode = makeNode(RangeTblEntry); + + COPY_SCALAR_FIELD(rtekind); + COPY_SCALAR_FIELD(relid); + COPY_NODE_FIELD(subquery); + COPY_NODE_FIELD(funcexpr); + COPY_NODE_FIELD(funccoltypes); + COPY_NODE_FIELD(funccoltypmods); + COPY_NODE_FIELD(values_lists); + COPY_SCALAR_FIELD(jointype); + COPY_NODE_FIELD(joinaliasvars); + COPY_NODE_FIELD(alias); + COPY_NODE_FIELD(eref); + COPY_SCALAR_FIELD(inh); + COPY_SCALAR_FIELD(inFromCl); + COPY_SCALAR_FIELD(requiredPerms); + COPY_SCALAR_FIELD(checkAsUser); + + return newnode; +} + +static FkConstraint * +_copyFkConstraint(FkConstraint *from) +{ + FkConstraint *newnode = makeNode(FkConstraint); + + COPY_STRING_FIELD(constr_name); + COPY_NODE_FIELD(pktable); + COPY_NODE_FIELD(fk_attrs); + COPY_NODE_FIELD(pk_attrs); + COPY_SCALAR_FIELD(fk_matchtype); + COPY_SCALAR_FIELD(fk_upd_action); + COPY_SCALAR_FIELD(fk_del_action); + COPY_SCALAR_FIELD(deferrable); + COPY_SCALAR_FIELD(initdeferred); + COPY_SCALAR_FIELD(skip_validation); + + return newnode; +} + +static SortClause * +_copySortClause(SortClause *from) +{ + SortClause *newnode = makeNode(SortClause); + + COPY_SCALAR_FIELD(tleSortGroupRef); + COPY_SCALAR_FIELD(sortop); + COPY_SCALAR_FIELD(nulls_first); + + return newnode; +} + +static GroupClause * +_copyGroupClause(GroupClause *from) +{ + GroupClause *newnode = makeNode(GroupClause); + + COPY_SCALAR_FIELD(tleSortGroupRef); + COPY_SCALAR_FIELD(sortop); + COPY_SCALAR_FIELD(nulls_first); + + return newnode; +} + +static RowMarkClause * +_copyRowMarkClause(RowMarkClause *from) +{ + RowMarkClause *newnode = makeNode(RowMarkClause); + + COPY_SCALAR_FIELD(rti); + COPY_SCALAR_FIELD(forUpdate); + COPY_SCALAR_FIELD(noWait); + + return newnode; +} + +static A_Expr * +_copyAExpr(A_Expr *from) +{ + A_Expr *newnode = makeNode(A_Expr); + + COPY_SCALAR_FIELD(kind); + COPY_NODE_FIELD(name); + COPY_NODE_FIELD(lexpr); + COPY_NODE_FIELD(rexpr); + COPY_SCALAR_FIELD(location); + + return newnode; +} + +static ColumnRef * +_copyColumnRef(ColumnRef *from) +{ + ColumnRef *newnode = makeNode(ColumnRef); + + COPY_NODE_FIELD(fields); + COPY_SCALAR_FIELD(location); + + return newnode; +} + +static ParamRef * +_copyParamRef(ParamRef *from) +{ + ParamRef *newnode = makeNode(ParamRef); + + COPY_SCALAR_FIELD(number); + + return newnode; +} + +static A_Const * +_copyAConst(A_Const *from) +{ + A_Const *newnode = makeNode(A_Const); + + /* This part must duplicate _copyValue */ + COPY_SCALAR_FIELD(val.type); + switch (from->val.type) + { + case T_Integer: + COPY_SCALAR_FIELD(val.val.ival); + break; + case T_Float: + case T_String: + case T_BitString: + COPY_STRING_FIELD(val.val.str); + break; + case T_Null: + /* nothing to do */ + break; + default: + pool_error("unrecognized node type: %d", + (int) from->val.type); + break; + } + + COPY_NODE_FIELD(typename); + + return newnode; +} + +static FuncCall * +_copyFuncCall(FuncCall *from) +{ + FuncCall *newnode = makeNode(FuncCall); + + COPY_NODE_FIELD(funcname); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(agg_star); + COPY_SCALAR_FIELD(agg_distinct); + COPY_SCALAR_FIELD(location); + + return newnode; +} + +static A_Indices * +_copyAIndices(A_Indices *from) +{ + A_Indices *newnode = makeNode(A_Indices); + + COPY_NODE_FIELD(lidx); + COPY_NODE_FIELD(uidx); + + return newnode; +} + +static A_Indirection * +_copyA_Indirection(A_Indirection *from) +{ + A_Indirection *newnode = makeNode(A_Indirection); + + COPY_NODE_FIELD(arg); + COPY_NODE_FIELD(indirection); + + return newnode; +} + +static ResTarget * +_copyResTarget(ResTarget *from) +{ + ResTarget *newnode = makeNode(ResTarget); + + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(indirection); + COPY_NODE_FIELD(val); + COPY_SCALAR_FIELD(location); + + return newnode; +} + +static TypeName * +_copyTypeName(TypeName *from) +{ + TypeName *newnode = makeNode(TypeName); + + COPY_NODE_FIELD(names); + COPY_SCALAR_FIELD(typeid); + COPY_SCALAR_FIELD(timezone); + COPY_SCALAR_FIELD(setof); + COPY_SCALAR_FIELD(pct_type); + COPY_NODE_FIELD(typmods); + COPY_SCALAR_FIELD(typemod); + COPY_NODE_FIELD(arrayBounds); + COPY_SCALAR_FIELD(location); + + return newnode; +} + +static SortBy * +_copySortBy(SortBy *from) +{ + SortBy *newnode = makeNode(SortBy); + + COPY_SCALAR_FIELD(sortby_dir); + COPY_SCALAR_FIELD(sortby_nulls); + COPY_NODE_FIELD(useOp); + COPY_NODE_FIELD(node); + + return newnode; +} + +static RangeSubselect * +_copyRangeSubselect(RangeSubselect *from) +{ + RangeSubselect *newnode = makeNode(RangeSubselect); + + COPY_NODE_FIELD(subquery); + COPY_NODE_FIELD(alias); + + return newnode; +} + +static RangeFunction * +_copyRangeFunction(RangeFunction *from) +{ + RangeFunction *newnode = makeNode(RangeFunction); + + COPY_NODE_FIELD(funccallnode); + COPY_NODE_FIELD(alias); + COPY_NODE_FIELD(coldeflist); + + return newnode; +} + +static TypeCast * +_copyTypeCast(TypeCast *from) +{ + TypeCast *newnode = makeNode(TypeCast); + + COPY_NODE_FIELD(arg); + COPY_NODE_FIELD(typename); + + return newnode; +} + +static IndexElem * +_copyIndexElem(IndexElem *from) +{ + IndexElem *newnode = makeNode(IndexElem); + + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(expr); + COPY_NODE_FIELD(opclass); + COPY_SCALAR_FIELD(ordering); + COPY_SCALAR_FIELD(nulls_ordering); + + return newnode; +} + +static ColumnDef * +_copyColumnDef(ColumnDef *from) +{ + ColumnDef *newnode = makeNode(ColumnDef); + + COPY_STRING_FIELD(colname); + COPY_NODE_FIELD(typename); + COPY_SCALAR_FIELD(inhcount); + COPY_SCALAR_FIELD(is_local); + COPY_SCALAR_FIELD(is_not_null); + COPY_NODE_FIELD(raw_default); + COPY_STRING_FIELD(cooked_default); + COPY_NODE_FIELD(constraints); + + return newnode; +} + +static Constraint * +_copyConstraint(Constraint *from) +{ + Constraint *newnode = makeNode(Constraint); + + COPY_SCALAR_FIELD(contype); + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(raw_expr); + COPY_STRING_FIELD(cooked_expr); + COPY_NODE_FIELD(keys); + COPY_NODE_FIELD(options); + COPY_STRING_FIELD(indexspace); + + return newnode; +} + +static DefElem * +_copyDefElem(DefElem *from) +{ + DefElem *newnode = makeNode(DefElem); + + COPY_STRING_FIELD(defname); + COPY_NODE_FIELD(arg); + + return newnode; +} + +static LockingClause * +_copyLockingClause(LockingClause *from) +{ + LockingClause *newnode = makeNode(LockingClause); + + COPY_NODE_FIELD(lockedRels); + COPY_SCALAR_FIELD(forUpdate); + COPY_SCALAR_FIELD(noWait); + + return newnode; +} + +static XmlSerialize * +_copyXmlSerialize(XmlSerialize *from) +{ + XmlSerialize *newnode = makeNode(XmlSerialize); + + COPY_SCALAR_FIELD(xmloption); + COPY_NODE_FIELD(expr); + COPY_NODE_FIELD(typename); + + return newnode; +} + +static Query * +_copyQuery(Query *from) +{ + Query *newnode = makeNode(Query); + + COPY_SCALAR_FIELD(commandType); + COPY_SCALAR_FIELD(querySource); + COPY_SCALAR_FIELD(canSetTag); + COPY_NODE_FIELD(utilityStmt); + COPY_SCALAR_FIELD(resultRelation); + COPY_NODE_FIELD(intoClause); + COPY_SCALAR_FIELD(hasAggs); + COPY_SCALAR_FIELD(hasSubLinks); + COPY_NODE_FIELD(rtable); + COPY_NODE_FIELD(jointree); + COPY_NODE_FIELD(targetList); + COPY_NODE_FIELD(returningList); + COPY_NODE_FIELD(groupClause); + COPY_NODE_FIELD(havingQual); + COPY_NODE_FIELD(distinctClause); + COPY_NODE_FIELD(sortClause); + COPY_NODE_FIELD(limitOffset); + COPY_NODE_FIELD(limitCount); + COPY_NODE_FIELD(rowMarks); + COPY_NODE_FIELD(setOperations); + + return newnode; +} + +static InsertStmt * +_copyInsertStmt(InsertStmt *from) +{ + InsertStmt *newnode = makeNode(InsertStmt); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(cols); + COPY_NODE_FIELD(selectStmt); + COPY_NODE_FIELD(returningList); + + return newnode; +} + +static DeleteStmt * +_copyDeleteStmt(DeleteStmt *from) +{ + DeleteStmt *newnode = makeNode(DeleteStmt); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(usingClause); + COPY_NODE_FIELD(whereClause); + COPY_NODE_FIELD(returningList); + + return newnode; +} + +static UpdateStmt * +_copyUpdateStmt(UpdateStmt *from) +{ + UpdateStmt *newnode = makeNode(UpdateStmt); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(targetList); + COPY_NODE_FIELD(whereClause); + COPY_NODE_FIELD(fromClause); + COPY_NODE_FIELD(returningList); + + return newnode; +} + +static SelectStmt * +_copySelectStmt(SelectStmt *from) +{ + SelectStmt *newnode = makeNode(SelectStmt); + + COPY_NODE_FIELD(distinctClause); + COPY_NODE_FIELD(intoClause); + COPY_NODE_FIELD(targetList); + COPY_NODE_FIELD(fromClause); + COPY_NODE_FIELD(whereClause); + COPY_NODE_FIELD(groupClause); + COPY_NODE_FIELD(havingClause); + COPY_NODE_FIELD(valuesLists); + COPY_NODE_FIELD(sortClause); + COPY_NODE_FIELD(limitOffset); + COPY_NODE_FIELD(limitCount); + COPY_NODE_FIELD(lockingClause); + COPY_SCALAR_FIELD(op); + COPY_SCALAR_FIELD(all); + COPY_NODE_FIELD(larg); + COPY_NODE_FIELD(rarg); + + return newnode; +} + +static SetOperationStmt * +_copySetOperationStmt(SetOperationStmt *from) +{ + SetOperationStmt *newnode = makeNode(SetOperationStmt); + + COPY_SCALAR_FIELD(op); + COPY_SCALAR_FIELD(all); + COPY_NODE_FIELD(larg); + COPY_NODE_FIELD(rarg); + COPY_NODE_FIELD(colTypes); + COPY_NODE_FIELD(colTypmods); + + return newnode; +} + +static AlterTableStmt * +_copyAlterTableStmt(AlterTableStmt *from) +{ + AlterTableStmt *newnode = makeNode(AlterTableStmt); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(cmds); + COPY_SCALAR_FIELD(relkind); + + return newnode; +} + +static AlterTableCmd * +_copyAlterTableCmd(AlterTableCmd *from) +{ + AlterTableCmd *newnode = makeNode(AlterTableCmd); + + COPY_SCALAR_FIELD(subtype); + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(def); + COPY_NODE_FIELD(transform); + COPY_SCALAR_FIELD(behavior); + + return newnode; +} + +static AlterDomainStmt * +_copyAlterDomainStmt(AlterDomainStmt *from) +{ + AlterDomainStmt *newnode = makeNode(AlterDomainStmt); + + COPY_SCALAR_FIELD(subtype); + COPY_NODE_FIELD(typename); + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(def); + COPY_SCALAR_FIELD(behavior); + + return newnode; +} + +static GrantStmt * +_copyGrantStmt(GrantStmt *from) +{ + GrantStmt *newnode = makeNode(GrantStmt); + + COPY_SCALAR_FIELD(is_grant); + COPY_SCALAR_FIELD(objtype); + COPY_NODE_FIELD(objects); + COPY_NODE_FIELD(privileges); + COPY_NODE_FIELD(grantees); + COPY_SCALAR_FIELD(grant_option); + COPY_SCALAR_FIELD(behavior); + + return newnode; +} + +static PrivGrantee * +_copyPrivGrantee(PrivGrantee *from) +{ + PrivGrantee *newnode = makeNode(PrivGrantee); + + COPY_STRING_FIELD(rolname); + + return newnode; +} + +static FuncWithArgs * +_copyFuncWithArgs(FuncWithArgs *from) +{ + FuncWithArgs *newnode = makeNode(FuncWithArgs); + + COPY_NODE_FIELD(funcname); + COPY_NODE_FIELD(funcargs); + + return newnode; +} + +static GrantRoleStmt * +_copyGrantRoleStmt(GrantRoleStmt *from) +{ + GrantRoleStmt *newnode = makeNode(GrantRoleStmt); + + COPY_NODE_FIELD(granted_roles); + COPY_NODE_FIELD(grantee_roles); + COPY_SCALAR_FIELD(is_grant); + COPY_SCALAR_FIELD(admin_opt); + COPY_STRING_FIELD(grantor); + COPY_SCALAR_FIELD(behavior); + + return newnode; +} + +static DeclareCursorStmt * +_copyDeclareCursorStmt(DeclareCursorStmt *from) +{ + DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt); + + COPY_STRING_FIELD(portalname); + COPY_SCALAR_FIELD(options); + COPY_NODE_FIELD(query); + + return newnode; +} + +static ClosePortalStmt * +_copyClosePortalStmt(ClosePortalStmt *from) +{ + ClosePortalStmt *newnode = makeNode(ClosePortalStmt); + + COPY_STRING_FIELD(portalname); + + return newnode; +} + +static ClusterStmt * +_copyClusterStmt(ClusterStmt *from) +{ + ClusterStmt *newnode = makeNode(ClusterStmt); + + COPY_NODE_FIELD(relation); + COPY_STRING_FIELD(indexname); + + return newnode; +} + +static CopyStmt * +_copyCopyStmt(CopyStmt *from) +{ + CopyStmt *newnode = makeNode(CopyStmt); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(query); + COPY_NODE_FIELD(attlist); + COPY_SCALAR_FIELD(is_from); + COPY_STRING_FIELD(filename); + COPY_NODE_FIELD(options); + + return newnode; +} + +static CreateStmt * +_copyCreateStmt(CreateStmt *from) +{ + CreateStmt *newnode = makeNode(CreateStmt); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(tableElts); + COPY_NODE_FIELD(inhRelations); + COPY_NODE_FIELD(constraints); + COPY_NODE_FIELD(options); + COPY_SCALAR_FIELD(oncommit); + COPY_STRING_FIELD(tablespacename); + + return newnode; +} + +static InhRelation * +_copyInhRelation(InhRelation *from) +{ + InhRelation *newnode = makeNode(InhRelation); + + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(options); + + return newnode; +} + +static DefineStmt * +_copyDefineStmt(DefineStmt *from) +{ + DefineStmt *newnode = makeNode(DefineStmt); + + COPY_SCALAR_FIELD(kind); + COPY_SCALAR_FIELD(oldstyle); + COPY_NODE_FIELD(defnames); + COPY_NODE_FIELD(args); + COPY_NODE_FIELD(definition); + + return newnode; +} + +static DropStmt * +_copyDropStmt(DropStmt *from) +{ + DropStmt *newnode = makeNode(DropStmt); + + COPY_NODE_FIELD(objects); + COPY_SCALAR_FIELD(removeType); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static TruncateStmt * +_copyTruncateStmt(TruncateStmt *from) +{ + TruncateStmt *newnode = makeNode(TruncateStmt); + + COPY_NODE_FIELD(relations); + COPY_SCALAR_FIELD(behavior); + + return newnode; +} + +static CommentStmt * +_copyCommentStmt(CommentStmt *from) +{ + CommentStmt *newnode = makeNode(CommentStmt); + + COPY_SCALAR_FIELD(objtype); + COPY_NODE_FIELD(objname); + COPY_NODE_FIELD(objargs); + COPY_STRING_FIELD(comment); + + return newnode; +} + +static FetchStmt * +_copyFetchStmt(FetchStmt *from) +{ + FetchStmt *newnode = makeNode(FetchStmt); + + COPY_SCALAR_FIELD(direction); + COPY_SCALAR_FIELD(howMany); + COPY_STRING_FIELD(portalname); + COPY_SCALAR_FIELD(ismove); + + return newnode; +} + +static IndexStmt * +_copyIndexStmt(IndexStmt *from) +{ + IndexStmt *newnode = makeNode(IndexStmt); + + COPY_STRING_FIELD(idxname); + COPY_NODE_FIELD(relation); + COPY_STRING_FIELD(accessMethod); + COPY_STRING_FIELD(tableSpace); + COPY_NODE_FIELD(indexParams); + COPY_NODE_FIELD(options); + COPY_STRING_FIELD(src_options); + COPY_NODE_FIELD(whereClause); + COPY_SCALAR_FIELD(unique); + COPY_SCALAR_FIELD(primary); + COPY_SCALAR_FIELD(isconstraint); + COPY_SCALAR_FIELD(concurrent); + + return newnode; +} + +static CreateFunctionStmt * +_copyCreateFunctionStmt(CreateFunctionStmt *from) +{ + CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt); + + COPY_SCALAR_FIELD(replace); + COPY_NODE_FIELD(funcname); + COPY_NODE_FIELD(parameters); + COPY_NODE_FIELD(returnType); + COPY_NODE_FIELD(options); + COPY_NODE_FIELD(withClause); + + return newnode; +} + +static FunctionParameter * +_copyFunctionParameter(FunctionParameter *from) +{ + FunctionParameter *newnode = makeNode(FunctionParameter); + + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(argType); + COPY_SCALAR_FIELD(mode); + + return newnode; +} + +static AlterFunctionStmt * +_copyAlterFunctionStmt(AlterFunctionStmt *from) +{ + AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt); + + COPY_NODE_FIELD(func); + COPY_NODE_FIELD(actions); + + return newnode; +} + +static RemoveFuncStmt * +_copyRemoveFuncStmt(RemoveFuncStmt *from) +{ + RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt); + + COPY_SCALAR_FIELD(kind); + COPY_NODE_FIELD(name); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static RemoveOpClassStmt * +_copyRemoveOpClassStmt(RemoveOpClassStmt *from) +{ + RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt); + + COPY_NODE_FIELD(opclassname); + COPY_STRING_FIELD(amname); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static RemoveOpFamilyStmt * +_copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from) +{ + RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt); + + COPY_NODE_FIELD(opfamilyname); + COPY_STRING_FIELD(amname); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static RenameStmt * +_copyRenameStmt(RenameStmt *from) +{ + RenameStmt *newnode = makeNode(RenameStmt); + + COPY_SCALAR_FIELD(renameType); + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(object); + COPY_NODE_FIELD(objarg); + COPY_STRING_FIELD(subname); + COPY_STRING_FIELD(newname); + + return newnode; +} + +static AlterObjectSchemaStmt * +_copyAlterObjectSchemaStmt(AlterObjectSchemaStmt *from) +{ + AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt); + + COPY_SCALAR_FIELD(objectType); + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(object); + COPY_NODE_FIELD(objarg); + COPY_STRING_FIELD(addname); + COPY_STRING_FIELD(newschema); + + return newnode; +} + +static AlterOwnerStmt * +_copyAlterOwnerStmt(AlterOwnerStmt *from) +{ + AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt); + + COPY_SCALAR_FIELD(objectType); + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(object); + COPY_NODE_FIELD(objarg); + COPY_STRING_FIELD(addname); + COPY_STRING_FIELD(newowner); + + return newnode; +} + +static RuleStmt * +_copyRuleStmt(RuleStmt *from) +{ + RuleStmt *newnode = makeNode(RuleStmt); + + COPY_NODE_FIELD(relation); + COPY_STRING_FIELD(rulename); + COPY_NODE_FIELD(whereClause); + COPY_SCALAR_FIELD(event); + COPY_SCALAR_FIELD(instead); + COPY_NODE_FIELD(actions); + COPY_SCALAR_FIELD(replace); + + return newnode; +} + +static NotifyStmt * +_copyNotifyStmt(NotifyStmt *from) +{ + NotifyStmt *newnode = makeNode(NotifyStmt); + + COPY_NODE_FIELD(relation); + + return newnode; +} + +static ListenStmt * +_copyListenStmt(ListenStmt *from) +{ + ListenStmt *newnode = makeNode(ListenStmt); + + COPY_NODE_FIELD(relation); + + return newnode; +} + +static UnlistenStmt * +_copyUnlistenStmt(UnlistenStmt *from) +{ + UnlistenStmt *newnode = makeNode(UnlistenStmt); + + COPY_NODE_FIELD(relation); + + return newnode; +} + +static TransactionStmt * +_copyTransactionStmt(TransactionStmt *from) +{ + TransactionStmt *newnode = makeNode(TransactionStmt); + + COPY_SCALAR_FIELD(kind); + COPY_NODE_FIELD(options); + COPY_STRING_FIELD(gid); + + return newnode; +} + +static CompositeTypeStmt * +_copyCompositeTypeStmt(CompositeTypeStmt *from) +{ + CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt); + + COPY_NODE_FIELD(typevar); + COPY_NODE_FIELD(coldeflist); + + return newnode; +} + +static CreateEnumStmt * +_copyCreateEnumStmt(CreateEnumStmt *from) +{ + CreateEnumStmt *newnode = makeNode(CreateEnumStmt); + + COPY_NODE_FIELD(typename); + COPY_NODE_FIELD(vals); + + return newnode; +} + +static ViewStmt * +_copyViewStmt(ViewStmt *from) +{ + ViewStmt *newnode = makeNode(ViewStmt); + + COPY_NODE_FIELD(view); + COPY_NODE_FIELD(aliases); + COPY_NODE_FIELD(query); + COPY_SCALAR_FIELD(replace); + + return newnode; +} + +static LoadStmt * +_copyLoadStmt(LoadStmt *from) +{ + LoadStmt *newnode = makeNode(LoadStmt); + + COPY_STRING_FIELD(filename); + + return newnode; +} + +static CreateDomainStmt * +_copyCreateDomainStmt(CreateDomainStmt *from) +{ + CreateDomainStmt *newnode = makeNode(CreateDomainStmt); + + COPY_NODE_FIELD(domainname); + COPY_NODE_FIELD(typename); + COPY_NODE_FIELD(constraints); + + return newnode; +} + +static CreateOpClassStmt * +_copyCreateOpClassStmt(CreateOpClassStmt *from) +{ + CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt); + + COPY_NODE_FIELD(opclassname); + COPY_NODE_FIELD(opfamilyname); + COPY_STRING_FIELD(amname); + COPY_NODE_FIELD(datatype); + COPY_NODE_FIELD(items); + COPY_SCALAR_FIELD(isDefault); + + return newnode; +} + +static CreateOpClassItem * +_copyCreateOpClassItem(CreateOpClassItem *from) +{ + CreateOpClassItem *newnode = makeNode(CreateOpClassItem); + + COPY_SCALAR_FIELD(itemtype); + COPY_NODE_FIELD(name); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(number); + COPY_SCALAR_FIELD(recheck); + COPY_NODE_FIELD(class_args); + COPY_NODE_FIELD(storedtype); + + return newnode; +} + +static CreateOpFamilyStmt * +_copyCreateOpFamilyStmt(CreateOpFamilyStmt *from) +{ + CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt); + + COPY_NODE_FIELD(opfamilyname); + COPY_STRING_FIELD(amname); + + return newnode; +} + +static AlterOpFamilyStmt * +_copyAlterOpFamilyStmt(AlterOpFamilyStmt *from) +{ + AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt); + + COPY_NODE_FIELD(opfamilyname); + COPY_STRING_FIELD(amname); + COPY_SCALAR_FIELD(isDrop); + COPY_NODE_FIELD(items); + + return newnode; +} + +static CreatedbStmt * +_copyCreatedbStmt(CreatedbStmt *from) +{ + CreatedbStmt *newnode = makeNode(CreatedbStmt); + + COPY_STRING_FIELD(dbname); + COPY_NODE_FIELD(options); + + return newnode; +} + +static AlterDatabaseStmt * +_copyAlterDatabaseStmt(AlterDatabaseStmt *from) +{ + AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt); + + COPY_STRING_FIELD(dbname); + COPY_NODE_FIELD(options); + + return newnode; +} + +static AlterDatabaseSetStmt * +_copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from) +{ + AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt); + + COPY_STRING_FIELD(dbname); + COPY_NODE_FIELD(setstmt); + + return newnode; +} + +static DropdbStmt * +_copyDropdbStmt(DropdbStmt *from) +{ + DropdbStmt *newnode = makeNode(DropdbStmt); + + COPY_STRING_FIELD(dbname); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static VacuumStmt * +_copyVacuumStmt(VacuumStmt *from) +{ + VacuumStmt *newnode = makeNode(VacuumStmt); + + COPY_SCALAR_FIELD(vacuum); + COPY_SCALAR_FIELD(full); + COPY_SCALAR_FIELD(analyze); + COPY_SCALAR_FIELD(verbose); + COPY_SCALAR_FIELD(freeze_min_age); + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(va_cols); + + return newnode; +} + +static ExplainStmt * +_copyExplainStmt(ExplainStmt *from) +{ + ExplainStmt *newnode = makeNode(ExplainStmt); + + COPY_NODE_FIELD(query); + COPY_SCALAR_FIELD(verbose); + COPY_SCALAR_FIELD(analyze); + + return newnode; +} + +static CreateSeqStmt * +_copyCreateSeqStmt(CreateSeqStmt *from) +{ + CreateSeqStmt *newnode = makeNode(CreateSeqStmt); + + COPY_NODE_FIELD(sequence); + COPY_NODE_FIELD(options); + + return newnode; +} + +static AlterSeqStmt * +_copyAlterSeqStmt(AlterSeqStmt *from) +{ + AlterSeqStmt *newnode = makeNode(AlterSeqStmt); + + COPY_NODE_FIELD(sequence); + COPY_NODE_FIELD(options); + + return newnode; +} + +static VariableSetStmt * +_copyVariableSetStmt(VariableSetStmt *from) +{ + VariableSetStmt *newnode = makeNode(VariableSetStmt); + + COPY_SCALAR_FIELD(kind); + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(is_local); + + return newnode; +} + +static VariableShowStmt * +_copyVariableShowStmt(VariableShowStmt *from) +{ + VariableShowStmt *newnode = makeNode(VariableShowStmt); + + COPY_STRING_FIELD(name); + + return newnode; +} + +static DiscardStmt * +_copyDiscardStmt(DiscardStmt *from) +{ + DiscardStmt *newnode = makeNode(DiscardStmt); + + COPY_SCALAR_FIELD(target); + + return newnode; +} + +static CreateTableSpaceStmt * +_copyCreateTableSpaceStmt(CreateTableSpaceStmt *from) +{ + CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt); + + COPY_STRING_FIELD(tablespacename); + COPY_STRING_FIELD(owner); + COPY_STRING_FIELD(location); + + return newnode; +} + +static DropTableSpaceStmt * +_copyDropTableSpaceStmt(DropTableSpaceStmt *from) +{ + DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt); + + COPY_STRING_FIELD(tablespacename); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static CreateTrigStmt * +_copyCreateTrigStmt(CreateTrigStmt *from) +{ + CreateTrigStmt *newnode = makeNode(CreateTrigStmt); + + COPY_STRING_FIELD(trigname); + COPY_NODE_FIELD(relation); + COPY_NODE_FIELD(funcname); + COPY_NODE_FIELD(args); + COPY_SCALAR_FIELD(before); + COPY_SCALAR_FIELD(row); + strcpy(newnode->actions, from->actions); /* in-line string field */ + COPY_SCALAR_FIELD(isconstraint); + COPY_SCALAR_FIELD(deferrable); + COPY_SCALAR_FIELD(initdeferred); + COPY_NODE_FIELD(constrrel); + + return newnode; +} + +static DropPropertyStmt * +_copyDropPropertyStmt(DropPropertyStmt *from) +{ + DropPropertyStmt *newnode = makeNode(DropPropertyStmt); + + COPY_NODE_FIELD(relation); + COPY_STRING_FIELD(property); + COPY_SCALAR_FIELD(removeType); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static CreatePLangStmt * +_copyCreatePLangStmt(CreatePLangStmt *from) +{ + CreatePLangStmt *newnode = makeNode(CreatePLangStmt); + + COPY_STRING_FIELD(plname); + COPY_NODE_FIELD(plhandler); + COPY_NODE_FIELD(plvalidator); + COPY_SCALAR_FIELD(pltrusted); + + return newnode; +} + +static DropPLangStmt * +_copyDropPLangStmt(DropPLangStmt *from) +{ + DropPLangStmt *newnode = makeNode(DropPLangStmt); + + COPY_STRING_FIELD(plname); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static CreateRoleStmt * +_copyCreateRoleStmt(CreateRoleStmt *from) +{ + CreateRoleStmt *newnode = makeNode(CreateRoleStmt); + + COPY_SCALAR_FIELD(stmt_type); + COPY_STRING_FIELD(role); + COPY_NODE_FIELD(options); + + return newnode; +} + +static AlterRoleStmt * +_copyAlterRoleStmt(AlterRoleStmt *from) +{ + AlterRoleStmt *newnode = makeNode(AlterRoleStmt); + + COPY_STRING_FIELD(role); + COPY_NODE_FIELD(options); + COPY_SCALAR_FIELD(action); + + return newnode; +} + +static AlterRoleSetStmt * +_copyAlterRoleSetStmt(AlterRoleSetStmt *from) +{ + AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt); + + COPY_STRING_FIELD(role); + COPY_NODE_FIELD(setstmt); + + return newnode; +} + +static DropRoleStmt * +_copyDropRoleStmt(DropRoleStmt *from) +{ + DropRoleStmt *newnode = makeNode(DropRoleStmt); + + COPY_NODE_FIELD(roles); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static LockStmt * +_copyLockStmt(LockStmt *from) +{ + LockStmt *newnode = makeNode(LockStmt); + + COPY_NODE_FIELD(relations); + COPY_SCALAR_FIELD(mode); + COPY_SCALAR_FIELD(nowait); + + return newnode; +} + +static ConstraintsSetStmt * +_copyConstraintsSetStmt(ConstraintsSetStmt *from) +{ + ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt); + + COPY_NODE_FIELD(constraints); + COPY_SCALAR_FIELD(deferred); + + return newnode; +} + +static ReindexStmt * +_copyReindexStmt(ReindexStmt *from) +{ + ReindexStmt *newnode = makeNode(ReindexStmt); + + COPY_SCALAR_FIELD(kind); + COPY_NODE_FIELD(relation); + COPY_STRING_FIELD(name); + COPY_SCALAR_FIELD(do_system); + COPY_SCALAR_FIELD(do_user); + + return newnode; +} + +static CreateSchemaStmt * +_copyCreateSchemaStmt(CreateSchemaStmt *from) +{ + CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt); + + COPY_STRING_FIELD(schemaname); + COPY_STRING_FIELD(authid); + COPY_NODE_FIELD(schemaElts); + + return newnode; +} + +static CreateConversionStmt * +_copyCreateConversionStmt(CreateConversionStmt *from) +{ + CreateConversionStmt *newnode = makeNode(CreateConversionStmt); + + COPY_NODE_FIELD(conversion_name); + COPY_STRING_FIELD(for_encoding_name); + COPY_STRING_FIELD(to_encoding_name); + COPY_NODE_FIELD(func_name); + COPY_SCALAR_FIELD(def); + + return newnode; +} + +static CreateCastStmt * +_copyCreateCastStmt(CreateCastStmt *from) +{ + CreateCastStmt *newnode = makeNode(CreateCastStmt); + + COPY_NODE_FIELD(sourcetype); + COPY_NODE_FIELD(targettype); + COPY_NODE_FIELD(func); + COPY_SCALAR_FIELD(context); + + return newnode; +} + +static DropCastStmt * +_copyDropCastStmt(DropCastStmt *from) +{ + DropCastStmt *newnode = makeNode(DropCastStmt); + + COPY_NODE_FIELD(sourcetype); + COPY_NODE_FIELD(targettype); + COPY_SCALAR_FIELD(behavior); + COPY_SCALAR_FIELD(missing_ok); + + return newnode; +} + +static PrepareStmt * +_copyPrepareStmt(PrepareStmt *from) +{ + PrepareStmt *newnode = makeNode(PrepareStmt); + + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(argtypes); + COPY_NODE_FIELD(query); + + return newnode; +} + +static ExecuteStmt * +_copyExecuteStmt(ExecuteStmt *from) +{ + ExecuteStmt *newnode = makeNode(ExecuteStmt); + + COPY_STRING_FIELD(name); + COPY_NODE_FIELD(into); + COPY_NODE_FIELD(params); + + return newnode; +} + +static DeallocateStmt * +_copyDeallocateStmt(DeallocateStmt *from) +{ + DeallocateStmt *newnode = makeNode(DeallocateStmt); + + COPY_STRING_FIELD(name); + + return newnode; +} + +static DropOwnedStmt * +_copyDropOwnedStmt(DropOwnedStmt *from) +{ + DropOwnedStmt *newnode = makeNode(DropOwnedStmt); + + COPY_NODE_FIELD(roles); + COPY_SCALAR_FIELD(behavior); + + return newnode; +} + +static ReassignOwnedStmt * +_copyReassignOwnedStmt(ReassignOwnedStmt *from) +{ + ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt); + + COPY_NODE_FIELD(roles); + COPY_SCALAR_FIELD(newrole); + + return newnode; +} + +/* **************************************************************** + * pg_list.h copy functions + * **************************************************************** + */ + +/* + * Perform a deep copy of the specified list, using copyObject(). The + * list MUST be of type T_List; T_IntList and T_OidList nodes don't + * need deep copies, so they should be copied via list_copy() + */ +#define COPY_NODE_CELL(new, old) \ + (new) = (ListCell *) palloc(sizeof(ListCell)); \ + lfirst(new) = copyObject(lfirst(old)); + +static List * +_copyList(List *from) +{ + List *new; + ListCell *curr_old; + ListCell *prev_new; + + new = makeNode(List); + new->length = from->length; + + COPY_NODE_CELL(new->head, from->head); + prev_new = new->head; + curr_old = lnext(from->head); + + while (curr_old) + { + COPY_NODE_CELL(prev_new->next, curr_old); + prev_new = prev_new->next; + curr_old = curr_old->next; + } + prev_new->next = NULL; + new->tail = prev_new; + + return new; +} + +/* **************************************************************** + * value.h copy functions + * **************************************************************** + */ +static Value * +_copyValue(Value *from) +{ + Value *newnode = makeNode(Value); + + /* See also _copyAConst when changing this code! */ + + COPY_SCALAR_FIELD(type); + switch (from->type) + { + case T_Integer: + COPY_SCALAR_FIELD(val.ival); + break; + case T_Float: + case T_String: + case T_BitString: + COPY_STRING_FIELD(val.str); + break; + case T_Null: + /* nothing to do */ + break; + default: + pool_error("unrecognized node type: %d", + (int) from->type); + break; + } + return newnode; +} + +/* + * copyObject + * + * Create a copy of a Node tree or list. This is a "deep" copy: all + * substructure is copied too, recursively. + */ +void * +copyObject(void *from) +{ + void *retval; + + if (from == NULL) + return NULL; + + switch (nodeTag(from)) + { + /* + * PRIMITIVE NODES + */ + case T_Alias: + retval = _copyAlias(from); + break; + case T_RangeVar: + retval = _copyRangeVar(from); + break; + case T_IntoClause: + retval = _copyIntoClause(from); + break; + case T_Var: + retval = _copyVar(from); + break; + case T_Param: + retval = _copyParam(from); + break; + case T_Aggref: + retval = _copyAggref(from); + break; + case T_ArrayRef: + retval = _copyArrayRef(from); + break; + case T_FuncExpr: + retval = _copyFuncExpr(from); + break; + case T_OpExpr: + retval = _copyOpExpr(from); + break; + case T_DistinctExpr: + retval = _copyDistinctExpr(from); + break; + case T_ScalarArrayOpExpr: + retval = _copyScalarArrayOpExpr(from); + break; + case T_BoolExpr: + retval = _copyBoolExpr(from); + break; + case T_SubLink: + retval = _copySubLink(from); + break; + case T_SubPlan: + retval = _copySubPlan(from); + break; + case T_FieldSelect: + retval = _copyFieldSelect(from); + break; + case T_FieldStore: + retval = _copyFieldStore(from); + break; + case T_RelabelType: + retval = _copyRelabelType(from); + break; + case T_CoerceViaIO: + retval = _copyCoerceViaIO(from); + break; + case T_ArrayCoerceExpr: + retval = _copyArrayCoerceExpr(from); + break; + case T_ConvertRowtypeExpr: + retval = _copyConvertRowtypeExpr(from); + break; + case T_CaseExpr: + retval = _copyCaseExpr(from); + break; + case T_CaseWhen: + retval = _copyCaseWhen(from); + break; + case T_CaseTestExpr: + retval = _copyCaseTestExpr(from); + break; + case T_ArrayExpr: + retval = _copyArrayExpr(from); + break; + case T_RowExpr: + retval = _copyRowExpr(from); + break; + case T_RowCompareExpr: + retval = _copyRowCompareExpr(from); + break; + case T_CoalesceExpr: + retval = _copyCoalesceExpr(from); + break; + case T_MinMaxExpr: + retval = _copyMinMaxExpr(from); + break; + case T_XmlExpr: + retval = _copyXmlExpr(from); + break; + case T_NullIfExpr: + retval = _copyNullIfExpr(from); + break; + case T_NullTest: + retval = _copyNullTest(from); + break; + case T_BooleanTest: + retval = _copyBooleanTest(from); + break; + case T_CoerceToDomain: + retval = _copyCoerceToDomain(from); + break; + case T_CoerceToDomainValue: + retval = _copyCoerceToDomainValue(from); + break; + case T_SetToDefault: + retval = _copySetToDefault(from); + break; + case T_CurrentOfExpr: + retval = _copyCurrentOfExpr(from); + break; + case T_TargetEntry: + retval = _copyTargetEntry(from); + break; + case T_RangeTblRef: + retval = _copyRangeTblRef(from); + break; + case T_JoinExpr: + retval = _copyJoinExpr(from); + break; + case T_FromExpr: + retval = _copyFromExpr(from); + break; + + /* + * VALUE NODES + */ + case T_Integer: + case T_Float: + case T_String: + case T_BitString: + case T_Null: + retval = _copyValue(from); + break; + + /* + * LIST NODES + */ + case T_List: + retval = _copyList(from); + break; + + /* + * Lists of integers and OIDs don't need to be deep-copied, so we + * perform a shallow copy via list_copy() + */ + case T_IntList: + case T_OidList: + retval = list_copy(from); + break; + + /* + * PARSE NODES + */ + case T_Query: + retval = _copyQuery(from); + break; + case T_InsertStmt: + retval = _copyInsertStmt(from); + break; + case T_DeleteStmt: + retval = _copyDeleteStmt(from); + break; + case T_UpdateStmt: + retval = _copyUpdateStmt(from); + break; + case T_SelectStmt: + retval = _copySelectStmt(from); + break; + case T_SetOperationStmt: + retval = _copySetOperationStmt(from); + break; + case T_AlterTableStmt: + retval = _copyAlterTableStmt(from); + break; + case T_AlterTableCmd: + retval = _copyAlterTableCmd(from); + break; + case T_AlterDomainStmt: + retval = _copyAlterDomainStmt(from); + break; + case T_GrantStmt: + retval = _copyGrantStmt(from); + break; + case T_GrantRoleStmt: + retval = _copyGrantRoleStmt(from); + break; + case T_DeclareCursorStmt: + retval = _copyDeclareCursorStmt(from); + break; + case T_ClosePortalStmt: + retval = _copyClosePortalStmt(from); + break; + case T_ClusterStmt: + retval = _copyClusterStmt(from); + break; + case T_CopyStmt: + retval = _copyCopyStmt(from); + break; + case T_CreateStmt: + retval = _copyCreateStmt(from); + break; + case T_InhRelation: + retval = _copyInhRelation(from); + break; + case T_DefineStmt: + retval = _copyDefineStmt(from); + break; + case T_DropStmt: + retval = _copyDropStmt(from); + break; + case T_TruncateStmt: + retval = _copyTruncateStmt(from); + break; + case T_CommentStmt: + retval = _copyCommentStmt(from); + break; + case T_FetchStmt: + retval = _copyFetchStmt(from); + break; + case T_IndexStmt: + retval = _copyIndexStmt(from); + break; + case T_CreateFunctionStmt: + retval = _copyCreateFunctionStmt(from); + break; + case T_FunctionParameter: + retval = _copyFunctionParameter(from); + break; + case T_AlterFunctionStmt: + retval = _copyAlterFunctionStmt(from); + break; + case T_RemoveFuncStmt: + retval = _copyRemoveFuncStmt(from); + break; + case T_RemoveOpClassStmt: + retval = _copyRemoveOpClassStmt(from); + break; + case T_RemoveOpFamilyStmt: + retval = _copyRemoveOpFamilyStmt(from); + break; + case T_RenameStmt: + retval = _copyRenameStmt(from); + break; + case T_AlterObjectSchemaStmt: + retval = _copyAlterObjectSchemaStmt(from); + break; + case T_AlterOwnerStmt: + retval = _copyAlterOwnerStmt(from); + break; + case T_RuleStmt: + retval = _copyRuleStmt(from); + break; + case T_NotifyStmt: + retval = _copyNotifyStmt(from); + break; + case T_ListenStmt: + retval = _copyListenStmt(from); + break; + case T_UnlistenStmt: + retval = _copyUnlistenStmt(from); + break; + case T_TransactionStmt: + retval = _copyTransactionStmt(from); + break; + case T_CompositeTypeStmt: + retval = _copyCompositeTypeStmt(from); + break; + case T_CreateEnumStmt: + retval = _copyCreateEnumStmt(from); + break; + case T_ViewStmt: + retval = _copyViewStmt(from); + break; + case T_LoadStmt: + retval = _copyLoadStmt(from); + break; + case T_CreateDomainStmt: + retval = _copyCreateDomainStmt(from); + break; + case T_CreateOpClassStmt: + retval = _copyCreateOpClassStmt(from); + break; + case T_CreateOpClassItem: + retval = _copyCreateOpClassItem(from); + break; + case T_CreateOpFamilyStmt: + retval = _copyCreateOpFamilyStmt(from); + break; + case T_AlterOpFamilyStmt: + retval = _copyAlterOpFamilyStmt(from); + break; + case T_CreatedbStmt: + retval = _copyCreatedbStmt(from); + break; + case T_AlterDatabaseStmt: + retval = _copyAlterDatabaseStmt(from); + break; + case T_AlterDatabaseSetStmt: + retval = _copyAlterDatabaseSetStmt(from); + break; + case T_DropdbStmt: + retval = _copyDropdbStmt(from); + break; + case T_VacuumStmt: + retval = _copyVacuumStmt(from); + break; + case T_ExplainStmt: + retval = _copyExplainStmt(from); + break; + case T_CreateSeqStmt: + retval = _copyCreateSeqStmt(from); + break; + case T_AlterSeqStmt: + retval = _copyAlterSeqStmt(from); + break; + case T_VariableSetStmt: + retval = _copyVariableSetStmt(from); + break; + case T_VariableShowStmt: + retval = _copyVariableShowStmt(from); + break; + case T_DiscardStmt: + retval = _copyDiscardStmt(from); + break; + case T_CreateTableSpaceStmt: + retval = _copyCreateTableSpaceStmt(from); + break; + case T_DropTableSpaceStmt: + retval = _copyDropTableSpaceStmt(from); + break; + case T_CreateTrigStmt: + retval = _copyCreateTrigStmt(from); + break; + case T_DropPropertyStmt: + retval = _copyDropPropertyStmt(from); + break; + case T_CreatePLangStmt: + retval = _copyCreatePLangStmt(from); + break; + case T_DropPLangStmt: + retval = _copyDropPLangStmt(from); + break; + case T_CreateRoleStmt: + retval = _copyCreateRoleStmt(from); + break; + case T_AlterRoleStmt: + retval = _copyAlterRoleStmt(from); + break; + case T_AlterRoleSetStmt: + retval = _copyAlterRoleSetStmt(from); + break; + case T_DropRoleStmt: + retval = _copyDropRoleStmt(from); + break; + case T_LockStmt: + retval = _copyLockStmt(from); + break; + case T_ConstraintsSetStmt: + retval = _copyConstraintsSetStmt(from); + break; + case T_ReindexStmt: + retval = _copyReindexStmt(from); + break; + case T_CheckPointStmt: + retval = (void *) makeNode(CheckPointStmt); + break; + case T_CreateSchemaStmt: + retval = _copyCreateSchemaStmt(from); + break; + case T_CreateConversionStmt: + retval = _copyCreateConversionStmt(from); + break; + case T_CreateCastStmt: + retval = _copyCreateCastStmt(from); + break; + case T_DropCastStmt: + retval = _copyDropCastStmt(from); + break; + case T_PrepareStmt: + retval = _copyPrepareStmt(from); + break; + case T_ExecuteStmt: + retval = _copyExecuteStmt(from); + break; + case T_DeallocateStmt: + retval = _copyDeallocateStmt(from); + break; + case T_DropOwnedStmt: + retval = _copyDropOwnedStmt(from); + break; + case T_ReassignOwnedStmt: + retval = _copyReassignOwnedStmt(from); + break; + + case T_A_Expr: + retval = _copyAExpr(from); + break; + case T_ColumnRef: + retval = _copyColumnRef(from); + break; + case T_ParamRef: + retval = _copyParamRef(from); + break; + case T_A_Const: + retval = _copyAConst(from); + break; + case T_FuncCall: + retval = _copyFuncCall(from); + break; + case T_A_Indices: + retval = _copyAIndices(from); + break; + case T_A_Indirection: + retval = _copyA_Indirection(from); + break; + case T_ResTarget: + retval = _copyResTarget(from); + break; + case T_TypeCast: + retval = _copyTypeCast(from); + break; + case T_SortBy: + retval = _copySortBy(from); + break; + case T_RangeSubselect: + retval = _copyRangeSubselect(from); + break; + case T_RangeFunction: + retval = _copyRangeFunction(from); + break; + case T_TypeName: + retval = _copyTypeName(from); + break; + case T_IndexElem: + retval = _copyIndexElem(from); + break; + case T_ColumnDef: + retval = _copyColumnDef(from); + break; + case T_Constraint: + retval = _copyConstraint(from); + break; + case T_DefElem: + retval = _copyDefElem(from); + break; + case T_LockingClause: + retval = _copyLockingClause(from); + break; + case T_RangeTblEntry: + retval = _copyRangeTblEntry(from); + break; + case T_SortClause: + retval = _copySortClause(from); + break; + case T_GroupClause: + retval = _copyGroupClause(from); + break; + case T_RowMarkClause: + retval = _copyRowMarkClause(from); + break; + case T_FkConstraint: + retval = _copyFkConstraint(from); + break; + case T_PrivGrantee: + retval = _copyPrivGrantee(from); + break; + case T_FuncWithArgs: + retval = _copyFuncWithArgs(from); + break; + case T_XmlSerialize: + retval = _copyXmlSerialize(from); + break; + + default: + pool_error("unrecognized node type: %d", (int) nodeTag(from)); + retval = from; /* keep compiler quiet */ + break; + } + + return retval; +} diff --git a/parser/gram.c b/parser/gram.c new file mode 100644 index 0000000..a3e6869 --- /dev/null +++ b/parser/gram.c @@ -0,0 +1,25739 @@ +/* A Bison parser, made by GNU Bison 2.1. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + +/* Substitute the variable and function names. */ +#define yyparse base_yyparse +#define yylex base_yylex +#define yyerror base_yyerror +#define yylval base_yylval +#define yychar base_yychar +#define yydebug base_yydebug +#define yynerrs base_yynerrs +#define yylloc base_yylloc + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ABORT_P = 258, + ABSOLUTE_P = 259, + ACCESS = 260, + ACTION = 261, + ADD_P = 262, + ADMIN = 263, + AFTER = 264, + AGGREGATE = 265, + ALL = 266, + ALSO = 267, + ALTER = 268, + ALWAYS = 269, + ANALYSE = 270, + ANALYZE = 271, + AND = 272, + ANY = 273, + ARRAY = 274, + AS = 275, + ASC = 276, + ASSERTION = 277, + ASSIGNMENT = 278, + ASYMMETRIC = 279, + AT = 280, + AUTHORIZATION = 281, + BACKWARD = 282, + BEFORE = 283, + BEGIN_P = 284, + BETWEEN = 285, + BIGINT = 286, + BINARY = 287, + BIT = 288, + BOOLEAN_P = 289, + BOTH = 290, + BY = 291, + CACHE = 292, + CALLED = 293, + CASCADE = 294, + CASCADED = 295, + CASE = 296, + CAST = 297, + CHAIN = 298, + CHAR_P = 299, + CHARACTER = 300, + CHARACTERISTICS = 301, + CHECK = 302, + CHECKPOINT = 303, + CLASS = 304, + CLOSE = 305, + CLUSTER = 306, + COALESCE = 307, + COLLATE = 308, + COLUMN = 309, + COMMENT = 310, + COMMIT = 311, + COMMITTED = 312, + CONCURRENTLY = 313, + CONFIGURATION = 314, + CONNECTION = 315, + CONSTRAINT = 316, + CONSTRAINTS = 317, + CONTENT_P = 318, + CONVERSION_P = 319, + COPY = 320, + COST = 321, + CREATE = 322, + CREATEDB = 323, + CREATEROLE = 324, + CREATEUSER = 325, + CROSS = 326, + CSV = 327, + CURRENT_P = 328, + CURRENT_DATE = 329, + CURRENT_ROLE = 330, + CURRENT_TIME = 331, + CURRENT_TIMESTAMP = 332, + CURRENT_USER = 333, + CURSOR = 334, + CYCLE = 335, + DATABASE = 336, + DAY_P = 337, + DEALLOCATE = 338, + DEC = 339, + DECIMAL_P = 340, + DECLARE = 341, + DEFAULT = 342, + DEFAULTS = 343, + DEFERRABLE = 344, + DEFERRED = 345, + DEFINER = 346, + DELETE_P = 347, + DELIMITER = 348, + DELIMITERS = 349, + DESC = 350, + DICTIONARY = 351, + DISABLE_P = 352, + DISCARD = 353, + DISTINCT = 354, + DO = 355, + DOCUMENT_P = 356, + DOMAIN_P = 357, + DOUBLE_P = 358, + DROP = 359, + EACH = 360, + ELSE = 361, + ENABLE_P = 362, + ENCODING = 363, + ENCRYPTED = 364, + END_P = 365, + ENUM_P = 366, + ESCAPE = 367, + EXCEPT = 368, + EXCLUDING = 369, + EXCLUSIVE = 370, + EXECUTE = 371, + EXISTS = 372, + EXPLAIN = 373, + EXTERNAL = 374, + EXTRACT = 375, + FALSE_P = 376, + FAMILY = 377, + FETCH = 378, + FIRST_P = 379, + FLOAT_P = 380, + FOR = 381, + FORCE = 382, + FOREIGN = 383, + FORWARD = 384, + FREEZE = 385, + FROM = 386, + FULL = 387, + FUNCTION = 388, + GLOBAL = 389, + GRANT = 390, + GRANTED = 391, + GREATEST = 392, + GROUP_P = 393, + HANDLER = 394, + HAVING = 395, + HEADER_P = 396, + HOLD = 397, + HOUR_P = 398, + IF_P = 399, + ILIKE = 400, + IMMEDIATE = 401, + IMMUTABLE = 402, + IMPLICIT_P = 403, + IN_P = 404, + INCLUDING = 405, + INCREMENT = 406, + INDEX = 407, + INDEXES = 408, + INHERIT = 409, + INHERITS = 410, + INITIALLY = 411, + INNER_P = 412, + INOUT = 413, + INPUT_P = 414, + INSENSITIVE = 415, + INSERT = 416, + INSTEAD = 417, + INT_P = 418, + INTEGER = 419, + INTERSECT = 420, + INTERVAL = 421, + INTO = 422, + INVOKER = 423, + IS = 424, + ISNULL = 425, + ISOLATION = 426, + JOIN = 427, + KEY = 428, + LANCOMPILER = 429, + LANGUAGE = 430, + LARGE_P = 431, + LAST_P = 432, + LEADING = 433, + LEAST = 434, + LEFT = 435, + LEVEL = 436, + LIKE = 437, + LIMIT = 438, + LISTEN = 439, + LOAD = 440, + LOCAL = 441, + LOCALTIME = 442, + LOCALTIMESTAMP = 443, + LOCATION = 444, + LOCK_P = 445, + LOGIN_P = 446, + MAPPING = 447, + MATCH = 448, + MAXVALUE = 449, + MINUTE_P = 450, + MINVALUE = 451, + MODE = 452, + MONTH_P = 453, + MOVE = 454, + NAME_P = 455, + NAMES = 456, + NATIONAL = 457, + NATURAL = 458, + NCHAR = 459, + NEW = 460, + NEXT = 461, + NO = 462, + NOCREATEDB = 463, + NOCREATEROLE = 464, + NOCREATEUSER = 465, + NOINHERIT = 466, + NOLOGIN_P = 467, + NONE = 468, + NOSUPERUSER = 469, + NOT = 470, + NOTHING = 471, + NOTIFY = 472, + NOTNULL = 473, + NOWAIT = 474, + NULL_P = 475, + NULLIF = 476, + NULLS_P = 477, + NUMERIC = 478, + OBJECT_P = 479, + OF = 480, + OFF = 481, + OFFSET = 482, + OIDS = 483, + OLD = 484, + ON = 485, + ONLY = 486, + OPERATOR = 487, + OPTION = 488, + OR = 489, + ORDER = 490, + OUT_P = 491, + OUTER_P = 492, + OVERLAPS = 493, + OVERLAY = 494, + OWNED = 495, + OWNER = 496, + PARSER = 497, + PARTIAL = 498, + PASSWORD = 499, + PLACING = 500, + PLANS = 501, + POSITION = 502, + PRECISION = 503, + PRESERVE = 504, + PREPARE = 505, + PREPARED = 506, + PRIMARY = 507, + PRIOR = 508, + PRIVILEGES = 509, + PROCEDURAL = 510, + PROCEDURE = 511, + QUOTE = 512, + READ = 513, + REAL = 514, + REASSIGN = 515, + RECHECK = 516, + REFERENCES = 517, + REINDEX = 518, + RELATIVE_P = 519, + RELEASE = 520, + RENAME = 521, + REPEATABLE = 522, + REPLACE = 523, + REPLICA = 524, + RESET = 525, + RESTART = 526, + RESTRICT = 527, + RETURNING = 528, + RETURNS = 529, + REVOKE = 530, + RIGHT = 531, + ROLE = 532, + ROLLBACK = 533, + ROW = 534, + ROWS = 535, + RULE = 536, + SAVEPOINT = 537, + SCHEMA = 538, + SCROLL = 539, + SEARCH = 540, + SECOND_P = 541, + SECURITY = 542, + SELECT = 543, + SEQUENCE = 544, + SERIALIZABLE = 545, + SESSION = 546, + SESSION_USER = 547, + SET = 548, + SETOF = 549, + SHARE = 550, + SHOW = 551, + SIMILAR = 552, + SIMPLE = 553, + SMALLINT = 554, + SOME = 555, + STABLE = 556, + STANDALONE_P = 557, + START = 558, + STATEMENT = 559, + STATISTICS = 560, + STDIN = 561, + STDOUT = 562, + STORAGE = 563, + STRICT_P = 564, + STRIP_P = 565, + SUBSTRING = 566, + SUPERUSER_P = 567, + SYMMETRIC = 568, + SYSID = 569, + SYSTEM_P = 570, + TABLE = 571, + TABLESPACE = 572, + TEMP = 573, + TEMPLATE = 574, + TEMPORARY = 575, + TEXT_P = 576, + THEN = 577, + TIME = 578, + TIMESTAMP = 579, + TO = 580, + TRAILING = 581, + TRANSACTION = 582, + TREAT = 583, + TRIGGER = 584, + TRIM = 585, + TRUE_P = 586, + TRUNCATE = 587, + TRUSTED = 588, + TYPE_P = 589, + UNCOMMITTED = 590, + UNENCRYPTED = 591, + UNION = 592, + UNIQUE = 593, + UNKNOWN = 594, + UNLISTEN = 595, + UNTIL = 596, + UPDATE = 597, + USER = 598, + USING = 599, + VACUUM = 600, + VALID = 601, + VALIDATOR = 602, + VALUE_P = 603, + VALUES = 604, + VARCHAR = 605, + VARYING = 606, + VERBOSE = 607, + VERSION_P = 608, + VIEW = 609, + VOLATILE = 610, + WHEN = 611, + WHERE = 612, + WHITESPACE_P = 613, + WITH = 614, + WITHOUT = 615, + WORK = 616, + WRITE = 617, + XML_P = 618, + XMLATTRIBUTES = 619, + XMLCONCAT = 620, + XMLELEMENT = 621, + XMLFOREST = 622, + XMLPARSE = 623, + XMLPI = 624, + XMLROOT = 625, + XMLSERIALIZE = 626, + YEAR_P = 627, + YES_P = 628, + ZONE = 629, + NULLS_FIRST = 630, + NULLS_LAST = 631, + WITH_CASCADED = 632, + WITH_LOCAL = 633, + WITH_CHECK = 634, + IDENT = 635, + FCONST = 636, + SCONST = 637, + BCONST = 638, + XCONST = 639, + Op = 640, + ICONST = 641, + PARAM = 642, + POSTFIXOP = 643, + UMINUS = 644, + TYPECAST = 645 + }; +#endif +/* Tokens. */ +#define ABORT_P 258 +#define ABSOLUTE_P 259 +#define ACCESS 260 +#define ACTION 261 +#define ADD_P 262 +#define ADMIN 263 +#define AFTER 264 +#define AGGREGATE 265 +#define ALL 266 +#define ALSO 267 +#define ALTER 268 +#define ALWAYS 269 +#define ANALYSE 270 +#define ANALYZE 271 +#define AND 272 +#define ANY 273 +#define ARRAY 274 +#define AS 275 +#define ASC 276 +#define ASSERTION 277 +#define ASSIGNMENT 278 +#define ASYMMETRIC 279 +#define AT 280 +#define AUTHORIZATION 281 +#define BACKWARD 282 +#define BEFORE 283 +#define BEGIN_P 284 +#define BETWEEN 285 +#define BIGINT 286 +#define BINARY 287 +#define BIT 288 +#define BOOLEAN_P 289 +#define BOTH 290 +#define BY 291 +#define CACHE 292 +#define CALLED 293 +#define CASCADE 294 +#define CASCADED 295 +#define CASE 296 +#define CAST 297 +#define CHAIN 298 +#define CHAR_P 299 +#define CHARACTER 300 +#define CHARACTERISTICS 301 +#define CHECK 302 +#define CHECKPOINT 303 +#define CLASS 304 +#define CLOSE 305 +#define CLUSTER 306 +#define COALESCE 307 +#define COLLATE 308 +#define COLUMN 309 +#define COMMENT 310 +#define COMMIT 311 +#define COMMITTED 312 +#define CONCURRENTLY 313 +#define CONFIGURATION 314 +#define CONNECTION 315 +#define CONSTRAINT 316 +#define CONSTRAINTS 317 +#define CONTENT_P 318 +#define CONVERSION_P 319 +#define COPY 320 +#define COST 321 +#define CREATE 322 +#define CREATEDB 323 +#define CREATEROLE 324 +#define CREATEUSER 325 +#define CROSS 326 +#define CSV 327 +#define CURRENT_P 328 +#define CURRENT_DATE 329 +#define CURRENT_ROLE 330 +#define CURRENT_TIME 331 +#define CURRENT_TIMESTAMP 332 +#define CURRENT_USER 333 +#define CURSOR 334 +#define CYCLE 335 +#define DATABASE 336 +#define DAY_P 337 +#define DEALLOCATE 338 +#define DEC 339 +#define DECIMAL_P 340 +#define DECLARE 341 +#define DEFAULT 342 +#define DEFAULTS 343 +#define DEFERRABLE 344 +#define DEFERRED 345 +#define DEFINER 346 +#define DELETE_P 347 +#define DELIMITER 348 +#define DELIMITERS 349 +#define DESC 350 +#define DICTIONARY 351 +#define DISABLE_P 352 +#define DISCARD 353 +#define DISTINCT 354 +#define DO 355 +#define DOCUMENT_P 356 +#define DOMAIN_P 357 +#define DOUBLE_P 358 +#define DROP 359 +#define EACH 360 +#define ELSE 361 +#define ENABLE_P 362 +#define ENCODING 363 +#define ENCRYPTED 364 +#define END_P 365 +#define ENUM_P 366 +#define ESCAPE 367 +#define EXCEPT 368 +#define EXCLUDING 369 +#define EXCLUSIVE 370 +#define EXECUTE 371 +#define EXISTS 372 +#define EXPLAIN 373 +#define EXTERNAL 374 +#define EXTRACT 375 +#define FALSE_P 376 +#define FAMILY 377 +#define FETCH 378 +#define FIRST_P 379 +#define FLOAT_P 380 +#define FOR 381 +#define FORCE 382 +#define FOREIGN 383 +#define FORWARD 384 +#define FREEZE 385 +#define FROM 386 +#define FULL 387 +#define FUNCTION 388 +#define GLOBAL 389 +#define GRANT 390 +#define GRANTED 391 +#define GREATEST 392 +#define GROUP_P 393 +#define HANDLER 394 +#define HAVING 395 +#define HEADER_P 396 +#define HOLD 397 +#define HOUR_P 398 +#define IF_P 399 +#define ILIKE 400 +#define IMMEDIATE 401 +#define IMMUTABLE 402 +#define IMPLICIT_P 403 +#define IN_P 404 +#define INCLUDING 405 +#define INCREMENT 406 +#define INDEX 407 +#define INDEXES 408 +#define INHERIT 409 +#define INHERITS 410 +#define INITIALLY 411 +#define INNER_P 412 +#define INOUT 413 +#define INPUT_P 414 +#define INSENSITIVE 415 +#define INSERT 416 +#define INSTEAD 417 +#define INT_P 418 +#define INTEGER 419 +#define INTERSECT 420 +#define INTERVAL 421 +#define INTO 422 +#define INVOKER 423 +#define IS 424 +#define ISNULL 425 +#define ISOLATION 426 +#define JOIN 427 +#define KEY 428 +#define LANCOMPILER 429 +#define LANGUAGE 430 +#define LARGE_P 431 +#define LAST_P 432 +#define LEADING 433 +#define LEAST 434 +#define LEFT 435 +#define LEVEL 436 +#define LIKE 437 +#define LIMIT 438 +#define LISTEN 439 +#define LOAD 440 +#define LOCAL 441 +#define LOCALTIME 442 +#define LOCALTIMESTAMP 443 +#define LOCATION 444 +#define LOCK_P 445 +#define LOGIN_P 446 +#define MAPPING 447 +#define MATCH 448 +#define MAXVALUE 449 +#define MINUTE_P 450 +#define MINVALUE 451 +#define MODE 452 +#define MONTH_P 453 +#define MOVE 454 +#define NAME_P 455 +#define NAMES 456 +#define NATIONAL 457 +#define NATURAL 458 +#define NCHAR 459 +#define NEW 460 +#define NEXT 461 +#define NO 462 +#define NOCREATEDB 463 +#define NOCREATEROLE 464 +#define NOCREATEUSER 465 +#define NOINHERIT 466 +#define NOLOGIN_P 467 +#define NONE 468 +#define NOSUPERUSER 469 +#define NOT 470 +#define NOTHING 471 +#define NOTIFY 472 +#define NOTNULL 473 +#define NOWAIT 474 +#define NULL_P 475 +#define NULLIF 476 +#define NULLS_P 477 +#define NUMERIC 478 +#define OBJECT_P 479 +#define OF 480 +#define OFF 481 +#define OFFSET 482 +#define OIDS 483 +#define OLD 484 +#define ON 485 +#define ONLY 486 +#define OPERATOR 487 +#define OPTION 488 +#define OR 489 +#define ORDER 490 +#define OUT_P 491 +#define OUTER_P 492 +#define OVERLAPS 493 +#define OVERLAY 494 +#define OWNED 495 +#define OWNER 496 +#define PARSER 497 +#define PARTIAL 498 +#define PASSWORD 499 +#define PLACING 500 +#define PLANS 501 +#define POSITION 502 +#define PRECISION 503 +#define PRESERVE 504 +#define PREPARE 505 +#define PREPARED 506 +#define PRIMARY 507 +#define PRIOR 508 +#define PRIVILEGES 509 +#define PROCEDURAL 510 +#define PROCEDURE 511 +#define QUOTE 512 +#define READ 513 +#define REAL 514 +#define REASSIGN 515 +#define RECHECK 516 +#define REFERENCES 517 +#define REINDEX 518 +#define RELATIVE_P 519 +#define RELEASE 520 +#define RENAME 521 +#define REPEATABLE 522 +#define REPLACE 523 +#define REPLICA 524 +#define RESET 525 +#define RESTART 526 +#define RESTRICT 527 +#define RETURNING 528 +#define RETURNS 529 +#define REVOKE 530 +#define RIGHT 531 +#define ROLE 532 +#define ROLLBACK 533 +#define ROW 534 +#define ROWS 535 +#define RULE 536 +#define SAVEPOINT 537 +#define SCHEMA 538 +#define SCROLL 539 +#define SEARCH 540 +#define SECOND_P 541 +#define SECURITY 542 +#define SELECT 543 +#define SEQUENCE 544 +#define SERIALIZABLE 545 +#define SESSION 546 +#define SESSION_USER 547 +#define SET 548 +#define SETOF 549 +#define SHARE 550 +#define SHOW 551 +#define SIMILAR 552 +#define SIMPLE 553 +#define SMALLINT 554 +#define SOME 555 +#define STABLE 556 +#define STANDALONE_P 557 +#define START 558 +#define STATEMENT 559 +#define STATISTICS 560 +#define STDIN 561 +#define STDOUT 562 +#define STORAGE 563 +#define STRICT_P 564 +#define STRIP_P 565 +#define SUBSTRING 566 +#define SUPERUSER_P 567 +#define SYMMETRIC 568 +#define SYSID 569 +#define SYSTEM_P 570 +#define TABLE 571 +#define TABLESPACE 572 +#define TEMP 573 +#define TEMPLATE 574 +#define TEMPORARY 575 +#define TEXT_P 576 +#define THEN 577 +#define TIME 578 +#define TIMESTAMP 579 +#define TO 580 +#define TRAILING 581 +#define TRANSACTION 582 +#define TREAT 583 +#define TRIGGER 584 +#define TRIM 585 +#define TRUE_P 586 +#define TRUNCATE 587 +#define TRUSTED 588 +#define TYPE_P 589 +#define UNCOMMITTED 590 +#define UNENCRYPTED 591 +#define UNION 592 +#define UNIQUE 593 +#define UNKNOWN 594 +#define UNLISTEN 595 +#define UNTIL 596 +#define UPDATE 597 +#define USER 598 +#define USING 599 +#define VACUUM 600 +#define VALID 601 +#define VALIDATOR 602 +#define VALUE_P 603 +#define VALUES 604 +#define VARCHAR 605 +#define VARYING 606 +#define VERBOSE 607 +#define VERSION_P 608 +#define VIEW 609 +#define VOLATILE 610 +#define WHEN 611 +#define WHERE 612 +#define WHITESPACE_P 613 +#define WITH 614 +#define WITHOUT 615 +#define WORK 616 +#define WRITE 617 +#define XML_P 618 +#define XMLATTRIBUTES 619 +#define XMLCONCAT 620 +#define XMLELEMENT 621 +#define XMLFOREST 622 +#define XMLPARSE 623 +#define XMLPI 624 +#define XMLROOT 625 +#define XMLSERIALIZE 626 +#define YEAR_P 627 +#define YES_P 628 +#define ZONE 629 +#define NULLS_FIRST 630 +#define NULLS_LAST 631 +#define WITH_CASCADED 632 +#define WITH_LOCAL 633 +#define WITH_CHECK 634 +#define IDENT 635 +#define FCONST 636 +#define SCONST 637 +#define BCONST 638 +#define XCONST 639 +#define Op 640 +#define ICONST 641 +#define PARAM 642 +#define POSTFIXOP 643 +#define UMINUS 644 +#define TYPECAST 645 + + + + +/* Copy the first part of user declarations. */ +#line 1 "gram.y" + + +/*#define YYDEBUG 1*/ +/*------------------------------------------------------------------------- + * + * gram.y + * POSTGRES SQL YACC rules/actions + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.603 2007/09/24 01:29:28 adunstan Exp $ + * + * HISTORY + * AUTHOR DATE MAJOR EVENT + * Andrew Yu Sept, 1994 POSTQUEL to SQL conversion + * Andrew Yu Oct, 1994 lispy code conversion + * + * NOTES + * CAPITALS are used to represent terminal symbols. + * non-capitals are used to represent non-terminals. + * SQL92-specific syntax is separated from plain SQL/Postgres syntax + * to help isolate the non-extensible portions of the parser. + * + * In general, nothing in this file should initiate database accesses + * nor depend on changeable state (such as SET variables). If you do + * database accesses, your code will fail when we have aborted the + * current transaction and are just parsing commands to find the next + * ROLLBACK or COMMIT. If you make use of SET variables, then you + * will do the wrong thing in multi-query strings like this: + * SET SQL_inheritance TO off; SELECT * FROM foo; + * because the entire string is parsed by gram.y before the SET gets + * executed. Anything that depends on the database or changeable state + * should be handled during parse analysis so that it happens at the + * right time not the wrong time. The handling of SQL_inheritance is + * a good example. + * + * WARNINGS + * If you use a list, make sure the datum is a node so that the printing + * routines work. + * + * Sometimes we assign constants to makeStrings. Make sure we don't free + * those. + * + *------------------------------------------------------------------------- + */ +#include "pool_parser.h" + +#include +#include +#include +#include +#include + +#include "nodes.h" +#include "keywords.h" +#include "pool_memory.h" +#include "gramparse.h" +#include "makefuncs.h" +#include "pool_string.h" +#include "parser.h" + +/* Location tracking support --- simpler than bison's default */ +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do { \ + if (N) \ + (Current) = (Rhs)[1]; \ + else \ + (Current) = (Rhs)[0]; \ + } while (0) + +/* + * We track token locations in terms of byte offsets from the start of the + * source string, not the column number/line number representation that + * bison uses by default. Also, to minimize overhead we track only one + * location (usually the first token location) for each construct, not + * the beginning and ending locations as bison does by default. It's + * therefore sufficient to make YYLTYPE an int. + */ +#define YYLTYPE int + +/* for XML data type */ +typedef enum +{ + XML_STANDALONE_YES, + XML_STANDALONE_NO, + XML_STANDALONE_NO_VALUE, + XML_STANDALONE_OMITTED +} XmlStandaloneType; + + +/* + * The %name-prefix option below will make bison call base_yylex, but we + * really want it to call filtered_base_yylex (see parser.c). + */ +#define base_yylex filtered_base_yylex + +#define ereport(a,b) yyerror("") +#define Assert +List *parsetree; /* final parse result is delivered here */ + +static bool QueryIsRule = FALSE; + +extern TypeName *SystemTypeName(char *name); +extern List *SystemFuncName(char *name); +extern void yyerror(const char *s); + +/* + * If you need access to certain yacc-generated variables and find that + * they're static by default, uncomment the next line. (this is not a + * problem, yet.) + */ +/*#define __YYSCLASS*/ + +static Node *makeColumnRef(char *relname, List *indirection, int location); +static Node *makeTypeCast(Node *arg, TypeName *typename); +static Node *makeStringConst(char *str, TypeName *typename); +static Node *makeIntConst(int val); +static Node *makeFloatConst(char *str); +static Node *makeAConst(Value *v); +static A_Const *makeBoolAConst(bool state); +static FuncCall *makeOverlaps(List *largs, List *rargs, int location); +static void check_qualified_name(List *names); +static List *check_func_name(List *names); +static List *extractArgTypes(List *parameters); +static SelectStmt *findLeftmostSelect(SelectStmt *node); +static void insertSelectOptions(SelectStmt *stmt, + List *sortClause, List *lockingClause, + Node *limitOffset, Node *limitCount); +static Node *makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg); +static Node *doNegate(Node *n, int location); +static void doNegateFloat(Value *v); +static Node *makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args); +static DefElem *defWithOids(bool value); + + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 146 "gram.y" +typedef union YYSTYPE { + int ival; + char chr; + char *str; + const char *keyword; + bool boolean; + JoinType jtype; + DropBehavior dbehavior; + OnCommitAction oncommit; + List *list; + Node *node; + Value *value; + ObjectType objtype; + + TypeName *typnam; + FunctionParameter *fun_param; + FunctionParameterMode fun_param_mode; + FuncWithArgs *funwithargs; + DefElem *defelt; + SortBy *sortby; + JoinExpr *jexpr; + IndexElem *ielem; + Alias *alias; + RangeVar *range; + IntoClause *into; + A_Indices *aind; + ResTarget *target; + PrivTarget *privtarget; + + InsertStmt *istmt; + VariableSetStmt *vsetstmt; +} YYSTYPE; +/* Line 196 of yacc.c. */ +#line 1047 "gram.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 219 of yacc.c. */ +#line 1071 "gram.c" + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYINCLUDED_STDLIB_H +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) +# endif +# ifdef __cplusplus +extern "C" { +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ + && (defined (__STDC__) || defined (__cplusplus))) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifdef __cplusplus +} +# endif +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \ + && defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + YYLTYPE yyls; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 621 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 48561 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 408 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 427 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 1812 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 3287 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 645 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned short int yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 396, 2, 2, + 401, 402, 394, 392, 406, 393, 404, 395, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 407, 405, + 389, 388, 390, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 399, 2, 400, 397, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 391, 398, 403 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short int yyprhs[] = +{ + 0, 0, 3, 5, 9, 11, 13, 15, 17, 19, + 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, + 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, + 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, + 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, + 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, + 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, + 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, + 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, + 181, 183, 185, 187, 189, 191, 193, 194, 200, 202, + 203, 206, 207, 210, 213, 217, 221, 223, 225, 227, + 229, 231, 233, 235, 237, 239, 241, 243, 245, 249, + 253, 256, 259, 262, 265, 269, 273, 279, 285, 290, + 296, 301, 305, 311, 315, 321, 327, 334, 336, 338, + 342, 348, 355, 360, 362, 363, 366, 367, 369, 371, + 373, 375, 377, 379, 382, 386, 390, 394, 398, 402, + 406, 410, 414, 417, 423, 426, 429, 433, 437, 441, + 443, 447, 449, 453, 455, 457, 459, 462, 465, 468, + 470, 472, 474, 476, 478, 480, 482, 486, 493, 495, + 497, 499, 501, 503, 504, 506, 508, 511, 515, 520, + 524, 527, 530, 532, 535, 539, 544, 548, 551, 556, + 558, 560, 562, 564, 566, 569, 572, 575, 578, 583, + 588, 590, 594, 598, 603, 610, 617, 624, 631, 636, + 643, 646, 651, 655, 659, 663, 667, 672, 677, 681, + 685, 689, 693, 697, 701, 706, 711, 715, 718, 722, + 724, 726, 730, 734, 738, 741, 744, 748, 751, 753, + 755, 756, 759, 760, 763, 766, 777, 784, 786, 788, + 790, 792, 794, 797, 798, 800, 802, 806, 810, 812, + 814, 818, 822, 826, 831, 833, 834, 837, 838, 842, + 843, 845, 846, 858, 871, 873, 875, 878, 881, 884, + 887, 888, 890, 891, 893, 897, 899, 901, 903, 907, + 910, 911, 915, 917, 919, 922, 924, 928, 933, 938, + 941, 947, 949, 952, 955, 958, 962, 965, 966, 969, + 972, 975, 978, 981, 984, 988, 990, 995, 1002, 1010, + 1022, 1026, 1027, 1029, 1033, 1035, 1038, 1041, 1044, 1045, + 1047, 1049, 1052, 1055, 1056, 1060, 1064, 1067, 1069, 1071, + 1074, 1077, 1082, 1083, 1086, 1089, 1092, 1093, 1097, 1102, + 1107, 1108, 1111, 1112, 1117, 1118, 1125, 1131, 1135, 1136, + 1138, 1142, 1144, 1150, 1155, 1158, 1159, 1162, 1164, 1167, + 1171, 1174, 1177, 1180, 1183, 1187, 1191, 1195, 1197, 1198, + 1200, 1202, 1204, 1207, 1209, 1215, 1225, 1227, 1228, 1230, + 1233, 1236, 1237, 1240, 1241, 1247, 1255, 1257, 1258, 1265, + 1268, 1269, 1273, 1279, 1294, 1314, 1316, 1318, 1320, 1324, + 1330, 1332, 1334, 1336, 1340, 1341, 1343, 1344, 1346, 1348, + 1350, 1354, 1355, 1357, 1359, 1361, 1363, 1365, 1367, 1370, + 1371, 1373, 1376, 1378, 1381, 1382, 1385, 1387, 1390, 1393, + 1400, 1409, 1418, 1423, 1429, 1434, 1439, 1444, 1448, 1456, + 1465, 1472, 1479, 1486, 1493, 1497, 1499, 1503, 1507, 1509, + 1511, 1513, 1515, 1517, 1519, 1523, 1527, 1531, 1533, 1537, + 1541, 1543, 1547, 1561, 1563, 1567, 1572, 1580, 1585, 1593, + 1596, 1598, 1599, 1602, 1603, 1605, 1606, 1613, 1622, 1631, + 1633, 1637, 1643, 1649, 1657, 1667, 1675, 1685, 1691, 1698, + 1705, 1710, 1712, 1714, 1716, 1718, 1720, 1722, 1724, 1726, + 1730, 1734, 1738, 1742, 1744, 1748, 1750, 1753, 1756, 1760, + 1765, 1772, 1780, 1788, 1798, 1807, 1816, 1823, 1832, 1842, + 1852, 1860, 1871, 1879, 1888, 1897, 1906, 1915, 1917, 1919, + 1921, 1923, 1925, 1927, 1929, 1931, 1933, 1935, 1937, 1939, + 1941, 1943, 1948, 1951, 1956, 1959, 1960, 1962, 1964, 1966, + 1968, 1971, 1974, 1976, 1978, 1980, 1983, 1986, 1988, 1991, + 1994, 1996, 1998, 2006, 2014, 2025, 2027, 2029, 2032, 2034, + 2038, 2040, 2042, 2044, 2046, 2048, 2051, 2054, 2057, 2060, + 2063, 2066, 2069, 2071, 2075, 2077, 2080, 2084, 2085, 2087, + 2091, 2094, 2101, 2108, 2118, 2122, 2123, 2127, 2128, 2142, + 2157, 2159, 2160, 2163, 2164, 2166, 2170, 2175, 2180, 2187, + 2189, 2192, 2193, 2195, 2197, 2198, 2200, 2202, 2203, 2213, + 2221, 2224, 2225, 2229, 2232, 2234, 2238, 2242, 2246, 2249, + 2252, 2254, 2256, 2258, 2260, 2263, 2265, 2267, 2269, 2274, + 2280, 2282, 2285, 2290, 2296, 2298, 2300, 2302, 2304, 2308, + 2312, 2315, 2318, 2321, 2324, 2326, 2329, 2332, 2334, 2336, + 2340, 2343, 2344, 2350, 2352, 2355, 2357, 2358, 2364, 2372, + 2378, 2386, 2394, 2404, 2406, 2410, 2414, 2418, 2420, 2424, + 2436, 2447, 2450, 2453, 2454, 2464, 2467, 2468, 2473, 2478, + 2483, 2485, 2487, 2489, 2490, 2498, 2505, 2512, 2519, 2526, + 2534, 2544, 2554, 2561, 2568, 2575, 2582, 2589, 2598, 2607, + 2614, 2621, 2628, 2637, 2646, 2655, 2664, 2666, 2667, 2675, + 2682, 2689, 2696, 2703, 2710, 2718, 2725, 2732, 2739, 2746, + 2754, 2764, 2774, 2784, 2791, 2798, 2805, 2814, 2823, 2824, + 2839, 2841, 2843, 2847, 2851, 2853, 2855, 2857, 2859, 2861, + 2863, 2865, 2866, 2868, 2870, 2872, 2874, 2876, 2878, 2879, + 2886, 2895, 2898, 2901, 2904, 2907, 2910, 2914, 2918, 2921, + 2924, 2927, 2930, 2934, 2937, 2943, 2948, 2952, 2956, 2960, + 2962, 2964, 2965, 2969, 2972, 2975, 2977, 2981, 2984, 2986, + 2987, 2996, 3007, 3010, 3014, 3018, 3019, 3022, 3028, 3031, + 3032, 3036, 3040, 3044, 3048, 3052, 3056, 3060, 3064, 3068, + 3073, 3077, 3081, 3083, 3084, 3090, 3095, 3098, 3099, 3104, + 3108, 3114, 3121, 3126, 3133, 3140, 3146, 3154, 3156, 3157, + 3164, 3176, 3188, 3200, 3214, 3224, 3236, 3247, 3251, 3253, + 3258, 3261, 3262, 3267, 3273, 3279, 3282, 3287, 3289, 3291, + 3293, 3294, 3296, 3297, 3299, 3300, 3304, 3305, 3310, 3312, + 3314, 3316, 3318, 3320, 3322, 3324, 3325, 3331, 3335, 3336, + 3338, 3340, 3342, 3344, 3348, 3357, 3361, 3362, 3365, 3369, + 3372, 3376, 3382, 3384, 3389, 3392, 3394, 3398, 3401, 3404, + 3405, 3412, 3415, 3416, 3422, 3426, 3427, 3430, 3433, 3436, + 3440, 3442, 3446, 3448, 3451, 3453, 3454, 3462, 3464, 3468, + 3470, 3472, 3476, 3482, 3485, 3487, 3491, 3499, 3500, 3504, + 3507, 3510, 3513, 3514, 3517, 3520, 3522, 3524, 3528, 3532, + 3534, 3537, 3542, 3547, 3549, 3551, 3560, 3562, 3567, 3572, + 3577, 3580, 3581, 3585, 3589, 3594, 3599, 3604, 3609, 3612, + 3614, 3616, 3617, 3619, 3621, 3622, 3624, 3630, 3632, 3633, + 3635, 3636, 3640, 3642, 3646, 3651, 3655, 3660, 3665, 3668, + 3671, 3676, 3678, 3679, 3681, 3683, 3685, 3689, 3690, 3693, + 3694, 3696, 3700, 3702, 3703, 3705, 3708, 3713, 3718, 3721, + 3722, 3725, 3729, 3732, 3733, 3735, 3739, 3741, 3744, 3746, + 3749, 3755, 3762, 3768, 3770, 3773, 3775, 3780, 3784, 3789, + 3795, 3800, 3806, 3811, 3817, 3820, 3825, 3827, 3830, 3833, + 3836, 3838, 3840, 3841, 3846, 3849, 3851, 3854, 3857, 3862, + 3864, 3867, 3871, 3873, 3876, 3877, 3880, 3885, 3890, 3891, + 3893, 3897, 3900, 3903, 3907, 3913, 3920, 3924, 3929, 3930, + 3932, 3934, 3936, 3938, 3940, 3943, 3949, 3951, 3953, 3955, + 3957, 3960, 3964, 3968, 3969, 3971, 3973, 3975, 3977, 3979, + 3982, 3985, 3988, 3991, 3994, 3996, 4000, 4001, 4003, 4005, + 4007, 4009, 4015, 4018, 4020, 4022, 4024, 4026, 4032, 4035, + 4038, 4041, 4043, 4047, 4051, 4054, 4056, 4057, 4061, 4062, + 4068, 4071, 4077, 4080, 4082, 4086, 4090, 4091, 4093, 4095, + 4097, 4099, 4101, 4103, 4107, 4111, 4115, 4119, 4123, 4127, + 4131, 4132, 4134, 4138, 4144, 4147, 4150, 4154, 4158, 4162, + 4166, 4170, 4174, 4178, 4182, 4186, 4190, 4193, 4196, 4200, + 4204, 4207, 4211, 4217, 4222, 4229, 4233, 4239, 4244, 4251, + 4256, 4263, 4269, 4277, 4281, 4284, 4289, 4292, 4296, 4300, + 4305, 4309, 4314, 4318, 4323, 4329, 4336, 4343, 4351, 4358, + 4366, 4373, 4381, 4385, 4390, 4395, 4402, 4405, 4409, 4414, + 4416, 4420, 4423, 4426, 4430, 4434, 4438, 4442, 4446, 4450, + 4454, 4458, 4462, 4466, 4469, 4472, 4478, 4485, 4492, 4500, + 4504, 4509, 4511, 4513, 4516, 4521, 4523, 4525, 4527, 4530, + 4533, 4536, 4538, 4542, 4547, 4553, 4559, 4564, 4566, 4568, + 4573, 4575, 4580, 4582, 4587, 4589, 4594, 4596, 4598, 4600, + 4602, 4609, 4614, 4619, 4624, 4629, 4636, 4642, 4648, 4654, + 4659, 4666, 4671, 4676, 4681, 4686, 4692, 4700, 4708, 4718, + 4723, 4730, 4736, 4744, 4752, 4760, 4763, 4767, 4771, 4775, + 4780, 4781, 4786, 4788, 4792, 4796, 4798, 4800, 4802, 4805, + 4808, 4809, 4814, 4818, 4824, 4826, 4828, 4830, 4832, 4834, + 4836, 4838, 4840, 4842, 4844, 4846, 4848, 4850, 4852, 4854, + 4859, 4861, 4866, 4868, 4873, 4875, 4878, 4880, 4883, 4885, + 4889, 4893, 4894, 4896, 4900, 4902, 4906, 4910, 4914, 4916, + 4918, 4920, 4922, 4924, 4926, 4928, 4930, 4935, 4939, 4942, + 4946, 4947, 4951, 4955, 4958, 4961, 4963, 4964, 4967, 4970, + 4974, 4977, 4979, 4981, 4985, 4991, 4993, 4996, 5001, 5004, + 5005, 5007, 5008, 5010, 5013, 5016, 5019, 5023, 5029, 5031, + 5034, 5035, 5038, 5040, 5041, 5043, 5045, 5047, 5051, 5055, + 5057, 5061, 5065, 5067, 5069, 5071, 5073, 5075, 5079, 5081, + 5084, 5086, 5090, 5092, 5094, 5096, 5098, 5100, 5102, 5104, + 5107, 5109, 5111, 5113, 5115, 5117, 5120, 5126, 5129, 5133, + 5140, 5142, 5144, 5146, 5148, 5150, 5152, 5154, 5157, 5159, + 5161, 5163, 5165, 5167, 5169, 5171, 5173, 5175, 5177, 5179, + 5181, 5183, 5185, 5187, 5189, 5191, 5193, 5195, 5197, 5199, + 5201, 5203, 5205, 5207, 5209, 5211, 5213, 5215, 5217, 5219, + 5221, 5223, 5225, 5227, 5229, 5231, 5233, 5235, 5237, 5239, + 5241, 5243, 5245, 5247, 5249, 5251, 5253, 5255, 5257, 5259, + 5261, 5263, 5265, 5267, 5269, 5271, 5273, 5275, 5277, 5279, + 5281, 5283, 5285, 5287, 5289, 5291, 5293, 5295, 5297, 5299, + 5301, 5303, 5305, 5307, 5309, 5311, 5313, 5315, 5317, 5319, + 5321, 5323, 5325, 5327, 5329, 5331, 5333, 5335, 5337, 5339, + 5341, 5343, 5345, 5347, 5349, 5351, 5353, 5355, 5357, 5359, + 5361, 5363, 5365, 5367, 5369, 5371, 5373, 5375, 5377, 5379, + 5381, 5383, 5385, 5387, 5389, 5391, 5393, 5395, 5397, 5399, + 5401, 5403, 5405, 5407, 5409, 5411, 5413, 5415, 5417, 5419, + 5421, 5423, 5425, 5427, 5429, 5431, 5433, 5435, 5437, 5439, + 5441, 5443, 5445, 5447, 5449, 5451, 5453, 5455, 5457, 5459, + 5461, 5463, 5465, 5467, 5469, 5471, 5473, 5475, 5477, 5479, + 5481, 5483, 5485, 5487, 5489, 5491, 5493, 5495, 5497, 5499, + 5501, 5503, 5505, 5507, 5509, 5511, 5513, 5515, 5517, 5519, + 5521, 5523, 5525, 5527, 5529, 5531, 5533, 5535, 5537, 5539, + 5541, 5543, 5545, 5547, 5549, 5551, 5553, 5555, 5557, 5559, + 5561, 5563, 5565, 5567, 5569, 5571, 5573, 5575, 5577, 5579, + 5581, 5583, 5585, 5587, 5589, 5591, 5593, 5595, 5597, 5599, + 5601, 5603, 5605, 5607, 5609, 5611, 5613, 5615, 5617, 5619, + 5621, 5623, 5625, 5627, 5629, 5631, 5633, 5635, 5637, 5639, + 5641, 5643, 5645, 5647, 5649, 5651, 5653, 5655, 5657, 5659, + 5661, 5663, 5665, 5667, 5669, 5671, 5673, 5675, 5677, 5679, + 5681, 5683, 5685, 5687, 5689, 5691, 5693, 5695, 5697, 5699, + 5701, 5703, 5705, 5707, 5709, 5711, 5713, 5715, 5717, 5719, + 5721, 5723, 5725, 5727, 5729, 5731, 5733, 5735, 5737, 5739, + 5741, 5743, 5745, 5747, 5749, 5751, 5753, 5755, 5757, 5759, + 5761, 5763, 5765, 5767, 5769, 5771, 5773, 5775, 5777, 5779, + 5781, 5783, 5785, 5787, 5789, 5791, 5793, 5795, 5797, 5799, + 5801, 5803, 5805, 5807, 5809, 5811, 5813, 5815, 5817, 5819, + 5821, 5823, 5825, 5827, 5829, 5831, 5833, 5835, 5837, 5839, + 5841, 5843, 5845, 5847, 5849, 5851, 5853, 5855, 5857, 5859, + 5861, 5863, 5865, 5867, 5869, 5871, 5873, 5875, 5877, 5879, + 5881, 5883, 5885, 5887, 5889, 5891, 5893, 5895, 5897, 5899, + 5901, 5903, 5905, 5907, 5909, 5911, 5913, 5915, 5917, 5919, + 5921, 5923, 5925 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const short int yyrhs[] = +{ + 409, 0, -1, 410, -1, 410, 405, 411, -1, 411, + -1, 650, -1, 651, -1, 656, -1, 607, -1, 424, + -1, 624, -1, 625, -1, 501, -1, 449, -1, 418, + -1, 417, -1, 659, -1, 658, -1, 420, -1, 419, + -1, 664, -1, 447, -1, 457, -1, 661, -1, 564, + -1, 444, -1, 458, -1, 495, -1, 532, -1, 615, + -1, 660, -1, 655, -1, 593, -1, 423, -1, 544, + -1, 550, -1, 551, -1, 508, -1, 427, -1, 500, + -1, 467, -1, 515, -1, 518, -1, 412, -1, 416, + -1, 646, -1, 678, -1, 697, -1, 534, -1, 684, + -1, 448, -1, 533, -1, 617, -1, 426, -1, 554, + -1, 555, -1, 556, -1, 513, -1, 634, -1, 558, + -1, 517, -1, 531, -1, 421, -1, 422, -1, 654, + -1, 676, -1, 670, -1, 567, -1, 570, -1, 581, + -1, 585, -1, 679, -1, 636, -1, 645, -1, 686, + -1, 635, -1, 673, -1, 557, -1, 619, -1, 611, + -1, 610, -1, 612, -1, 622, -1, 571, -1, 582, + -1, 626, -1, 700, -1, 638, -1, 563, -1, 637, + -1, 690, -1, 663, -1, 441, -1, 431, -1, 443, + -1, 643, -1, -1, 67, 277, 825, 413, 414, -1, + 359, -1, -1, 414, 415, -1, -1, 244, 824, -1, + 244, 220, -1, 109, 244, 824, -1, 336, 244, 824, + -1, 312, -1, 214, -1, 154, -1, 211, -1, 68, + -1, 208, -1, 69, -1, 209, -1, 70, -1, 210, + -1, 191, -1, 212, -1, 60, 183, 826, -1, 346, + 341, 824, -1, 343, 814, -1, 314, 823, -1, 8, + 814, -1, 277, 814, -1, 149, 277, 814, -1, 149, + 138, 814, -1, 67, 343, 825, 413, 414, -1, 13, + 277, 825, 413, 414, -1, 13, 277, 825, 442, -1, + 13, 343, 825, 413, 414, -1, 13, 343, 825, 442, + -1, 104, 277, 814, -1, 104, 277, 144, 117, 814, + -1, 104, 343, 814, -1, 104, 343, 144, 117, 814, + -1, 67, 138, 825, 413, 414, -1, 13, 138, 825, + 425, 343, 814, -1, 7, -1, 104, -1, 104, 138, + 814, -1, 104, 138, 144, 117, 814, -1, 67, 283, + 428, 26, 825, 429, -1, 67, 283, 827, 429, -1, + 827, -1, -1, 429, 430, -1, -1, 467, -1, 585, + -1, 500, -1, 518, -1, 570, -1, 643, -1, 293, + 432, -1, 293, 186, 432, -1, 293, 291, 432, -1, + 433, 325, 434, -1, 433, 388, 434, -1, 433, 325, + 87, -1, 433, 388, 87, -1, 433, 131, 73, -1, + 323, 374, 438, -1, 327, 641, -1, 291, 46, 20, + 327, 641, -1, 201, 439, -1, 277, 440, -1, 291, + 26, 440, -1, 291, 26, 87, -1, 363, 233, 773, + -1, 827, -1, 433, 404, 827, -1, 435, -1, 434, + 406, 435, -1, 437, -1, 440, -1, 505, -1, 258, + 335, -1, 258, 57, -1, 267, 258, -1, 290, -1, + 331, -1, 121, -1, 230, -1, 226, -1, 824, -1, + 380, -1, 761, 824, 763, -1, 761, 401, 823, 402, + 824, 763, -1, 505, -1, 87, -1, 186, -1, 824, + -1, 87, -1, -1, 827, -1, 382, -1, 270, 433, + -1, 270, 323, 374, -1, 270, 327, 171, 181, -1, + 270, 291, 26, -1, 270, 11, -1, 293, 432, -1, + 441, -1, 296, 433, -1, 296, 323, 374, -1, 296, + 327, 171, 181, -1, 296, 291, 26, -1, 296, 11, + -1, 293, 62, 445, 446, -1, 11, -1, 812, -1, + 90, -1, 146, -1, 48, -1, 98, 11, -1, 98, + 318, -1, 98, 320, -1, 98, 246, -1, 13, 316, + 734, 450, -1, 13, 152, 734, 452, -1, 451, -1, + 450, 406, 451, -1, 7, 623, 472, -1, 13, 623, + 827, 454, -1, 13, 623, 827, 104, 215, 220, -1, + 13, 623, 827, 293, 215, 220, -1, 13, 623, 827, + 293, 305, 507, -1, 13, 623, 827, 293, 308, 827, + -1, 104, 623, 827, 455, -1, 13, 623, 827, 334, + 741, 456, -1, 7, 480, -1, 104, 61, 815, 455, + -1, 293, 360, 228, -1, 51, 230, 815, -1, 293, + 360, 51, -1, 107, 329, 815, -1, 107, 14, 329, + 815, -1, 107, 269, 329, 815, -1, 107, 329, 11, + -1, 107, 329, 343, -1, 97, 329, 815, -1, 97, + 329, 11, -1, 97, 329, 343, -1, 107, 281, 815, + -1, 107, 14, 281, 815, -1, 107, 269, 281, 815, + -1, 97, 281, 815, -1, 154, 813, -1, 207, 154, + 813, -1, 453, -1, 453, -1, 452, 406, 453, -1, + 241, 325, 825, -1, 293, 317, 815, -1, 293, 535, + -1, 270, 535, -1, 293, 87, 764, -1, 104, 87, + -1, 39, -1, 272, -1, -1, 344, 764, -1, -1, + 50, 815, -1, 50, 11, -1, 65, 463, 813, 482, + 464, 459, 460, 465, 413, 461, -1, 65, 701, 325, + 460, 413, 461, -1, 131, -1, 325, -1, 824, -1, + 306, -1, 307, -1, 461, 462, -1, -1, 32, -1, + 228, -1, 93, 657, 824, -1, 220, 657, 824, -1, + 72, -1, 141, -1, 257, 657, 824, -1, 112, 657, + 824, -1, 127, 257, 483, -1, 127, 215, 220, 483, + -1, 32, -1, -1, 359, 228, -1, -1, 466, 94, + 824, -1, -1, 344, -1, -1, 67, 468, 316, 813, + 401, 469, 402, 490, 491, 492, 493, -1, 67, 468, + 316, 813, 225, 813, 401, 469, 402, 491, 492, 493, + -1, 320, -1, 318, -1, 186, 320, -1, 186, 318, + -1, 134, 320, -1, 134, 318, -1, -1, 470, -1, + -1, 471, -1, 470, 406, 471, -1, 472, -1, 477, + -1, 480, -1, 827, 741, 473, -1, 473, 474, -1, + -1, 61, 815, 475, -1, 475, -1, 476, -1, 215, + 220, -1, 220, -1, 338, 606, 494, -1, 252, 173, + 606, 494, -1, 47, 401, 764, 402, -1, 87, 765, + -1, 262, 813, 482, 485, 486, -1, 89, -1, 215, + 89, -1, 156, 90, -1, 156, 146, -1, 182, 813, + 478, -1, 478, 479, -1, -1, 150, 88, -1, 114, + 88, -1, 150, 62, -1, 114, 62, -1, 150, 153, + -1, 114, 153, -1, 61, 815, 481, -1, 481, -1, + 47, 401, 764, 402, -1, 338, 401, 483, 402, 606, + 494, -1, 252, 173, 401, 483, 402, 606, 494, -1, + 128, 173, 401, 483, 402, 262, 813, 482, 485, 486, + 528, -1, 401, 483, 402, -1, -1, 484, -1, 483, + 406, 484, -1, 827, -1, 193, 132, -1, 193, 243, + -1, 193, 298, -1, -1, 487, -1, 488, -1, 487, + 488, -1, 488, 487, -1, -1, 230, 342, 489, -1, + 230, 92, 489, -1, 207, 6, -1, 272, -1, 39, + -1, 293, 220, -1, 293, 87, -1, 155, 401, 812, + 402, -1, -1, 359, 535, -1, 359, 228, -1, 360, + 228, -1, -1, 230, 56, 104, -1, 230, 56, 92, + 280, -1, 230, 56, 249, 280, -1, -1, 317, 815, + -1, -1, 344, 152, 317, 815, -1, -1, 67, 468, + 316, 496, 20, 700, -1, 813, 497, 491, 492, 493, + -1, 401, 498, 402, -1, -1, 499, -1, 498, 406, + 499, -1, 827, -1, 67, 468, 289, 813, 502, -1, + 13, 289, 813, 502, -1, 502, 503, -1, -1, 37, + 505, -1, 80, -1, 207, 80, -1, 151, 504, 505, + -1, 194, 505, -1, 196, 505, -1, 207, 194, -1, + 207, 196, -1, 240, 36, 561, -1, 303, 413, 505, + -1, 271, 413, 505, -1, 36, -1, -1, 506, -1, + 507, -1, 381, -1, 393, 381, -1, 826, -1, 67, + 509, 514, 175, 440, -1, 67, 509, 514, 175, 440, + 139, 510, 511, 512, -1, 333, -1, -1, 815, -1, + 815, 562, -1, 347, 510, -1, -1, 174, 824, -1, + -1, 104, 514, 175, 440, 455, -1, 104, 514, 175, + 144, 117, 440, 455, -1, 255, -1, -1, 67, 317, + 815, 516, 189, 824, -1, 241, 815, -1, -1, 104, + 317, 815, -1, 104, 317, 144, 117, 815, -1, 67, + 329, 815, 519, 520, 230, 813, 522, 116, 256, 821, + 401, 525, 402, -1, 67, 61, 329, 815, 9, 520, + 230, 813, 527, 528, 126, 105, 279, 116, 256, 821, + 401, 525, 402, -1, 28, -1, 9, -1, 521, -1, + 521, 234, 521, -1, 521, 234, 521, 234, 521, -1, + 161, -1, 92, -1, 342, -1, 126, 523, 524, -1, + -1, 105, -1, -1, 279, -1, 304, -1, 526, -1, + 525, 406, 526, -1, -1, 386, -1, 381, -1, 824, + -1, 383, -1, 384, -1, 827, -1, 131, 813, -1, + -1, 529, -1, 529, 530, -1, 530, -1, 530, 529, + -1, -1, 215, 89, -1, 89, -1, 156, 146, -1, + 156, 90, -1, 104, 329, 815, 230, 813, 455, -1, + 104, 329, 144, 117, 815, 230, 813, 455, -1, 67, + 22, 815, 47, 401, 764, 402, 528, -1, 104, 22, + 815, 455, -1, 67, 10, 821, 539, 535, -1, 67, + 10, 821, 540, -1, 67, 232, 614, 535, -1, 67, + 334, 561, 535, -1, 67, 334, 561, -1, 67, 334, + 561, 20, 401, 739, 402, -1, 67, 334, 561, 20, + 111, 401, 543, 402, -1, 67, 321, 285, 242, 561, + 535, -1, 67, 321, 285, 96, 561, 535, -1, 67, + 321, 285, 319, 561, 535, -1, 67, 321, 285, 59, + 561, 535, -1, 401, 536, 402, -1, 537, -1, 536, + 406, 537, -1, 829, 388, 538, -1, 829, -1, 601, + -1, 833, -1, 780, -1, 505, -1, 824, -1, 401, + 784, 402, -1, 401, 394, 402, -1, 401, 541, 402, + -1, 542, -1, 541, 406, 542, -1, 380, 388, 538, + -1, 824, -1, 543, 406, 824, -1, 67, 232, 49, + 561, 547, 126, 334, 741, 344, 817, 548, 20, 545, + -1, 546, -1, 545, 406, 546, -1, 232, 823, 614, + 549, -1, 232, 823, 614, 401, 613, 402, 549, -1, + 133, 823, 821, 595, -1, 133, 823, 401, 784, 402, + 821, 595, -1, 308, 741, -1, 87, -1, -1, 122, + 561, -1, -1, 261, -1, -1, 67, 232, 122, 561, + 344, 817, -1, 13, 232, 122, 561, 344, 817, 7, + 545, -1, 13, 232, 122, 561, 344, 817, 104, 552, + -1, 553, -1, 552, 406, 553, -1, 232, 823, 401, + 784, 402, -1, 133, 823, 401, 784, 402, -1, 104, + 232, 49, 561, 344, 817, 455, -1, 104, 232, 49, + 144, 117, 561, 344, 817, 455, -1, 104, 232, 122, + 561, 344, 817, 455, -1, 104, 232, 122, 144, 117, + 561, 344, 817, 455, -1, 104, 240, 36, 814, 455, + -1, 260, 240, 36, 814, 325, 815, -1, 104, 559, + 144, 117, 560, 455, -1, 104, 559, 560, 455, -1, + 316, -1, 289, -1, 354, -1, 152, -1, 334, -1, + 102, -1, 64, -1, 283, -1, 321, 285, 242, -1, + 321, 285, 96, -1, 321, 285, 319, -1, 321, 285, + 59, -1, 561, -1, 560, 406, 561, -1, 827, -1, + 827, 562, -1, 404, 818, -1, 562, 404, 818, -1, + 332, 707, 812, 455, -1, 55, 230, 565, 561, 169, + 566, -1, 55, 230, 10, 821, 539, 169, 566, -1, + 55, 230, 133, 821, 595, 169, 566, -1, 55, 230, + 232, 614, 401, 613, 402, 169, 566, -1, 55, 230, + 61, 815, 230, 561, 169, 566, -1, 55, 230, 281, + 815, 230, 561, 169, 566, -1, 55, 230, 281, 815, + 169, 566, -1, 55, 230, 329, 815, 230, 561, 169, + 566, -1, 55, 230, 232, 49, 561, 344, 817, 169, + 566, -1, 55, 230, 232, 122, 561, 344, 817, 169, + 566, -1, 55, 230, 176, 224, 505, 169, 566, -1, + 55, 230, 42, 401, 741, 20, 741, 402, 169, 566, + -1, 55, 230, 514, 175, 561, 169, 566, -1, 55, + 230, 321, 285, 242, 561, 169, 566, -1, 55, 230, + 321, 285, 96, 561, 169, 566, -1, 55, 230, 321, + 285, 319, 561, 169, 566, -1, 55, 230, 321, 285, + 59, 561, 169, 566, -1, 54, -1, 81, -1, 283, + -1, 152, -1, 289, -1, 316, -1, 102, -1, 334, + -1, 354, -1, 64, -1, 317, -1, 277, -1, 824, + -1, 220, -1, 123, 568, 569, 815, -1, 123, 815, + -1, 199, 568, 569, 815, -1, 199, 815, -1, -1, + 206, -1, 253, -1, 124, -1, 177, -1, 4, 826, + -1, 264, 826, -1, 826, -1, 11, -1, 129, -1, + 129, 826, -1, 129, 11, -1, 27, -1, 27, 826, + -1, 27, 11, -1, 131, -1, 149, -1, 135, 572, + 230, 575, 325, 576, 578, -1, 275, 572, 230, 575, + 131, 576, 455, -1, 275, 135, 233, 126, 572, 230, + 575, 131, 576, 455, -1, 573, -1, 11, -1, 11, + 254, -1, 574, -1, 573, 406, 574, -1, 288, -1, + 262, -1, 67, -1, 827, -1, 812, -1, 316, 812, + -1, 289, 812, -1, 133, 579, -1, 81, 814, -1, + 175, 814, -1, 283, 814, -1, 317, 814, -1, 577, + -1, 576, 406, 577, -1, 825, -1, 138, 825, -1, + 359, 135, 233, -1, -1, 580, -1, 579, 406, 580, + -1, 821, 595, -1, 135, 573, 325, 814, 583, 584, + -1, 275, 573, 131, 814, 584, 455, -1, 275, 8, + 233, 126, 573, 131, 814, 584, 455, -1, 359, 8, + 233, -1, -1, 136, 36, 825, -1, -1, 67, 586, + 152, 819, 230, 813, 587, 401, 588, 402, 606, 493, + 737, -1, 67, 586, 152, 58, 819, 230, 813, 587, + 401, 588, 402, 606, 493, 737, -1, 338, -1, -1, + 344, 817, -1, -1, 589, -1, 588, 406, 589, -1, + 827, 590, 591, 592, -1, 767, 590, 591, 592, -1, + 401, 764, 402, 590, 591, 592, -1, 561, -1, 344, + 561, -1, -1, 21, -1, 95, -1, -1, 375, -1, + 376, -1, -1, 67, 594, 133, 821, 595, 274, 600, + 602, 606, -1, 67, 594, 133, 821, 595, 602, 606, + -1, 234, 268, -1, -1, 401, 596, 402, -1, 401, + 402, -1, 597, -1, 596, 406, 597, -1, 598, 599, + 601, -1, 599, 598, 601, -1, 599, 601, -1, 598, + 601, -1, 601, -1, 149, -1, 236, -1, 158, -1, + 149, 236, -1, 828, -1, 601, -1, 741, -1, 828, + 562, 396, 334, -1, 294, 828, 562, 396, 334, -1, + 604, -1, 602, 604, -1, 38, 230, 220, 159, -1, + 274, 220, 230, 220, 159, -1, 309, -1, 147, -1, + 301, -1, 355, -1, 119, 287, 91, -1, 119, 287, + 168, -1, 287, 91, -1, 287, 168, -1, 66, 505, + -1, 280, 505, -1, 442, -1, 20, 605, -1, 175, + 440, -1, 603, -1, 824, -1, 824, 406, 824, -1, + 359, 535, -1, -1, 13, 133, 580, 608, 609, -1, + 603, -1, 608, 603, -1, 272, -1, -1, 104, 133, + 821, 595, 455, -1, 104, 133, 144, 117, 821, 595, + 455, -1, 104, 10, 821, 539, 455, -1, 104, 10, + 144, 117, 821, 539, 455, -1, 104, 232, 614, 401, + 613, 402, 455, -1, 104, 232, 144, 117, 614, 401, + 613, 402, 455, -1, 741, -1, 741, 406, 741, -1, + 213, 406, 741, -1, 741, 406, 213, -1, 777, -1, + 827, 404, 614, -1, 67, 42, 401, 741, 20, 741, + 402, 359, 133, 580, 616, -1, 67, 42, 401, 741, + 20, 741, 402, 360, 133, 616, -1, 20, 148, -1, + 20, 23, -1, -1, 104, 42, 618, 401, 741, 20, + 741, 402, 455, -1, 144, 117, -1, -1, 263, 620, + 813, 621, -1, 263, 315, 815, 621, -1, 263, 81, + 815, 621, -1, 152, -1, 316, -1, 127, -1, -1, + 13, 10, 821, 539, 266, 325, 815, -1, 13, 64, + 561, 266, 325, 815, -1, 13, 81, 816, 266, 325, + 816, -1, 13, 133, 580, 266, 325, 815, -1, 13, + 138, 825, 266, 325, 825, -1, 13, 514, 175, 815, + 266, 325, 815, -1, 13, 232, 49, 561, 344, 817, + 266, 325, 815, -1, 13, 232, 122, 561, 344, 817, + 266, 325, 815, -1, 13, 283, 815, 266, 325, 815, + -1, 13, 316, 734, 266, 325, 815, -1, 13, 289, + 734, 266, 325, 815, -1, 13, 354, 734, 266, 325, + 815, -1, 13, 152, 734, 266, 325, 815, -1, 13, + 316, 734, 266, 623, 815, 325, 815, -1, 13, 329, + 815, 230, 734, 266, 325, 815, -1, 13, 277, 825, + 266, 325, 825, -1, 13, 343, 825, 266, 325, 825, + -1, 13, 317, 815, 266, 325, 815, -1, 13, 321, + 285, 242, 561, 266, 325, 815, -1, 13, 321, 285, + 96, 561, 266, 325, 815, -1, 13, 321, 285, 319, + 561, 266, 325, 815, -1, 13, 321, 285, 59, 561, + 266, 325, 815, -1, 54, -1, -1, 13, 10, 821, + 539, 293, 283, 815, -1, 13, 102, 561, 293, 283, + 815, -1, 13, 133, 580, 293, 283, 815, -1, 13, + 289, 734, 293, 283, 815, -1, 13, 316, 734, 293, + 283, 815, -1, 13, 334, 561, 293, 283, 815, -1, + 13, 10, 821, 539, 241, 325, 825, -1, 13, 64, + 561, 241, 325, 825, -1, 13, 81, 816, 241, 325, + 825, -1, 13, 102, 561, 241, 325, 825, -1, 13, + 133, 580, 241, 325, 825, -1, 13, 514, 175, 815, + 241, 325, 825, -1, 13, 232, 614, 401, 613, 402, + 241, 325, 825, -1, 13, 232, 49, 561, 344, 817, + 241, 325, 825, -1, 13, 232, 122, 561, 344, 817, + 241, 325, 825, -1, 13, 283, 815, 241, 325, 825, + -1, 13, 334, 561, 241, 325, 825, -1, 13, 317, + 815, 241, 325, 825, -1, 13, 321, 285, 96, 561, + 241, 325, 825, -1, 13, 321, 285, 59, 561, 241, + 325, 825, -1, -1, 67, 594, 281, 815, 20, 627, + 230, 632, 325, 813, 737, 100, 633, 628, -1, 216, + -1, 630, -1, 401, 629, 402, -1, 629, 405, 631, + -1, 631, -1, 700, -1, 679, -1, 690, -1, 684, + -1, 635, -1, 630, -1, -1, 288, -1, 342, -1, + 92, -1, 161, -1, 162, -1, 12, -1, -1, 104, + 281, 815, 230, 813, 455, -1, 104, 281, 144, 117, + 815, 230, 813, 455, -1, 217, 827, -1, 184, 827, + -1, 340, 827, -1, 340, 394, -1, 3, 639, -1, + 29, 639, 642, -1, 303, 327, 642, -1, 56, 639, + -1, 110, 639, -1, 278, 639, -1, 282, 827, -1, + 265, 282, 827, -1, 265, 827, -1, 278, 639, 325, + 282, 827, -1, 278, 639, 325, 827, -1, 250, 327, + 824, -1, 56, 251, 824, -1, 278, 251, 824, -1, + 361, -1, 327, -1, -1, 171, 181, 436, -1, 258, + 231, -1, 258, 362, -1, 640, -1, 641, 406, 640, + -1, 641, 640, -1, 641, -1, -1, 67, 468, 354, + 813, 482, 20, 700, 644, -1, 67, 234, 268, 468, + 354, 813, 482, 20, 700, 644, -1, 379, 233, -1, + 377, 47, 233, -1, 378, 47, 233, -1, -1, 185, + 820, -1, 67, 81, 816, 413, 647, -1, 647, 648, + -1, -1, 317, 649, 815, -1, 317, 649, 87, -1, + 189, 649, 824, -1, 189, 649, 87, -1, 319, 649, + 815, -1, 319, 649, 87, -1, 108, 649, 824, -1, + 108, 649, 823, -1, 108, 649, 87, -1, 60, 183, + 649, 826, -1, 241, 649, 815, -1, 241, 649, 87, + -1, 388, -1, -1, 13, 81, 816, 413, 652, -1, + 13, 81, 816, 442, -1, 652, 653, -1, -1, 60, + 183, 649, 826, -1, 104, 81, 816, -1, 104, 81, + 144, 117, 816, -1, 67, 102, 561, 657, 741, 473, + -1, 13, 102, 561, 454, -1, 13, 102, 561, 104, + 215, 220, -1, 13, 102, 561, 293, 215, 220, -1, + 13, 102, 561, 7, 480, -1, 13, 102, 561, 104, + 61, 815, 455, -1, 20, -1, -1, 13, 321, 285, + 96, 561, 535, -1, 13, 321, 285, 59, 561, 7, + 192, 126, 814, 359, 560, -1, 13, 321, 285, 59, + 561, 13, 192, 126, 814, 359, 560, -1, 13, 321, + 285, 59, 561, 13, 192, 268, 561, 359, 561, -1, + 13, 321, 285, 59, 561, 13, 192, 126, 814, 268, + 561, 359, 561, -1, 13, 321, 285, 59, 561, 104, + 192, 126, 814, -1, 13, 321, 285, 59, 561, 104, + 192, 144, 117, 126, 814, -1, 67, 547, 64, 561, + 126, 824, 325, 824, 131, 561, -1, 51, 813, 662, + -1, 51, -1, 51, 819, 230, 813, -1, 344, 819, + -1, -1, 345, 667, 668, 666, -1, 345, 667, 668, + 666, 813, -1, 345, 667, 668, 666, 664, -1, 665, + 666, -1, 665, 666, 813, 669, -1, 16, -1, 15, + -1, 352, -1, -1, 132, -1, -1, 130, -1, -1, + 401, 814, 402, -1, -1, 118, 672, 666, 671, -1, + 700, -1, 679, -1, 690, -1, 684, -1, 697, -1, + 676, -1, 665, -1, -1, 250, 815, 674, 20, 675, + -1, 401, 784, 402, -1, -1, 700, -1, 679, -1, + 690, -1, 684, -1, 116, 815, 677, -1, 67, 468, + 316, 496, 20, 116, 815, 677, -1, 401, 782, 402, + -1, -1, 83, 815, -1, 83, 250, 815, -1, 83, + 11, -1, 83, 250, 11, -1, 161, 167, 813, 680, + 683, -1, 700, -1, 401, 681, 402, 700, -1, 87, + 349, -1, 682, -1, 681, 406, 682, -1, 827, 804, + -1, 273, 809, -1, -1, 92, 131, 735, 685, 738, + 683, -1, 344, 727, -1, -1, 190, 707, 812, 687, + 689, -1, 149, 688, 197, -1, -1, 5, 295, -1, + 279, 295, -1, 279, 115, -1, 295, 342, 115, -1, + 295, -1, 295, 279, 115, -1, 115, -1, 5, 115, + -1, 219, -1, -1, 342, 735, 293, 691, 726, 738, + 683, -1, 692, -1, 691, 406, 692, -1, 693, -1, + 694, -1, 695, 388, 806, -1, 401, 696, 402, 388, + 808, -1, 827, 804, -1, 695, -1, 696, 406, 695, + -1, 86, 815, 698, 79, 699, 126, 700, -1, -1, + 698, 207, 284, -1, 698, 284, -1, 698, 32, -1, + 698, 160, -1, -1, 359, 142, -1, 360, 142, -1, + 702, -1, 701, -1, 401, 702, 402, -1, 401, 701, + 402, -1, 704, -1, 703, 711, -1, 703, 710, 720, + 715, -1, 703, 710, 714, 721, -1, 704, -1, 701, + -1, 288, 709, 809, 705, 726, 737, 718, 719, -1, + 725, -1, 703, 337, 708, 703, -1, 703, 165, 708, + 703, -1, 703, 113, 708, 703, -1, 167, 706, -1, + -1, 320, 707, 813, -1, 318, 707, 813, -1, 186, + 320, 707, 813, -1, 186, 318, 707, 813, -1, 134, + 320, 707, 813, -1, 134, 318, 707, 813, -1, 316, + 813, -1, 813, -1, 316, -1, -1, 11, -1, 99, + -1, -1, 99, -1, 99, 230, 401, 782, 402, -1, + 11, -1, -1, 711, -1, -1, 235, 36, 712, -1, + 713, -1, 712, 406, 713, -1, 764, 344, 780, 592, + -1, 764, 591, 592, -1, 183, 716, 227, 717, -1, + 227, 717, 183, 716, -1, 183, 716, -1, 227, 717, + -1, 183, 716, 406, 717, -1, 714, -1, -1, 764, + -1, 11, -1, 764, -1, 138, 36, 782, -1, -1, + 140, 764, -1, -1, 722, -1, 126, 258, 231, -1, + 720, -1, -1, 723, -1, 722, 723, -1, 126, 342, + 724, 689, -1, 126, 295, 724, 689, -1, 225, 814, + -1, -1, 349, 808, -1, 725, 406, 808, -1, 131, + 727, -1, -1, 728, -1, 727, 406, 728, -1, 734, + -1, 734, 730, -1, 736, -1, 736, 730, -1, 736, + 20, 401, 739, 402, -1, 736, 20, 827, 401, 739, + 402, -1, 736, 827, 401, 739, 402, -1, 701, -1, + 701, 730, -1, 729, -1, 401, 729, 402, 730, -1, + 401, 729, 402, -1, 728, 71, 172, 728, -1, 728, + 731, 172, 728, 733, -1, 728, 172, 728, 733, -1, + 728, 203, 731, 172, 728, -1, 728, 203, 172, 728, + -1, 20, 827, 401, 814, 402, -1, 20, 827, -1, + 827, 401, 814, 402, -1, 827, -1, 132, 732, -1, + 180, 732, -1, 276, 732, -1, 157, -1, 237, -1, + -1, 344, 401, 814, 402, -1, 230, 764, -1, 813, + -1, 813, 394, -1, 231, 813, -1, 231, 401, 813, + 402, -1, 734, -1, 734, 827, -1, 734, 20, 827, + -1, 767, -1, 357, 764, -1, -1, 357, 764, -1, + 357, 73, 225, 815, -1, 357, 73, 225, 387, -1, + -1, 740, -1, 739, 406, 740, -1, 827, 741, -1, + 743, 742, -1, 294, 743, 742, -1, 743, 19, 399, + 823, 400, -1, 294, 743, 19, 399, 823, 400, -1, + 742, 399, 400, -1, 742, 399, 823, 400, -1, -1, + 745, -1, 747, -1, 749, -1, 753, -1, 760, -1, + 761, 763, -1, 761, 401, 823, 402, 763, -1, 747, + -1, 750, -1, 754, -1, 760, -1, 828, 746, -1, + 828, 562, 746, -1, 401, 782, 402, -1, -1, 163, + -1, 164, -1, 299, -1, 31, -1, 259, -1, 125, + 748, -1, 103, 248, -1, 85, 746, -1, 84, 746, + -1, 223, 746, -1, 34, -1, 401, 823, 402, -1, + -1, 751, -1, 752, -1, 751, -1, 752, -1, 33, + 758, 401, 782, 402, -1, 33, 758, -1, 755, -1, + 756, -1, 755, -1, 756, -1, 757, 401, 823, 402, + 759, -1, 757, 759, -1, 45, 758, -1, 44, 758, + -1, 350, -1, 202, 45, 758, -1, 202, 44, 758, + -1, 204, 758, -1, 351, -1, -1, 45, 293, 827, + -1, -1, 324, 401, 823, 402, 762, -1, 324, 762, + -1, 323, 401, 823, 402, 762, -1, 323, 762, -1, + 166, -1, 359, 323, 374, -1, 360, 323, 374, -1, + -1, 372, -1, 198, -1, 82, -1, 143, -1, 195, + -1, 286, -1, 372, 325, 198, -1, 82, 325, 143, + -1, 82, 325, 195, -1, 82, 325, 286, -1, 143, + 325, 195, -1, 143, 325, 286, -1, 195, 325, 286, + -1, -1, 766, -1, 764, 403, 741, -1, 764, 25, + 323, 374, 764, -1, 392, 764, -1, 393, 764, -1, + 764, 392, 764, -1, 764, 393, 764, -1, 764, 394, + 764, -1, 764, 395, 764, -1, 764, 396, 764, -1, + 764, 397, 764, -1, 764, 389, 764, -1, 764, 390, + 764, -1, 764, 388, 764, -1, 764, 779, 764, -1, + 779, 764, -1, 764, 779, -1, 764, 17, 764, -1, + 764, 234, 764, -1, 215, 764, -1, 764, 182, 764, + -1, 764, 182, 764, 112, 764, -1, 764, 215, 182, + 764, -1, 764, 215, 182, 764, 112, 764, -1, 764, + 145, 764, -1, 764, 145, 764, 112, 764, -1, 764, + 215, 145, 764, -1, 764, 215, 145, 764, 112, 764, + -1, 764, 297, 325, 764, -1, 764, 297, 325, 764, + 112, 764, -1, 764, 215, 297, 325, 764, -1, 764, + 215, 297, 325, 764, 112, 764, -1, 764, 169, 220, + -1, 764, 170, -1, 764, 169, 215, 220, -1, 764, + 218, -1, 775, 238, 775, -1, 764, 169, 331, -1, + 764, 169, 215, 331, -1, 764, 169, 121, -1, 764, + 169, 215, 121, -1, 764, 169, 339, -1, 764, 169, + 215, 339, -1, 764, 169, 99, 131, 764, -1, 764, + 169, 215, 99, 131, 764, -1, 764, 169, 225, 401, + 784, 402, -1, 764, 169, 215, 225, 401, 784, 402, + -1, 764, 30, 805, 765, 17, 765, -1, 764, 215, + 30, 805, 765, 17, 765, -1, 764, 30, 313, 765, + 17, 765, -1, 764, 215, 30, 313, 765, 17, 765, + -1, 764, 149, 795, -1, 764, 215, 149, 795, -1, + 764, 781, 776, 701, -1, 764, 781, 776, 401, 764, + 402, -1, 338, 701, -1, 764, 169, 101, -1, 764, + 169, 215, 101, -1, 766, -1, 765, 403, 741, -1, + 392, 765, -1, 393, 765, -1, 765, 392, 765, -1, + 765, 393, 765, -1, 765, 394, 765, -1, 765, 395, + 765, -1, 765, 396, 765, -1, 765, 397, 765, -1, + 765, 389, 765, -1, 765, 390, 765, -1, 765, 388, + 765, -1, 765, 779, 765, -1, 779, 765, -1, 765, + 779, -1, 765, 169, 99, 131, 765, -1, 765, 169, + 215, 99, 131, 765, -1, 765, 169, 225, 401, 784, + 402, -1, 765, 169, 215, 225, 401, 784, 402, -1, + 765, 169, 101, -1, 765, 169, 215, 101, -1, 801, + -1, 822, -1, 387, 804, -1, 401, 764, 402, 804, + -1, 796, -1, 767, -1, 701, -1, 117, 701, -1, + 19, 701, -1, 19, 786, -1, 775, -1, 821, 401, + 402, -1, 821, 401, 782, 402, -1, 821, 401, 11, + 782, 402, -1, 821, 401, 99, 782, 402, -1, 821, + 401, 394, 402, -1, 74, -1, 76, -1, 76, 401, + 823, 402, -1, 77, -1, 77, 401, 823, 402, -1, + 187, -1, 187, 401, 823, 402, -1, 188, -1, 188, + 401, 823, 402, -1, 75, -1, 78, -1, 292, -1, + 343, -1, 42, 401, 764, 20, 741, 402, -1, 120, + 401, 783, 402, -1, 239, 401, 788, 402, -1, 247, + 401, 790, 402, -1, 311, 401, 791, 402, -1, 328, + 401, 764, 20, 741, 402, -1, 330, 401, 35, 794, + 402, -1, 330, 401, 178, 794, 402, -1, 330, 401, + 326, 794, 402, -1, 330, 401, 794, 402, -1, 221, + 401, 764, 406, 764, 402, -1, 52, 401, 782, 402, + -1, 137, 401, 782, 402, -1, 179, 401, 782, 402, + -1, 365, 401, 782, 402, -1, 366, 401, 200, 829, + 402, -1, 366, 401, 200, 829, 406, 770, 402, -1, + 366, 401, 200, 829, 406, 782, 402, -1, 366, 401, + 200, 829, 406, 770, 406, 782, 402, -1, 367, 401, + 771, 402, -1, 368, 401, 773, 764, 774, 402, -1, + 369, 401, 200, 829, 402, -1, 369, 401, 200, 829, + 406, 764, 402, -1, 370, 401, 764, 406, 768, 769, + 402, -1, 371, 401, 773, 764, 20, 743, 402, -1, + 353, 764, -1, 353, 207, 348, -1, 406, 302, 373, + -1, 406, 302, 207, -1, 406, 302, 207, 348, -1, + -1, 364, 401, 771, 402, -1, 772, -1, 771, 406, + 772, -1, 764, 20, 829, -1, 764, -1, 101, -1, + 63, -1, 249, 358, -1, 310, 358, -1, -1, 279, + 401, 782, 402, -1, 279, 401, 402, -1, 401, 782, + 406, 764, 402, -1, 18, -1, 300, -1, 11, -1, + 385, -1, 778, -1, 392, -1, 393, -1, 394, -1, + 395, -1, 396, -1, 397, -1, 389, -1, 390, -1, + 388, -1, 385, -1, 232, 401, 614, 402, -1, 777, + -1, 232, 401, 614, 402, -1, 777, -1, 232, 401, + 614, 402, -1, 182, -1, 215, 182, -1, 145, -1, + 215, 145, -1, 764, -1, 782, 406, 764, -1, 787, + 131, 764, -1, -1, 741, -1, 784, 406, 741, -1, + 786, -1, 785, 406, 786, -1, 399, 782, 400, -1, + 399, 785, 400, -1, 380, -1, 372, -1, 198, -1, + 82, -1, 143, -1, 195, -1, 286, -1, 382, -1, + 764, 789, 792, 793, -1, 764, 789, 792, -1, 245, + 764, -1, 765, 149, 765, -1, -1, 764, 792, 793, + -1, 764, 793, 792, -1, 764, 792, -1, 764, 793, + -1, 782, -1, -1, 131, 764, -1, 126, 764, -1, + 764, 131, 782, -1, 131, 782, -1, 782, -1, 701, + -1, 401, 782, 402, -1, 41, 800, 797, 799, 110, + -1, 798, -1, 797, 798, -1, 356, 764, 322, 764, + -1, 106, 764, -1, -1, 764, -1, -1, 811, -1, + 811, 803, -1, 404, 818, -1, 404, 394, -1, 399, + 764, 400, -1, 399, 764, 407, 764, 400, -1, 802, + -1, 803, 802, -1, -1, 804, 802, -1, 24, -1, + -1, 764, -1, 87, -1, 806, -1, 807, 406, 806, + -1, 401, 807, 402, -1, 810, -1, 809, 406, 810, + -1, 764, 20, 829, -1, 764, -1, 394, -1, 834, + -1, 827, -1, 813, -1, 812, 406, 813, -1, 811, + -1, 811, 803, -1, 815, -1, 814, 406, 815, -1, + 827, -1, 827, -1, 827, -1, 829, -1, 827, -1, + 824, -1, 828, -1, 811, 803, -1, 823, -1, 381, + -1, 824, -1, 383, -1, 384, -1, 821, 824, -1, + 821, 401, 782, 402, 824, -1, 744, 824, -1, 761, + 824, 763, -1, 761, 401, 823, 402, 824, 763, -1, + 331, -1, 121, -1, 220, -1, 386, -1, 382, -1, + 827, -1, 386, -1, 393, 386, -1, 380, -1, 830, + -1, 831, -1, 380, -1, 830, -1, 832, -1, 380, + -1, 830, -1, 831, -1, 832, -1, 833, -1, 3, + -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, + -1, 9, -1, 10, -1, 12, -1, 13, -1, 14, + -1, 22, -1, 23, -1, 25, -1, 27, -1, 28, + -1, 29, -1, 36, -1, 37, -1, 38, -1, 39, + -1, 40, -1, 43, -1, 46, -1, 48, -1, 49, + -1, 50, -1, 51, -1, 55, -1, 56, -1, 57, + -1, 58, -1, 59, -1, 60, -1, 62, -1, 63, + -1, 64, -1, 65, -1, 66, -1, 68, -1, 69, + -1, 70, -1, 72, -1, 73, -1, 79, -1, 80, + -1, 81, -1, 82, -1, 83, -1, 86, -1, 88, + -1, 90, -1, 91, -1, 92, -1, 93, -1, 94, + -1, 96, -1, 97, -1, 98, -1, 101, -1, 102, + -1, 103, -1, 104, -1, 105, -1, 107, -1, 108, + -1, 109, -1, 111, -1, 112, -1, 114, -1, 115, + -1, 116, -1, 118, -1, 119, -1, 122, -1, 123, + -1, 124, -1, 127, -1, 129, -1, 133, -1, 134, + -1, 136, -1, 139, -1, 141, -1, 142, -1, 143, + -1, 144, -1, 146, -1, 147, -1, 148, -1, 150, + -1, 151, -1, 152, -1, 153, -1, 154, -1, 155, + -1, 159, -1, 160, -1, 161, -1, 162, -1, 168, + -1, 171, -1, 173, -1, 174, -1, 175, -1, 176, + -1, 177, -1, 181, -1, 184, -1, 185, -1, 186, + -1, 189, -1, 190, -1, 191, -1, 192, -1, 193, + -1, 194, -1, 195, -1, 196, -1, 197, -1, 198, + -1, 199, -1, 200, -1, 201, -1, 206, -1, 207, + -1, 208, -1, 209, -1, 210, -1, 211, -1, 212, + -1, 214, -1, 216, -1, 217, -1, 219, -1, 222, + -1, 224, -1, 225, -1, 228, -1, 232, -1, 233, + -1, 240, -1, 241, -1, 242, -1, 243, -1, 244, + -1, 246, -1, 250, -1, 251, -1, 249, -1, 253, + -1, 254, -1, 255, -1, 256, -1, 257, -1, 258, + -1, 260, -1, 261, -1, 263, -1, 264, -1, 265, + -1, 266, -1, 267, -1, 268, -1, 269, -1, 270, + -1, 271, -1, 272, -1, 274, -1, 275, -1, 277, + -1, 278, -1, 280, -1, 281, -1, 282, -1, 283, + -1, 284, -1, 285, -1, 286, -1, 287, -1, 289, + -1, 290, -1, 291, -1, 293, -1, 295, -1, 296, + -1, 298, -1, 301, -1, 302, -1, 303, -1, 304, + -1, 305, -1, 306, -1, 307, -1, 308, -1, 309, + -1, 310, -1, 312, -1, 314, -1, 315, -1, 317, + -1, 318, -1, 319, -1, 320, -1, 321, -1, 327, + -1, 329, -1, 332, -1, 333, -1, 334, -1, 335, + -1, 336, -1, 339, -1, 340, -1, 341, -1, 342, + -1, 345, -1, 346, -1, 347, -1, 348, -1, 351, + -1, 353, -1, 354, -1, 355, -1, 358, -1, 359, + -1, 360, -1, 361, -1, 362, -1, 363, -1, 372, + -1, 373, -1, 374, -1, 31, -1, 33, -1, 34, + -1, 44, -1, 45, -1, 52, -1, 84, -1, 85, + -1, 117, -1, 120, -1, 125, -1, 137, -1, 158, + -1, 163, -1, 164, -1, 166, -1, 179, -1, 202, + -1, 204, -1, 213, -1, 221, -1, 223, -1, 236, + -1, 239, -1, 247, -1, 248, -1, 259, -1, 279, + -1, 294, -1, 299, -1, 311, -1, 323, -1, 324, + -1, 328, -1, 330, -1, 349, -1, 350, -1, 364, + -1, 365, -1, 366, -1, 367, -1, 368, -1, 369, + -1, 370, -1, 371, -1, 26, -1, 30, -1, 32, + -1, 71, -1, 130, -1, 132, -1, 145, -1, 157, + -1, 169, -1, 170, -1, 172, -1, 180, -1, 182, + -1, 203, -1, 218, -1, 237, -1, 238, -1, 276, + -1, 297, -1, 352, -1, 11, -1, 15, -1, 16, + -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, + -1, 24, -1, 35, -1, 41, -1, 42, -1, 47, + -1, 53, -1, 54, -1, 61, -1, 67, -1, 74, + -1, 75, -1, 76, -1, 77, -1, 78, -1, 87, + -1, 89, -1, 95, -1, 99, -1, 100, -1, 106, + -1, 110, -1, 113, -1, 121, -1, 126, -1, 128, + -1, 131, -1, 135, -1, 138, -1, 140, -1, 149, + -1, 156, -1, 165, -1, 167, -1, 178, -1, 183, + -1, 187, -1, 188, -1, 205, -1, 215, -1, 220, + -1, 226, -1, 227, -1, 229, -1, 230, -1, 231, + -1, 234, -1, 235, -1, 245, -1, 252, -1, 262, + -1, 273, -1, 288, -1, 292, -1, 300, -1, 313, + -1, 316, -1, 322, -1, 325, -1, 326, -1, 331, + -1, 337, -1, 338, -1, 343, -1, 344, -1, 356, + -1, 357, -1, 229, -1, 205, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short int yyrline[] = +{ + 0, 539, 539, 543, 549, 558, 559, 560, 561, 562, + 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, + 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, + 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, + 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, + 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, + 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, + 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, + 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, + 643, 644, 645, 646, 647, 648, 650, 660, 671, 672, + 681, 682, 686, 691, 695, 700, 705, 709, 713, 717, + 721, 725, 729, 733, 737, 742, 746, 750, 754, 758, + 763, 768, 772, 776, 780, 784, 798, 816, 827, 844, + 856, 876, 883, 902, 909, 926, 944, 955, 956, 968, + 975, 992, 1004, 1016, 1017, 1021, 1022, 1030, 1031, 1032, + 1033, 1034, 1035, 1049, 1055, 1061, 1070, 1078, 1086, 1093, + 1100, 1108, 1119, 1127, 1135, 1146, 1154, 1162, 1169, 1179, + 1180, 1187, 1188, 1191, 1193, 1195, 1199, 1200, 1201, 1202, + 1206, 1207, 1208, 1209, 1221, 1225, 1229, 1242, 1254, 1255, + 1256, 1260, 1261, 1262, 1266, 1267, 1271, 1278, 1285, 1292, + 1299, 1309, 1310, 1315, 1321, 1327, 1333, 1339, 1349, 1359, + 1360, 1364, 1365, 1373, 1388, 1394, 1400, 1406, 1422, 1430, + 1441, 1442, 1448, 1456, 1465, 1473, 1481, 1490, 1499, 1511, + 1521, 1529, 1538, 1545, 1553, 1561, 1569, 1577, 1585, 1592, + 1599, 1607, 1614, 1621, 1629, 1637, 1645, 1653, 1661, 1668, + 1675, 1676, 1682, 1690, 1698, 1706, 1716, 1724, 1728, 1729, + 1730, 1734, 1735, 1748, 1754, 1777, 1799, 1814, 1815, 1824, + 1825, 1826, 1832, 1833, 1838, 1842, 1846, 1850, 1854, 1858, + 1862, 1866, 1870, 1874, 1883, 1887, 1891, 1895, 1900, 1904, + 1908, 1909, 1920, 1934, 1960, 1961, 1962, 1963, 1964, 1965, + 1966, 1970, 1971, 1975, 1979, 1986, 1987, 1988, 1991, 2003, + 2004, 2008, 2029, 2030, 2049, 2060, 2071, 2083, 2095, 2106, + 2125, 2154, 2160, 2166, 2172, 2190, 2200, 2201, 2205, 2206, + 2207, 2208, 2209, 2210, 2219, 2240, 2244, 2254, 2266, 2278, + 2296, 2297, 2301, 2302, 2305, 2311, 2315, 2322, 2327, 2339, + 2341, 2343, 2345, 2348, 2351, 2354, 2358, 2359, 2360, 2361, + 2362, 2365, 2366, 2371, 2372, 2373, 2374, 2377, 2378, 2379, + 2380, 2383, 2384, 2387, 2388, 2398, 2419, 2431, 2432, 2436, + 2437, 2441, 2466, 2477, 2486, 2487, 2490, 2494, 2498, 2502, + 2506, 2510, 2514, 2518, 2522, 2526, 2530, 2536, 2537, 2541, + 2542, 2545, 2546, 2553, 2565, 2575, 2589, 2590, 2598, 2599, + 2603, 2604, 2608, 2609, 2613, 2621, 2632, 2633, 2643, 2653, + 2654, 2667, 2674, 2692, 2710, 2734, 2735, 2739, 2745, 2751, + 2760, 2761, 2762, 2766, 2771, 2781, 2782, 2786, 2787, 2791, + 2792, 2793, 2797, 2803, 2804, 2805, 2806, 2807, 2811, 2812, + 2816, 2818, 2826, 2833, 2842, 2846, 2847, 2851, 2852, 2857, + 2867, 2889, 2908, 2931, 2941, 2952, 2962, 2972, 2983, 3017, + 3024, 3033, 3042, 3051, 3062, 3065, 3066, 3069, 3073, 3080, + 3081, 3082, 3083, 3084, 3087, 3088, 3091, 3094, 3095, 3098, + 3104, 3106, 3123, 3138, 3139, 3143, 3153, 3163, 3172, 3182, + 3191, 3192, 3195, 3196, 3199, 3200, 3205, 3215, 3224, 3236, + 3237, 3241, 3249, 3261, 3270, 3282, 3291, 3312, 3322, 3340, + 3349, 3361, 3362, 3363, 3364, 3365, 3366, 3367, 3368, 3369, + 3370, 3371, 3372, 3376, 3377, 3380, 3381, 3384, 3386, 3399, + 3430, 3439, 3448, 3457, 3467, 3476, 3485, 3495, 3504, 3513, + 3522, 3531, 3540, 3549, 3557, 3565, 3573, 3584, 3585, 3586, + 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3599, + 3600, 3610, 3617, 3626, 3633, 3646, 3652, 3659, 3666, 3673, + 3680, 3687, 3694, 3701, 3708, 3715, 3722, 3729, 3736, 3743, + 3752, 3753, 3763, 3778, 3791, 3817, 3819, 3821, 3825, 3827, + 3831, 3832, 3833, 3834, 3842, 3849, 3856, 3863, 3870, 3877, + 3884, 3891, 3902, 3903, 3906, 3916, 3930, 3931, 3935, 3936, + 3941, 3957, 3970, 3980, 3992, 3993, 3996, 3997, 4012, 4028, + 4047, 4048, 4052, 4053, 4056, 4057, 4065, 4074, 4083, 4094, + 4095, 4096, 4099, 4100, 4101, 4104, 4105, 4106, 4122, 4134, + 4149, 4150, 4153, 4154, 4158, 4159, 4173, 4181, 4189, 4197, + 4205, 4216, 4217, 4218, 4219, 4225, 4229, 4244, 4245, 4251, + 4263, 4264, 4271, 4275, 4279, 4283, 4287, 4291, 4295, 4299, + 4303, 4307, 4311, 4315, 4319, 4327, 4331, 4335, 4341, 4342, + 4349, 4350, 4362, 4373, 4374, 4379, 4380, 4395, 4405, 4418, + 4428, 4441, 4451, 4464, 4471, 4473, 4475, 4480, 4482, 4493, + 4503, 4515, 4516, 4517, 4521, 4532, 4533, 4547, 4555, 4565, + 4578, 4579, 4582, 4583, 4593, 4602, 4610, 4618, 4627, 4635, + 4643, 4652, 4661, 4669, 4678, 4687, 4696, 4705, 4714, 4723, + 4731, 4739, 4747, 4755, 4763, 4771, 4781, 4782, 4792, 4801, + 4809, 4818, 4826, 4834, 4850, 4859, 4867, 4875, 4883, 4892, + 4900, 4909, 4918, 4927, 4935, 4943, 4951, 4959, 4977, 4976, + 4995, 4996, 4997, 5002, 5008, 5017, 5018, 5019, 5020, 5021, + 5025, 5026, 5029, 5030, 5031, 5032, 5036, 5037, 5038, 5043, + 5053, 5074, 5084, 5095, 5103, 5124, 5131, 5138, 5145, 5152, + 5159, 5166, 5174, 5182, 5190, 5198, 5206, 5213, 5220, 5229, + 5230, 5231, 5235, 5238, 5241, 5248, 5250, 5252, 5257, 5259, + 5271, 5282, 5300, 5306, 5312, 5318, 5328, 5344, 5354, 5355, + 5359, 5363, 5367, 5371, 5375, 5379, 5383, 5387, 5391, 5395, + 5399, 5403, 5413, 5414, 5425, 5435, 5446, 5447, 5451, 5465, + 5472, 5489, 5501, 5510, 5518, 5526, 5535, 5546, 5547, 5558, + 5568, 5578, 5588, 5598, 5608, 5616, 5637, 5660, 5667, 5675, + 5685, 5686, 5698, 5710, 5722, 5734, 5746, 5761, 5762, 5766, + 5767, 5770, 5771, 5774, 5775, 5779, 5780, 5791, 5802, 5803, + 5804, 5805, 5806, 5807, 5811, 5812, 5822, 5832, 5833, 5837, + 5838, 5839, 5840, 5850, 5858, 5875, 5876, 5886, 5892, 5898, + 5904, 5920, 5929, 5935, 5941, 5950, 5952, 5957, 5968, 5969, + 5980, 5993, 5994, 5997, 6008, 6009, 6012, 6013, 6014, 6015, + 6016, 6017, 6018, 6019, 6022, 6023, 6034, 6051, 6052, 6056, + 6057, 6061, 6069, 6096, 6107, 6108, 6118, 6129, 6130, 6131, + 6132, 6133, 6136, 6137, 6138, 6186, 6187, 6191, 6192, 6202, + 6203, 6209, 6215, 6224, 6225, 6252, 6266, 6267, 6271, 6275, + 6282, 6292, 6300, 6305, 6310, 6315, 6320, 6325, 6330, 6335, + 6342, 6343, 6346, 6347, 6348, 6355, 6356, 6357, 6358, 6362, + 6363, 6367, 6371, 6372, 6375, 6383, 6395, 6397, 6399, 6401, + 6403, 6414, 6416, 6420, 6421, 6431, 6435, 6436, 6440, 6441, + 6445, 6446, 6450, 6451, 6455, 6456, 6460, 6468, 6479, 6480, + 6485, 6491, 6509, 6510, 6514, 6515, 6525, 6529, 6534, 6541, + 6549, 6556, 6566, 6576, 6602, 6609, 6613, 6639, 6643, 6655, + 6668, 6682, 6693, 6708, 6714, 6719, 6725, 6732, 6733, 6734, + 6735, 6739, 6740, 6752, 6753, 6758, 6765, 6772, 6779, 6798, + 6802, 6809, 6819, 6824, 6825, 6830, 6831, 6839, 6847, 6852, + 6856, 6862, 6883, 6888, 6894, 6900, 6910, 6912, 6915, 6919, + 6920, 6921, 6922, 6923, 6924, 6930, 6950, 6951, 6952, 6953, + 6964, 6970, 6978, 6979, 6985, 6990, 6995, 7000, 7005, 7010, + 7015, 7020, 7026, 7032, 7038, 7045, 7065, 7074, 7078, 7086, + 7090, 7098, 7110, 7131, 7135, 7141, 7145, 7158, 7177, 7200, + 7202, 7204, 7206, 7208, 7210, 7215, 7216, 7220, 7221, 7228, + 7241, 7253, 7262, 7273, 7281, 7282, 7283, 7287, 7288, 7289, + 7290, 7291, 7292, 7293, 7295, 7297, 7300, 7303, 7305, 7308, + 7310, 7336, 7337, 7339, 7358, 7360, 7362, 7364, 7366, 7368, + 7370, 7372, 7374, 7376, 7378, 7381, 7383, 7385, 7388, 7390, + 7392, 7395, 7397, 7407, 7409, 7419, 7421, 7431, 7433, 7444, + 7456, 7466, 7478, 7498, 7505, 7512, 7519, 7526, 7530, 7537, + 7544, 7551, 7558, 7565, 7572, 7576, 7584, 7588, 7592, 7599, + 7606, 7619, 7632, 7650, 7670, 7679, 7686, 7701, 7705, 7722, + 7724, 7726, 7728, 7730, 7732, 7734, 7736, 7738, 7740, 7742, + 7744, 7746, 7748, 7750, 7752, 7754, 7758, 7763, 7767, 7771, + 7775, 7791, 7792, 7793, 7807, 7819, 7821, 7823, 7832, 7841, + 7850, 7852, 7869, 7879, 7889, 7903, 7913, 7933, 7961, 7978, + 7995, 8009, 8027, 8044, 8061, 8078, 8096, 8106, 8116, 8126, + 8136, 8138, 8148, 8163, 8174, 8187, 8206, 8219, 8229, 8239, + 8249, 8253, 8259, 8266, 8273, 8277, 8281, 8285, 8289, 8293, + 8297, 8305, 8309, 8313, 8318, 8331, 8333, 8341, 8343, 8345, + 8348, 8351, 8354, 8355, 8358, 8366, 8376, 8377, 8380, 8381, + 8382, 8395, 8396, 8397, 8400, 8401, 8402, 8405, 8406, 8409, + 8410, 8411, 8412, 8413, 8414, 8415, 8416, 8417, 8420, 8422, + 8427, 8429, 8434, 8436, 8438, 8440, 8442, 8444, 8456, 8460, + 8467, 8474, 8477, 8478, 8481, 8483, 8487, 8493, 8506, 8507, + 8508, 8509, 8510, 8511, 8512, 8513, 8522, 8526, 8533, 8540, + 8541, 8557, 8561, 8566, 8570, 8587, 8592, 8596, 8599, 8602, + 8603, 8604, 8607, 8614, 8624, 8637, 8638, 8642, 8652, 8653, + 8656, 8657, 8665, 8669, 8676, 8680, 8684, 8691, 8701, 8702, + 8706, 8707, 8710, 8711, 8722, 8723, 8727, 8728, 8736, 8747, + 8748, 8752, 8760, 8768, 8790, 8791, 8795, 8796, 8807, 8814, + 8840, 8842, 8847, 8850, 8853, 8855, 8857, 8859, 8869, 8871, + 8879, 8886, 8893, 8900, 8907, 8919, 8929, 8940, 8948, 8959, + 8969, 8973, 8977, 8985, 8986, 8987, 8989, 8990, 9006, 9007, + 9008, 9013, 9014, 9015, 9021, 9022, 9023, 9024, 9025, 9045, + 9046, 9047, 9048, 9049, 9050, 9051, 9052, 9053, 9054, 9055, + 9056, 9057, 9058, 9059, 9060, 9061, 9062, 9063, 9064, 9065, + 9066, 9067, 9068, 9069, 9070, 9071, 9072, 9073, 9074, 9075, + 9076, 9077, 9078, 9079, 9080, 9081, 9082, 9083, 9084, 9085, + 9086, 9087, 9088, 9089, 9090, 9091, 9092, 9093, 9094, 9095, + 9096, 9097, 9098, 9099, 9100, 9101, 9102, 9103, 9104, 9105, + 9106, 9107, 9108, 9109, 9110, 9111, 9112, 9113, 9114, 9115, + 9116, 9117, 9118, 9119, 9120, 9121, 9122, 9123, 9124, 9125, + 9126, 9127, 9128, 9129, 9130, 9131, 9132, 9133, 9134, 9135, + 9136, 9137, 9138, 9139, 9140, 9141, 9142, 9143, 9144, 9145, + 9146, 9147, 9148, 9149, 9150, 9151, 9152, 9153, 9154, 9155, + 9156, 9157, 9158, 9159, 9160, 9161, 9162, 9163, 9164, 9165, + 9166, 9167, 9168, 9169, 9170, 9171, 9172, 9173, 9174, 9175, + 9176, 9177, 9178, 9179, 9180, 9181, 9182, 9183, 9184, 9185, + 9186, 9187, 9188, 9189, 9190, 9191, 9192, 9193, 9194, 9195, + 9196, 9197, 9198, 9199, 9200, 9201, 9202, 9203, 9204, 9205, + 9206, 9207, 9208, 9209, 9210, 9211, 9212, 9213, 9214, 9215, + 9216, 9217, 9218, 9219, 9220, 9221, 9222, 9223, 9224, 9225, + 9226, 9227, 9228, 9229, 9230, 9231, 9232, 9233, 9234, 9235, + 9236, 9237, 9238, 9239, 9240, 9241, 9242, 9243, 9244, 9245, + 9246, 9247, 9248, 9249, 9250, 9251, 9252, 9253, 9254, 9255, + 9256, 9257, 9258, 9259, 9260, 9261, 9262, 9263, 9264, 9265, + 9266, 9267, 9268, 9269, 9270, 9271, 9272, 9273, 9274, 9275, + 9276, 9277, 9291, 9292, 9293, 9294, 9295, 9296, 9297, 9298, + 9299, 9300, 9301, 9302, 9303, 9304, 9305, 9306, 9307, 9308, + 9309, 9310, 9311, 9312, 9313, 9314, 9315, 9316, 9317, 9318, + 9319, 9320, 9321, 9322, 9323, 9324, 9325, 9326, 9327, 9328, + 9329, 9330, 9331, 9332, 9333, 9334, 9335, 9349, 9350, 9351, + 9352, 9353, 9354, 9355, 9356, 9357, 9358, 9359, 9360, 9361, + 9362, 9363, 9364, 9365, 9366, 9367, 9368, 9378, 9379, 9380, + 9381, 9382, 9383, 9384, 9385, 9386, 9387, 9388, 9389, 9390, + 9391, 9392, 9393, 9394, 9395, 9396, 9397, 9398, 9399, 9400, + 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, + 9411, 9412, 9413, 9414, 9415, 9416, 9417, 9418, 9419, 9420, + 9421, 9422, 9423, 9424, 9425, 9426, 9427, 9428, 9429, 9430, + 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, + 9441, 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449, 9450, + 9451, 9456, 9465 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ABORT_P", "ABSOLUTE_P", "ACCESS", + "ACTION", "ADD_P", "ADMIN", "AFTER", "AGGREGATE", "ALL", "ALSO", "ALTER", + "ALWAYS", "ANALYSE", "ANALYZE", "AND", "ANY", "ARRAY", "AS", "ASC", + "ASSERTION", "ASSIGNMENT", "ASYMMETRIC", "AT", "AUTHORIZATION", + "BACKWARD", "BEFORE", "BEGIN_P", "BETWEEN", "BIGINT", "BINARY", "BIT", + "BOOLEAN_P", "BOTH", "BY", "CACHE", "CALLED", "CASCADE", "CASCADED", + "CASE", "CAST", "CHAIN", "CHAR_P", "CHARACTER", "CHARACTERISTICS", + "CHECK", "CHECKPOINT", "CLASS", "CLOSE", "CLUSTER", "COALESCE", + "COLLATE", "COLUMN", "COMMENT", "COMMIT", "COMMITTED", "CONCURRENTLY", + "CONFIGURATION", "CONNECTION", "CONSTRAINT", "CONSTRAINTS", "CONTENT_P", + "CONVERSION_P", "COPY", "COST", "CREATE", "CREATEDB", "CREATEROLE", + "CREATEUSER", "CROSS", "CSV", "CURRENT_P", "CURRENT_DATE", + "CURRENT_ROLE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", + "CURSOR", "CYCLE", "DATABASE", "DAY_P", "DEALLOCATE", "DEC", "DECIMAL_P", + "DECLARE", "DEFAULT", "DEFAULTS", "DEFERRABLE", "DEFERRED", "DEFINER", + "DELETE_P", "DELIMITER", "DELIMITERS", "DESC", "DICTIONARY", "DISABLE_P", + "DISCARD", "DISTINCT", "DO", "DOCUMENT_P", "DOMAIN_P", "DOUBLE_P", + "DROP", "EACH", "ELSE", "ENABLE_P", "ENCODING", "ENCRYPTED", "END_P", + "ENUM_P", "ESCAPE", "EXCEPT", "EXCLUDING", "EXCLUSIVE", "EXECUTE", + "EXISTS", "EXPLAIN", "EXTERNAL", "EXTRACT", "FALSE_P", "FAMILY", "FETCH", + "FIRST_P", "FLOAT_P", "FOR", "FORCE", "FOREIGN", "FORWARD", "FREEZE", + "FROM", "FULL", "FUNCTION", "GLOBAL", "GRANT", "GRANTED", "GREATEST", + "GROUP_P", "HANDLER", "HAVING", "HEADER_P", "HOLD", "HOUR_P", "IF_P", + "ILIKE", "IMMEDIATE", "IMMUTABLE", "IMPLICIT_P", "IN_P", "INCLUDING", + "INCREMENT", "INDEX", "INDEXES", "INHERIT", "INHERITS", "INITIALLY", + "INNER_P", "INOUT", "INPUT_P", "INSENSITIVE", "INSERT", "INSTEAD", + "INT_P", "INTEGER", "INTERSECT", "INTERVAL", "INTO", "INVOKER", "IS", + "ISNULL", "ISOLATION", "JOIN", "KEY", "LANCOMPILER", "LANGUAGE", + "LARGE_P", "LAST_P", "LEADING", "LEAST", "LEFT", "LEVEL", "LIKE", + "LIMIT", "LISTEN", "LOAD", "LOCAL", "LOCALTIME", "LOCALTIMESTAMP", + "LOCATION", "LOCK_P", "LOGIN_P", "MAPPING", "MATCH", "MAXVALUE", + "MINUTE_P", "MINVALUE", "MODE", "MONTH_P", "MOVE", "NAME_P", "NAMES", + "NATIONAL", "NATURAL", "NCHAR", "NEW", "NEXT", "NO", "NOCREATEDB", + "NOCREATEROLE", "NOCREATEUSER", "NOINHERIT", "NOLOGIN_P", "NONE", + "NOSUPERUSER", "NOT", "NOTHING", "NOTIFY", "NOTNULL", "NOWAIT", "NULL_P", + "NULLIF", "NULLS_P", "NUMERIC", "OBJECT_P", "OF", "OFF", "OFFSET", + "OIDS", "OLD", "ON", "ONLY", "OPERATOR", "OPTION", "OR", "ORDER", + "OUT_P", "OUTER_P", "OVERLAPS", "OVERLAY", "OWNED", "OWNER", "PARSER", + "PARTIAL", "PASSWORD", "PLACING", "PLANS", "POSITION", "PRECISION", + "PRESERVE", "PREPARE", "PREPARED", "PRIMARY", "PRIOR", "PRIVILEGES", + "PROCEDURAL", "PROCEDURE", "QUOTE", "READ", "REAL", "REASSIGN", + "RECHECK", "REFERENCES", "REINDEX", "RELATIVE_P", "RELEASE", "RENAME", + "REPEATABLE", "REPLACE", "REPLICA", "RESET", "RESTART", "RESTRICT", + "RETURNING", "RETURNS", "REVOKE", "RIGHT", "ROLE", "ROLLBACK", "ROW", + "ROWS", "RULE", "SAVEPOINT", "SCHEMA", "SCROLL", "SEARCH", "SECOND_P", + "SECURITY", "SELECT", "SEQUENCE", "SERIALIZABLE", "SESSION", + "SESSION_USER", "SET", "SETOF", "SHARE", "SHOW", "SIMILAR", "SIMPLE", + "SMALLINT", "SOME", "STABLE", "STANDALONE_P", "START", "STATEMENT", + "STATISTICS", "STDIN", "STDOUT", "STORAGE", "STRICT_P", "STRIP_P", + "SUBSTRING", "SUPERUSER_P", "SYMMETRIC", "SYSID", "SYSTEM_P", "TABLE", + "TABLESPACE", "TEMP", "TEMPLATE", "TEMPORARY", "TEXT_P", "THEN", "TIME", + "TIMESTAMP", "TO", "TRAILING", "TRANSACTION", "TREAT", "TRIGGER", "TRIM", + "TRUE_P", "TRUNCATE", "TRUSTED", "TYPE_P", "UNCOMMITTED", "UNENCRYPTED", + "UNION", "UNIQUE", "UNKNOWN", "UNLISTEN", "UNTIL", "UPDATE", "USER", + "USING", "VACUUM", "VALID", "VALIDATOR", "VALUE_P", "VALUES", "VARCHAR", + "VARYING", "VERBOSE", "VERSION_P", "VIEW", "VOLATILE", "WHEN", "WHERE", + "WHITESPACE_P", "WITH", "WITHOUT", "WORK", "WRITE", "XML_P", + "XMLATTRIBUTES", "XMLCONCAT", "XMLELEMENT", "XMLFOREST", "XMLPARSE", + "XMLPI", "XMLROOT", "XMLSERIALIZE", "YEAR_P", "YES_P", "ZONE", + "NULLS_FIRST", "NULLS_LAST", "WITH_CASCADED", "WITH_LOCAL", "WITH_CHECK", + "IDENT", "FCONST", "SCONST", "BCONST", "XCONST", "Op", "ICONST", "PARAM", + "'='", "'<'", "'>'", "POSTFIXOP", "'+'", "'-'", "'*'", "'/'", "'%'", + "'^'", "UMINUS", "'['", "']'", "'('", "')'", "TYPECAST", "'.'", "';'", + "','", "':'", "$accept", "stmtblock", "stmtmulti", "stmt", + "CreateRoleStmt", "opt_with", "OptRoleList", "OptRoleElem", + "CreateUserStmt", "AlterRoleStmt", "AlterRoleSetStmt", "AlterUserStmt", + "AlterUserSetStmt", "DropRoleStmt", "DropUserStmt", "CreateGroupStmt", + "AlterGroupStmt", "add_drop", "DropGroupStmt", "CreateSchemaStmt", + "OptSchemaName", "OptSchemaEltList", "schema_stmt", "VariableSetStmt", + "set_rest", "var_name", "var_list", "var_value", "iso_level", + "opt_boolean", "zone_value", "opt_encoding", "ColId_or_Sconst", + "VariableResetStmt", "SetResetClause", "VariableShowStmt", + "ConstraintsSetStmt", "constraints_set_list", "constraints_set_mode", + "CheckPointStmt", "DiscardStmt", "AlterTableStmt", "alter_table_cmds", + "alter_table_cmd", "alter_rel_cmds", "alter_rel_cmd", + "alter_column_default", "opt_drop_behavior", "alter_using", + "ClosePortalStmt", "CopyStmt", "copy_from", "copy_file_name", + "copy_opt_list", "copy_opt_item", "opt_binary", "opt_oids", + "copy_delimiter", "opt_using", "CreateStmt", "OptTemp", + "OptTableElementList", "TableElementList", "TableElement", "columnDef", + "ColQualList", "ColConstraint", "ColConstraintElem", "ConstraintAttr", + "TableLikeClause", "TableLikeOptionList", "TableLikeOption", + "TableConstraint", "ConstraintElem", "opt_column_list", "columnList", + "columnElem", "key_match", "key_actions", "key_update", "key_delete", + "key_action", "OptInherit", "OptWith", "OnCommitOption", "OptTableSpace", + "OptConsTableSpace", "CreateAsStmt", "create_as_target", "OptCreateAs", + "CreateAsList", "CreateAsElement", "CreateSeqStmt", "AlterSeqStmt", + "OptSeqList", "OptSeqElem", "opt_by", "NumericOnly", "FloatOnly", + "IntegerOnly", "CreatePLangStmt", "opt_trusted", "handler_name", + "opt_validator", "opt_lancompiler", "DropPLangStmt", "opt_procedural", + "CreateTableSpaceStmt", "OptTableSpaceOwner", "DropTableSpaceStmt", + "CreateTrigStmt", "TriggerActionTime", "TriggerEvents", + "TriggerOneEvent", "TriggerForSpec", "TriggerForOpt", "TriggerForType", + "TriggerFuncArgs", "TriggerFuncArg", "OptConstrFromTable", + "ConstraintAttributeSpec", "ConstraintDeferrabilitySpec", + "ConstraintTimeSpec", "DropTrigStmt", "CreateAssertStmt", + "DropAssertStmt", "DefineStmt", "definition", "def_list", "def_elem", + "def_arg", "aggr_args", "old_aggr_definition", "old_aggr_list", + "old_aggr_elem", "enum_val_list", "CreateOpClassStmt", + "opclass_item_list", "opclass_item", "opt_default", "opt_opfamily", + "opt_recheck", "CreateOpFamilyStmt", "AlterOpFamilyStmt", + "opclass_drop_list", "opclass_drop", "DropOpClassStmt", + "DropOpFamilyStmt", "DropOwnedStmt", "ReassignOwnedStmt", "DropStmt", + "drop_type", "any_name_list", "any_name", "attrs", "TruncateStmt", + "CommentStmt", "comment_type", "comment_text", "FetchStmt", + "fetch_direction", "from_in", "GrantStmt", "RevokeStmt", "privileges", + "privilege_list", "privilege", "privilege_target", "grantee_list", + "grantee", "opt_grant_grant_option", "function_with_argtypes_list", + "function_with_argtypes", "GrantRoleStmt", "RevokeRoleStmt", + "opt_grant_admin_option", "opt_granted_by", "IndexStmt", + "index_opt_unique", "access_method_clause", "index_params", "index_elem", + "opt_class", "opt_asc_desc", "opt_nulls_order", "CreateFunctionStmt", + "opt_or_replace", "func_args", "func_args_list", "func_arg", "arg_class", + "param_name", "func_return", "func_type", "createfunc_opt_list", + "common_func_opt_item", "createfunc_opt_item", "func_as", + "opt_definition", "AlterFunctionStmt", "alterfunc_opt_list", + "opt_restrict", "RemoveFuncStmt", "RemoveAggrStmt", "RemoveOperStmt", + "oper_argtypes", "any_operator", "CreateCastStmt", "cast_context", + "DropCastStmt", "opt_if_exists", "ReindexStmt", "reindex_type", + "opt_force", "RenameStmt", "opt_column", "AlterObjectSchemaStmt", + "AlterOwnerStmt", "RuleStmt", "@1", "RuleActionList", "RuleActionMulti", + "RuleActionStmt", "RuleActionStmtOrEmpty", "event", "opt_instead", + "DropRuleStmt", "NotifyStmt", "ListenStmt", "UnlistenStmt", + "TransactionStmt", "opt_transaction", "transaction_mode_item", + "transaction_mode_list", "transaction_mode_list_or_empty", "ViewStmt", + "opt_check_option", "LoadStmt", "CreatedbStmt", "createdb_opt_list", + "createdb_opt_item", "opt_equal", "AlterDatabaseStmt", + "AlterDatabaseSetStmt", "alterdb_opt_list", "alterdb_opt_item", + "DropdbStmt", "CreateDomainStmt", "AlterDomainStmt", "opt_as", + "AlterTSDictionaryStmt", "AlterTSConfigurationStmt", + "CreateConversionStmt", "ClusterStmt", "cluster_index_specification", + "VacuumStmt", "AnalyzeStmt", "analyze_keyword", "opt_verbose", + "opt_full", "opt_freeze", "opt_name_list", "ExplainStmt", + "ExplainableStmt", "opt_analyze", "PrepareStmt", "prep_type_clause", + "PreparableStmt", "ExecuteStmt", "execute_param_clause", + "DeallocateStmt", "InsertStmt", "insert_rest", "insert_column_list", + "insert_column_item", "returning_clause", "DeleteStmt", "using_clause", + "LockStmt", "opt_lock", "lock_type", "opt_nowait", "UpdateStmt", + "set_clause_list", "set_clause", "single_set_clause", + "multiple_set_clause", "set_target", "set_target_list", + "DeclareCursorStmt", "cursor_options", "opt_hold", "SelectStmt", + "select_with_parens", "select_no_parens", "select_clause", + "simple_select", "into_clause", "OptTempTableName", "opt_table", + "opt_all", "opt_distinct", "opt_sort_clause", "sort_clause", + "sortby_list", "sortby", "select_limit", "opt_select_limit", + "select_limit_value", "select_offset_value", "group_clause", + "having_clause", "for_locking_clause", "opt_for_locking_clause", + "for_locking_items", "for_locking_item", "locked_rels_list", + "values_clause", "from_clause", "from_list", "table_ref", "joined_table", + "alias_clause", "join_type", "join_outer", "join_qual", "relation_expr", + "relation_expr_opt_alias", "func_table", "where_clause", + "where_or_current_clause", "TableFuncElementList", "TableFuncElement", + "Typename", "opt_array_bounds", "SimpleTypename", "ConstTypename", + "GenericType", "opt_type_modifiers", "Numeric", "opt_float", "Bit", + "ConstBit", "BitWithLength", "BitWithoutLength", "Character", + "ConstCharacter", "CharacterWithLength", "CharacterWithoutLength", + "character", "opt_varying", "opt_charset", "ConstDatetime", + "ConstInterval", "opt_timezone", "opt_interval", "a_expr", "b_expr", + "c_expr", "func_expr", "xml_root_version", "opt_xml_root_standalone", + "xml_attributes", "xml_attribute_list", "xml_attribute_el", + "document_or_content", "xml_whitespace_option", "row", "sub_type", + "all_Op", "MathOp", "qual_Op", "qual_all_Op", "subquery_Op", "expr_list", + "extract_list", "type_list", "array_expr_list", "array_expr", + "extract_arg", "overlay_list", "overlay_placing", "position_list", + "substr_list", "substr_from", "substr_for", "trim_list", "in_expr", + "case_expr", "when_clause_list", "when_clause", "case_default", + "case_arg", "columnref", "indirection_el", "indirection", + "opt_indirection", "opt_asymmetric", "ctext_expr", "ctext_expr_list", + "ctext_row", "target_list", "target_el", "relation_name", + "qualified_name_list", "qualified_name", "name_list", "name", + "database_name", "access_method", "attr_name", "index_name", "file_name", + "func_name", "AexprConst", "Iconst", "Sconst", "RoleId", "SignedIconst", + "ColId", "type_function_name", "ColLabel", "unreserved_keyword", + "col_name_keyword", "type_func_name_keyword", "reserved_keyword", + "SpecialRuleRelation", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, + 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, + 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, + 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, + 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, + 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, + 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, + 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, + 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, + 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, + 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, + 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, + 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, + 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, + 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, + 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, + 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, + 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, + 635, 636, 637, 638, 639, 640, 641, 642, 61, 60, + 62, 643, 43, 45, 42, 47, 37, 94, 644, 91, + 93, 40, 41, 645, 46, 59, 44, 58 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned short int yyr1[] = +{ + 0, 408, 409, 410, 410, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, + 411, 411, 411, 411, 411, 411, 411, 412, 413, 413, + 414, 414, 415, 415, 415, 415, 415, 415, 415, 415, + 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, + 415, 415, 415, 415, 415, 415, 416, 417, 418, 419, + 420, 421, 421, 422, 422, 423, 424, 425, 425, 426, + 426, 427, 427, 428, 428, 429, 429, 430, 430, 430, + 430, 430, 430, 431, 431, 431, 432, 432, 432, 432, + 432, 432, 432, 432, 432, 432, 432, 432, 432, 433, + 433, 434, 434, 435, 435, 435, 436, 436, 436, 436, + 437, 437, 437, 437, 438, 438, 438, 438, 438, 438, + 438, 439, 439, 439, 440, 440, 441, 441, 441, 441, + 441, 442, 442, 443, 443, 443, 443, 443, 444, 445, + 445, 446, 446, 447, 448, 448, 448, 448, 449, 449, + 450, 450, 451, 451, 451, 451, 451, 451, 451, 451, + 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, + 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, + 452, 452, 453, 453, 453, 453, 454, 454, 455, 455, + 455, 456, 456, 457, 457, 458, 458, 459, 459, 460, + 460, 460, 461, 461, 462, 462, 462, 462, 462, 462, + 462, 462, 462, 462, 463, 463, 464, 464, 465, 465, + 466, 466, 467, 467, 468, 468, 468, 468, 468, 468, + 468, 469, 469, 470, 470, 471, 471, 471, 472, 473, + 473, 474, 474, 474, 475, 475, 475, 475, 475, 475, + 475, 476, 476, 476, 476, 477, 478, 478, 479, 479, + 479, 479, 479, 479, 480, 480, 481, 481, 481, 481, + 482, 482, 483, 483, 484, 485, 485, 485, 485, 486, + 486, 486, 486, 486, 487, 488, 489, 489, 489, 489, + 489, 490, 490, 491, 491, 491, 491, 492, 492, 492, + 492, 493, 493, 494, 494, 495, 496, 497, 497, 498, + 498, 499, 500, 501, 502, 502, 503, 503, 503, 503, + 503, 503, 503, 503, 503, 503, 503, 504, 504, 505, + 505, 506, 506, 507, 508, 508, 509, 509, 510, 510, + 511, 511, 512, 512, 513, 513, 514, 514, 515, 516, + 516, 517, 517, 518, 518, 519, 519, 520, 520, 520, + 521, 521, 521, 522, 522, 523, 523, 524, 524, 525, + 525, 525, 526, 526, 526, 526, 526, 526, 527, 527, + 528, 528, 528, 528, 528, 529, 529, 530, 530, 531, + 531, 532, 533, 534, 534, 534, 534, 534, 534, 534, + 534, 534, 534, 534, 535, 536, 536, 537, 537, 538, + 538, 538, 538, 538, 539, 539, 540, 541, 541, 542, + 543, 543, 544, 545, 545, 546, 546, 546, 546, 546, + 547, 547, 548, 548, 549, 549, 550, 551, 551, 552, + 552, 553, 553, 554, 554, 555, 555, 556, 557, 558, + 558, 559, 559, 559, 559, 559, 559, 559, 559, 559, + 559, 559, 559, 560, 560, 561, 561, 562, 562, 563, + 564, 564, 564, 564, 564, 564, 564, 564, 564, 564, + 564, 564, 564, 564, 564, 564, 564, 565, 565, 565, + 565, 565, 565, 565, 565, 565, 565, 565, 565, 566, + 566, 567, 567, 567, 567, 568, 568, 568, 568, 568, + 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, + 569, 569, 570, 571, 571, 572, 572, 572, 573, 573, + 574, 574, 574, 574, 575, 575, 575, 575, 575, 575, + 575, 575, 576, 576, 577, 577, 578, 578, 579, 579, + 580, 581, 582, 582, 583, 583, 584, 584, 585, 585, + 586, 586, 587, 587, 588, 588, 589, 589, 589, 590, + 590, 590, 591, 591, 591, 592, 592, 592, 593, 593, + 594, 594, 595, 595, 596, 596, 597, 597, 597, 597, + 597, 598, 598, 598, 598, 599, 600, 601, 601, 601, + 602, 602, 603, 603, 603, 603, 603, 603, 603, 603, + 603, 603, 603, 603, 603, 604, 604, 604, 605, 605, + 606, 606, 607, 608, 608, 609, 609, 610, 610, 611, + 611, 612, 612, 613, 613, 613, 613, 614, 614, 615, + 615, 616, 616, 616, 617, 618, 618, 619, 619, 619, + 620, 620, 621, 621, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, + 622, 622, 622, 622, 622, 622, 623, 623, 624, 624, + 624, 624, 624, 624, 625, 625, 625, 625, 625, 625, + 625, 625, 625, 625, 625, 625, 625, 625, 627, 626, + 628, 628, 628, 629, 629, 630, 630, 630, 630, 630, + 631, 631, 632, 632, 632, 632, 633, 633, 633, 634, + 634, 635, 636, 637, 637, 638, 638, 638, 638, 638, + 638, 638, 638, 638, 638, 638, 638, 638, 638, 639, + 639, 639, 640, 640, 640, 641, 641, 641, 642, 642, + 643, 643, 644, 644, 644, 644, 645, 646, 647, 647, + 648, 648, 648, 648, 648, 648, 648, 648, 648, 648, + 648, 648, 649, 649, 650, 651, 652, 652, 653, 654, + 654, 655, 656, 656, 656, 656, 656, 657, 657, 658, + 659, 659, 659, 659, 659, 659, 660, 661, 661, 661, + 662, 662, 663, 663, 663, 664, 664, 665, 665, 666, + 666, 667, 667, 668, 668, 669, 669, 670, 671, 671, + 671, 671, 671, 671, 672, 672, 673, 674, 674, 675, + 675, 675, 675, 676, 676, 677, 677, 678, 678, 678, + 678, 679, 680, 680, 680, 681, 681, 682, 683, 683, + 684, 685, 685, 686, 687, 687, 688, 688, 688, 688, + 688, 688, 688, 688, 689, 689, 690, 691, 691, 692, + 692, 693, 694, 695, 696, 696, 697, 698, 698, 698, + 698, 698, 699, 699, 699, 700, 700, 701, 701, 702, + 702, 702, 702, 703, 703, 704, 704, 704, 704, 704, + 705, 705, 706, 706, 706, 706, 706, 706, 706, 706, + 707, 707, 708, 708, 708, 709, 709, 709, 709, 710, + 710, 711, 712, 712, 713, 713, 714, 714, 714, 714, + 714, 715, 715, 716, 716, 717, 718, 718, 719, 719, + 720, 720, 721, 721, 722, 722, 723, 723, 724, 724, + 725, 725, 726, 726, 727, 727, 728, 728, 728, 728, + 728, 728, 728, 728, 728, 728, 728, 729, 729, 729, + 729, 729, 729, 730, 730, 730, 730, 731, 731, 731, + 731, 732, 732, 733, 733, 734, 734, 734, 734, 735, + 735, 735, 736, 737, 737, 738, 738, 738, 738, 739, + 739, 740, 741, 741, 741, 741, 742, 742, 742, 743, + 743, 743, 743, 743, 743, 743, 744, 744, 744, 744, + 745, 745, 746, 746, 747, 747, 747, 747, 747, 747, + 747, 747, 747, 747, 747, 748, 748, 749, 749, 750, + 750, 751, 752, 753, 753, 754, 754, 755, 756, 757, + 757, 757, 757, 757, 757, 758, 758, 759, 759, 760, + 760, 760, 760, 761, 762, 762, 762, 763, 763, 763, + 763, 763, 763, 763, 763, 763, 763, 763, 763, 763, + 763, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 764, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 764, 764, 764, 764, 764, 764, 764, 764, 764, 765, + 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, + 765, 765, 765, 765, 765, 765, 765, 765, 765, 765, + 765, 766, 766, 766, 766, 766, 766, 766, 766, 766, + 766, 766, 767, 767, 767, 767, 767, 767, 767, 767, + 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, + 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, + 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, + 767, 767, 767, 767, 767, 768, 768, 769, 769, 769, + 769, 770, 771, 771, 772, 772, 773, 773, 774, 774, + 774, 775, 775, 775, 776, 776, 776, 777, 777, 778, + 778, 778, 778, 778, 778, 778, 778, 778, 779, 779, + 780, 780, 781, 781, 781, 781, 781, 781, 782, 782, + 783, 783, 784, 784, 785, 785, 786, 786, 787, 787, + 787, 787, 787, 787, 787, 787, 788, 788, 789, 790, + 790, 791, 791, 791, 791, 791, 791, 792, 793, 794, + 794, 794, 795, 795, 796, 797, 797, 798, 799, 799, + 800, 800, 801, 801, 802, 802, 802, 802, 803, 803, + 804, 804, 805, 805, 806, 806, 807, 807, 808, 809, + 809, 810, 810, 810, 811, 811, 812, 812, 813, 813, + 814, 814, 815, 816, 817, 818, 819, 820, 821, 821, + 822, 822, 822, 822, 822, 822, 822, 822, 822, 822, + 822, 822, 822, 823, 824, 825, 826, 826, 827, 827, + 827, 828, 828, 828, 829, 829, 829, 829, 829, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + 830, 830, 831, 831, 831, 831, 831, 831, 831, 831, + 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, + 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, + 831, 831, 831, 831, 831, 831, 831, 831, 831, 831, + 831, 831, 831, 831, 831, 831, 831, 832, 832, 832, + 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + 832, 832, 832, 832, 832, 832, 832, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 833, 833, 833, 833, 833, 833, 833, 833, 833, + 833, 834, 834 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 5, 1, 0, + 2, 0, 2, 2, 3, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, + 2, 2, 2, 2, 3, 3, 5, 5, 4, 5, + 4, 3, 5, 3, 5, 5, 6, 1, 1, 3, + 5, 6, 4, 1, 0, 2, 0, 1, 1, 1, + 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, + 3, 3, 2, 5, 2, 2, 3, 3, 3, 1, + 3, 1, 3, 1, 1, 1, 2, 2, 2, 1, + 1, 1, 1, 1, 1, 1, 3, 6, 1, 1, + 1, 1, 1, 0, 1, 1, 2, 3, 4, 3, + 2, 2, 1, 2, 3, 4, 3, 2, 4, 1, + 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, + 1, 3, 3, 4, 6, 6, 6, 6, 4, 6, + 2, 4, 3, 3, 3, 3, 4, 4, 3, 3, + 3, 3, 3, 3, 4, 4, 3, 2, 3, 1, + 1, 3, 3, 3, 2, 2, 3, 2, 1, 1, + 0, 2, 0, 2, 2, 10, 6, 1, 1, 1, + 1, 1, 2, 0, 1, 1, 3, 3, 1, 1, + 3, 3, 3, 4, 1, 0, 2, 0, 3, 0, + 1, 0, 11, 12, 1, 1, 2, 2, 2, 2, + 0, 1, 0, 1, 3, 1, 1, 1, 3, 2, + 0, 3, 1, 1, 2, 1, 3, 4, 4, 2, + 5, 1, 2, 2, 2, 3, 2, 0, 2, 2, + 2, 2, 2, 2, 3, 1, 4, 6, 7, 11, + 3, 0, 1, 3, 1, 2, 2, 2, 0, 1, + 1, 2, 2, 0, 3, 3, 2, 1, 1, 2, + 2, 4, 0, 2, 2, 2, 0, 3, 4, 4, + 0, 2, 0, 4, 0, 6, 5, 3, 0, 1, + 3, 1, 5, 4, 2, 0, 2, 1, 2, 3, + 2, 2, 2, 2, 3, 3, 3, 1, 0, 1, + 1, 1, 2, 1, 5, 9, 1, 0, 1, 2, + 2, 0, 2, 0, 5, 7, 1, 0, 6, 2, + 0, 3, 5, 14, 19, 1, 1, 1, 3, 5, + 1, 1, 1, 3, 0, 1, 0, 1, 1, 1, + 3, 0, 1, 1, 1, 1, 1, 1, 2, 0, + 1, 2, 1, 2, 0, 2, 1, 2, 2, 6, + 8, 8, 4, 5, 4, 4, 4, 3, 7, 8, + 6, 6, 6, 6, 3, 1, 3, 3, 1, 1, + 1, 1, 1, 1, 3, 3, 3, 1, 3, 3, + 1, 3, 13, 1, 3, 4, 7, 4, 7, 2, + 1, 0, 2, 0, 1, 0, 6, 8, 8, 1, + 3, 5, 5, 7, 9, 7, 9, 5, 6, 6, + 4, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 3, 3, 3, 1, 3, 1, 2, 2, 3, 4, + 6, 7, 7, 9, 8, 8, 6, 8, 9, 9, + 7, 10, 7, 8, 8, 8, 8, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 2, 4, 2, 0, 1, 1, 1, 1, + 2, 2, 1, 1, 1, 2, 2, 1, 2, 2, + 1, 1, 7, 7, 10, 1, 1, 2, 1, 3, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 1, 3, 1, 2, 3, 0, 1, 3, + 2, 6, 6, 9, 3, 0, 3, 0, 13, 14, + 1, 0, 2, 0, 1, 3, 4, 4, 6, 1, + 2, 0, 1, 1, 0, 1, 1, 0, 9, 7, + 2, 0, 3, 2, 1, 3, 3, 3, 2, 2, + 1, 1, 1, 1, 2, 1, 1, 1, 4, 5, + 1, 2, 4, 5, 1, 1, 1, 1, 3, 3, + 2, 2, 2, 2, 1, 2, 2, 1, 1, 3, + 2, 0, 5, 1, 2, 1, 0, 5, 7, 5, + 7, 7, 9, 1, 3, 3, 3, 1, 3, 11, + 10, 2, 2, 0, 9, 2, 0, 4, 4, 4, + 1, 1, 1, 0, 7, 6, 6, 6, 6, 7, + 9, 9, 6, 6, 6, 6, 6, 8, 8, 6, + 6, 6, 8, 8, 8, 8, 1, 0, 7, 6, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 7, + 9, 9, 9, 6, 6, 6, 8, 8, 0, 14, + 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 0, 6, + 8, 2, 2, 2, 2, 2, 3, 3, 2, 2, + 2, 2, 3, 2, 5, 4, 3, 3, 3, 1, + 1, 0, 3, 2, 2, 1, 3, 2, 1, 0, + 8, 10, 2, 3, 3, 0, 2, 5, 2, 0, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, + 3, 3, 1, 0, 5, 4, 2, 0, 4, 3, + 5, 6, 4, 6, 6, 5, 7, 1, 0, 6, + 11, 11, 11, 13, 9, 11, 10, 3, 1, 4, + 2, 0, 4, 5, 5, 2, 4, 1, 1, 1, + 0, 1, 0, 1, 0, 3, 0, 4, 1, 1, + 1, 1, 1, 1, 1, 0, 5, 3, 0, 1, + 1, 1, 1, 3, 8, 3, 0, 2, 3, 2, + 3, 5, 1, 4, 2, 1, 3, 2, 2, 0, + 6, 2, 0, 5, 3, 0, 2, 2, 2, 3, + 1, 3, 1, 2, 1, 0, 7, 1, 3, 1, + 1, 3, 5, 2, 1, 3, 7, 0, 3, 2, + 2, 2, 0, 2, 2, 1, 1, 3, 3, 1, + 2, 4, 4, 1, 1, 8, 1, 4, 4, 4, + 2, 0, 3, 3, 4, 4, 4, 4, 2, 1, + 1, 0, 1, 1, 0, 1, 5, 1, 0, 1, + 0, 3, 1, 3, 4, 3, 4, 4, 2, 2, + 4, 1, 0, 1, 1, 1, 3, 0, 2, 0, + 1, 3, 1, 0, 1, 2, 4, 4, 2, 0, + 2, 3, 2, 0, 1, 3, 1, 2, 1, 2, + 5, 6, 5, 1, 2, 1, 4, 3, 4, 5, + 4, 5, 4, 5, 2, 4, 1, 2, 2, 2, + 1, 1, 0, 4, 2, 1, 2, 2, 4, 1, + 2, 3, 1, 2, 0, 2, 4, 4, 0, 1, + 3, 2, 2, 3, 5, 6, 3, 4, 0, 1, + 1, 1, 1, 1, 2, 5, 1, 1, 1, 1, + 2, 3, 3, 0, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 1, 3, 0, 1, 1, 1, + 1, 5, 2, 1, 1, 1, 1, 5, 2, 2, + 2, 1, 3, 3, 2, 1, 0, 3, 0, 5, + 2, 5, 2, 1, 3, 3, 0, 1, 1, 1, + 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, + 0, 1, 3, 5, 2, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, + 2, 3, 5, 4, 6, 3, 5, 4, 6, 4, + 6, 5, 7, 3, 2, 4, 2, 3, 3, 4, + 3, 4, 3, 4, 5, 6, 6, 7, 6, 7, + 6, 7, 3, 4, 4, 6, 2, 3, 4, 1, + 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 2, 5, 6, 6, 7, 3, + 4, 1, 1, 2, 4, 1, 1, 1, 2, 2, + 2, 1, 3, 4, 5, 5, 4, 1, 1, 4, + 1, 4, 1, 4, 1, 4, 1, 1, 1, 1, + 6, 4, 4, 4, 4, 6, 5, 5, 5, 4, + 6, 4, 4, 4, 4, 5, 7, 7, 9, 4, + 6, 5, 7, 7, 7, 2, 3, 3, 3, 4, + 0, 4, 1, 3, 3, 1, 1, 1, 2, 2, + 0, 4, 3, 5, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 1, 4, 1, 4, 1, 2, 1, 2, 1, 3, + 3, 0, 1, 3, 1, 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 4, 3, 2, 3, + 0, 3, 3, 2, 2, 1, 0, 2, 2, 3, + 2, 1, 1, 3, 5, 1, 2, 4, 2, 0, + 1, 0, 1, 2, 2, 2, 3, 5, 1, 2, + 0, 2, 1, 0, 1, 1, 1, 3, 3, 1, + 3, 3, 1, 1, 1, 1, 1, 3, 1, 2, + 1, 3, 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 2, 5, 2, 3, 6, + 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned short int yydefact[] = +{ + 96, 811, 417, 878, 877, 811, 213, 0, 868, 0, + 811, 285, 300, 0, 0, 0, 0, 417, 811, 0, + 895, 575, 0, 0, 0, 0, 981, 575, 0, 0, + 0, 0, 0, 0, 0, 811, 0, 988, 0, 0, + 0, 981, 0, 0, 882, 0, 0, 0, 2, 4, + 43, 44, 15, 14, 19, 18, 62, 63, 33, 9, + 53, 38, 93, 92, 94, 25, 21, 50, 13, 22, + 26, 40, 27, 39, 12, 37, 57, 41, 60, 42, + 61, 28, 51, 48, 34, 35, 36, 54, 55, 56, + 77, 59, 88, 24, 67, 68, 83, 69, 84, 70, + 32, 8, 80, 79, 81, 29, 52, 78, 82, 10, + 11, 85, 58, 75, 72, 89, 87, 95, 73, 45, + 5, 6, 64, 31, 7, 17, 16, 30, 23, 91, + 20, 880, 66, 76, 65, 46, 71, 49, 74, 90, + 47, 86, 956, 955, 990, 959, 966, 810, 809, 795, + 0, 0, 0, 0, 0, 0, 0, 0, 416, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 819, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 264, + 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1672, + 1673, 1674, 1456, 1457, 1458, 1459, 1460, 1461, 1675, 1676, + 1462, 1463, 1464, 1465, 1466, 1677, 1467, 1468, 1469, 1470, + 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, + 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1678, 1679, 1488, + 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, + 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, + 1509, 1510, 1680, 1511, 1512, 1681, 1513, 1514, 1515, 1682, + 1516, 1517, 1518, 1519, 1520, 1683, 1521, 1522, 1523, 1524, + 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, + 1684, 1535, 1536, 1537, 1538, 1685, 1686, 1687, 1539, 1540, + 1541, 1542, 1543, 1544, 1545, 1688, 1546, 1547, 1548, 1549, + 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, + 1560, 1561, 1562, 1689, 1690, 1563, 1564, 1565, 1566, 1567, + 1568, 1569, 1691, 1570, 1571, 1572, 1573, 1692, 1574, 1693, + 1575, 1576, 1577, 1578, 1579, 1694, 1695, 1580, 1581, 1582, + 1583, 1584, 1585, 1696, 1697, 1588, 1586, 1587, 1589, 1590, + 1591, 1592, 1593, 1594, 1698, 1595, 1596, 1597, 1598, 1599, + 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, + 1610, 1699, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, + 1619, 1620, 1621, 1622, 1700, 1623, 1624, 1625, 1701, 1626, + 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1702, + 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1703, 1704, + 1644, 1705, 1645, 1706, 1646, 1647, 1648, 1649, 1650, 1651, + 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1707, 1708, 1659, + 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1709, + 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1669, 1670, 1671, + 1428, 263, 1402, 1429, 1430, 1812, 1811, 1398, 871, 0, + 1395, 1394, 417, 0, 798, 284, 0, 0, 0, 0, + 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, + 0, 144, 0, 295, 294, 0, 0, 406, 0, 630, + 0, 0, 417, 0, 0, 0, 909, 1586, 907, 947, + 0, 214, 217, 215, 216, 0, 0, 716, 527, 0, + 526, 0, 0, 524, 0, 0, 0, 0, 528, 522, + 521, 0, 0, 0, 525, 0, 523, 0, 0, 799, + 906, 894, 880, 1440, 583, 587, 578, 584, 579, 576, + 577, 1598, 1426, 0, 0, 572, 582, 596, 602, 601, + 600, 0, 595, 598, 603, 0, 792, 1424, 826, 1407, + 980, 0, 0, 574, 791, 1644, 898, 0, 0, 720, + 0, 721, 0, 1613, 803, 200, 1621, 1703, 1644, 196, + 169, 1444, 0, 0, 595, 0, 800, 801, 987, 985, + 0, 1473, 1549, 193, 1609, 1621, 1703, 1644, 1668, 153, + 0, 207, 1621, 1703, 1644, 203, 819, 0, 794, 793, + 0, 1059, 0, 1055, 1395, 881, 884, 0, 1020, 964, + 0, 1, 96, 879, 875, 984, 984, 0, 984, 0, + 960, 0, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, + 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, + 1735, 1736, 1428, 0, 0, 1408, 1429, 1433, 0, 535, + 99, 1403, 0, 0, 0, 0, 1425, 0, 1464, 1513, + 1307, 1317, 1315, 1316, 1309, 1310, 1311, 1312, 1313, 1314, + 0, 707, 1308, 0, 99, 0, 0, 385, 0, 0, + 0, 0, 0, 99, 0, 0, 0, 0, 815, 818, + 796, 0, 0, 1378, 1399, 0, 867, 0, 0, 0, + 557, 0, 566, 558, 563, 0, 560, 0, 0, 568, + 0, 559, 561, 562, 567, 0, 0, 564, 565, 0, + 0, 807, 341, 0, 0, 0, 0, 0, 99, 858, + 299, 298, 99, 297, 296, 1464, 1513, 0, 650, 99, + 0, 146, 420, 0, 0, 467, 99, 0, 0, 0, + 0, 0, 0, 0, 0, 910, 908, 0, 922, 1525, + 0, 260, 0, 0, 1525, 849, 1525, 0, 1525, 139, + 1400, 1464, 1513, 1525, 0, 0, 1525, 131, 1525, 0, + 1525, 421, 0, 1525, 0, 1525, 133, 0, 1525, 260, + 533, 0, 903, 0, 580, 589, 588, 586, 585, 581, + 1427, 590, 591, 0, 597, 0, 0, 0, 0, 925, + 1396, 0, 806, 0, 0, 0, 723, 723, 723, 802, + 199, 197, 0, 0, 0, 0, 0, 0, 808, 0, + 0, 0, 1672, 1673, 1674, 1371, 0, 1675, 1676, 1677, + 1247, 1256, 1248, 1250, 1257, 1678, 1679, 1500, 1680, 1681, + 1421, 1682, 1683, 1685, 1686, 1687, 1688, 1252, 1254, 1689, + 1690, 0, 1422, 1692, 1693, 1578, 1695, 1696, 1698, 1699, + 1258, 1701, 1702, 1703, 1704, 1705, 1706, 1420, 0, 1259, + 1708, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1411, 1413, + 1414, 1318, 1423, 1380, 0, 0, 1393, 0, 1237, 0, + 1086, 1087, 1109, 1110, 1088, 1115, 1116, 1128, 1089, 0, + 1392, 1151, 1236, 1241, 0, 1235, 1231, 971, 1389, 1372, + 0, 1232, 1410, 1412, 209, 0, 210, 1621, 154, 192, + 164, 191, 195, 165, 194, 0, 1462, 155, 0, 162, + 0, 0, 0, 0, 206, 204, 0, 797, 260, 0, + 1057, 0, 1060, 0, 1056, 883, 880, 1385, 1384, 1386, + 0, 958, 957, 3, 886, 982, 983, 0, 0, 0, + 0, 0, 0, 0, 1013, 1002, 1010, 1014, 1021, 1409, + 0, 0, 0, 0, 0, 536, 0, 0, 0, 98, + 847, 202, 845, 0, 0, 0, 0, 852, 0, 0, + 0, 675, 0, 0, 0, 0, 0, 0, 676, 674, + 677, 684, 693, 696, 0, 620, 137, 138, 0, 0, + 0, 0, 0, 0, 219, 250, 0, 0, 0, 0, + 0, 101, 128, 0, 0, 0, 0, 383, 747, 747, + 0, 0, 747, 0, 0, 0, 747, 0, 218, 220, + 249, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 101, 130, 0, 0, 0, 813, 814, 0, 817, + 0, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, + 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, + 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, + 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, + 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, + 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, + 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, + 1806, 1807, 1808, 1809, 1810, 1434, 1375, 1374, 1405, 1435, + 1436, 1437, 1438, 1379, 870, 1406, 869, 0, 0, 0, + 0, 0, 1464, 1513, 0, 0, 0, 0, 0, 0, + 0, 287, 270, 271, 99, 269, 0, 0, 464, 0, + 1097, 1126, 1104, 1126, 1126, 1093, 1093, 1106, 1094, 1095, + 1133, 0, 1126, 1093, 1098, 0, 1096, 1136, 1136, 1121, + 1431, 0, 1078, 1079, 1080, 1081, 1107, 1108, 1082, 1113, + 1114, 1083, 1150, 1093, 1432, 0, 829, 857, 0, 101, + 501, 0, 0, 465, 0, 101, 0, 142, 0, 0, + 0, 0, 0, 0, 426, 425, 0, 0, 466, 101, + 385, 0, 378, 341, 0, 0, 1470, 0, 0, 0, + 950, 952, 951, 0, 949, 0, 1068, 0, 260, 258, + 259, 462, 715, 0, 0, 0, 260, 0, 0, 1525, + 0, 1525, 0, 0, 0, 260, 0, 0, 0, 0, + 532, 530, 529, 531, 0, 0, 0, 1525, 260, 0, + 0, 520, 1328, 0, 300, 887, 893, 889, 891, 890, + 892, 888, 571, 1485, 1518, 1543, 1614, 1619, 0, 1639, + 0, 604, 625, 599, 0, 0, 919, 912, 0, 0, + 935, 573, 1332, 0, 0, 0, 722, 719, 718, 717, + 198, 170, 0, 0, 0, 627, 1613, 805, 0, 0, + 1239, 1240, 1125, 1112, 1370, 0, 0, 1120, 1119, 0, + 0, 0, 0, 1102, 1101, 1100, 1238, 1331, 0, 1099, + 0, 0, 0, 0, 1126, 1126, 1124, 1170, 0, 1103, + 0, 0, 1350, 0, 1356, 0, 0, 0, 1132, 0, + 1130, 0, 0, 1206, 0, 0, 0, 0, 0, 0, + 0, 1233, 1154, 1155, 1707, 1237, 1328, 0, 1417, 0, + 0, 1118, 0, 1150, 0, 0, 0, 1383, 1326, 0, + 0, 1184, 1324, 0, 1186, 0, 0, 0, 1318, 1317, + 1315, 1316, 1309, 1310, 1311, 1312, 1313, 1314, 0, 1322, + 1167, 0, 0, 1166, 0, 0, 1023, 1373, 0, 1415, + 211, 212, 208, 0, 167, 166, 0, 189, 190, 185, + 401, 0, 161, 188, 399, 400, 0, 184, 403, 1297, + 1296, 168, 160, 158, 181, 183, 182, 180, 156, 171, + 173, 174, 175, 159, 157, 205, 539, 0, 1061, 0, + 1023, 937, 939, 940, 0, 1380, 872, 1388, 0, 0, + 876, 964, 969, 963, 968, 991, 992, 644, 967, 0, + 1019, 1019, 1004, 998, 1003, 999, 1005, 1012, 962, 1001, + 961, 0, 1015, 0, 0, 0, 0, 0, 0, 0, + 537, 0, 0, 0, 201, 844, 0, 0, 0, 0, + 0, 855, 335, 0, 257, 0, 0, 0, 0, 0, + 0, 682, 0, 0, 0, 0, 683, 680, 681, 1614, + 695, 694, 692, 661, 663, 662, 0, 653, 0, 654, + 0, 0, 660, 667, 665, 0, 0, 0, 0, 255, + 0, 254, 0, 0, 0, 0, 0, 703, 708, 0, + 127, 0, 0, 0, 0, 0, 387, 398, 0, 0, + 0, 0, 99, 99, 384, 746, 230, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 247, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 129, 0, 0, 0, 0, + 0, 179, 812, 816, 1376, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 342, 344, 0, 0, 273, 1431, + 0, 487, 463, 0, 1078, 0, 0, 1072, 1139, 1140, + 1141, 1138, 1142, 1137, 0, 1084, 1093, 1090, 0, 827, + 310, 135, 0, 0, 0, 475, 478, 0, 97, 146, + 300, 0, 145, 147, 149, 150, 151, 148, 152, 419, + 0, 0, 0, 0, 0, 431, 430, 432, 0, 427, + 0, 0, 126, 382, 0, 0, 302, 366, 0, 404, + 0, 0, 0, 0, 768, 0, 0, 0, 948, 0, + 1033, 921, 1024, 1035, 1026, 1028, 1062, 1398, 0, 0, + 919, 0, 699, 0, 850, 0, 697, 140, 1401, 0, + 0, 0, 0, 0, 0, 517, 132, 0, 260, 422, + 0, 260, 134, 0, 414, 260, 534, 905, 0, 0, + 608, 607, 618, 609, 610, 606, 605, 611, 0, 0, + 627, 914, 0, 915, 1380, 0, 911, 0, 932, 0, + 930, 0, 1397, 934, 923, 897, 0, 896, 900, 902, + 901, 899, 0, 0, 0, 595, 0, 0, 260, 804, + 0, 0, 0, 1334, 0, 0, 1369, 1365, 0, 0, + 0, 0, 0, 1341, 1342, 1343, 1340, 1344, 1339, 1338, + 1345, 0, 0, 0, 0, 0, 0, 0, 1123, 1122, + 0, 0, 0, 0, 0, 0, 0, 1209, 1241, 0, + 0, 1302, 0, 1328, 1355, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1328, 1361, 0, 0, 0, + 1295, 0, 1292, 0, 0, 0, 0, 1381, 1380, 0, + 0, 0, 0, 1418, 1168, 1391, 0, 1382, 0, 0, + 1175, 0, 1362, 1202, 0, 1207, 1190, 0, 1183, 0, + 1188, 1192, 1171, 1383, 1327, 0, 1325, 0, 0, 1169, + 0, 1164, 1162, 1163, 1156, 1157, 1158, 1159, 1160, 1161, + 1152, 1165, 1306, 1304, 1305, 0, 0, 0, 1187, 1519, + 1549, 0, 981, 981, 970, 979, 1390, 0, 1064, 0, + 0, 0, 1242, 0, 0, 402, 0, 1150, 0, 1058, + 944, 0, 0, 1068, 0, 943, 874, 873, 1387, 0, + 0, 642, 643, 0, 647, 1011, 0, 935, 935, 0, + 0, 0, 485, 484, 0, 0, 0, 755, 725, 538, + 756, 726, 0, 846, 0, 0, 0, 0, 0, 260, + 853, 757, 256, 854, 749, 0, 678, 679, 758, 727, + 0, 750, 664, 1093, 652, 0, 0, 659, 0, 658, + 1093, 1093, 728, 136, 252, 736, 253, 251, 0, 1404, + 0, 0, 0, 0, 739, 0, 0, 110, 112, 114, + 0, 0, 108, 116, 111, 113, 115, 109, 117, 107, + 0, 0, 106, 0, 0, 0, 0, 100, 763, 732, + 734, 751, 386, 397, 0, 390, 391, 388, 392, 393, + 0, 0, 0, 222, 0, 0, 233, 246, 241, 242, + 240, 260, 260, 0, 0, 0, 0, 243, 238, 239, + 235, 248, 733, 0, 752, 234, 232, 0, 221, 765, + 741, 0, 0, 0, 0, 0, 0, 0, 859, 0, + 0, 0, 764, 753, 740, 735, 0, 0, 177, 176, + 178, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 570, 546, 569, 0, 0, 0, 0, 0, 0, 0, + 540, 340, 0, 286, 267, 268, 0, 266, 0, 486, + 0, 0, 0, 1073, 0, 0, 0, 0, 0, 0, + 0, 0, 1091, 0, 0, 843, 843, 843, 843, 843, + 828, 851, 0, 506, 474, 0, 0, 341, 141, 0, + 0, 418, 473, 471, 470, 472, 0, 0, 0, 0, + 1069, 0, 0, 375, 0, 0, 0, 301, 303, 305, + 306, 307, 0, 379, 381, 0, 0, 370, 0, 0, + 0, 0, 633, 0, 0, 0, 691, 687, 670, 0, + 953, 954, 0, 964, 0, 1035, 0, 1034, 1046, 0, + 0, 1052, 1050, 0, 1052, 0, 1052, 0, 1027, 0, + 1029, 1046, 1399, 0, 1482, 1065, 920, 260, 0, 260, + 0, 260, 0, 260, 0, 260, 0, 789, 0, 459, + 260, 519, 1329, 0, 0, 0, 617, 612, 614, 0, + 621, 0, 0, 917, 918, 933, 926, 928, 927, 0, + 0, 924, 1333, 518, 0, 0, 260, 0, 622, 986, + 1336, 1337, 0, 0, 0, 0, 1366, 0, 0, 1271, + 1249, 1251, 1092, 1261, 0, 1105, 1272, 1273, 1253, 1255, + 0, 1319, 0, 0, 1262, 1211, 1212, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1224, 1223, 1263, 1301, 0, 0, 1353, 1354, 1264, 1134, + 1135, 1136, 1136, 0, 0, 1360, 0, 0, 0, 1269, + 1274, 0, 0, 1279, 0, 1300, 0, 0, 0, 1234, + 1329, 1127, 1128, 0, 0, 0, 0, 0, 0, 0, + 0, 1208, 1191, 1185, 0, 1189, 1193, 0, 0, 0, + 0, 1177, 1203, 1173, 0, 0, 1179, 0, 1204, 981, + 981, 981, 981, 978, 0, 0, 1022, 0, 1007, 0, + 0, 1246, 1243, 163, 0, 186, 172, 0, 0, 938, + 919, 941, 885, 993, 0, 1320, 647, 645, 646, 995, + 1018, 1017, 1016, 996, 1000, 997, 754, 724, 748, 843, + 0, 334, 0, 0, 0, 856, 672, 0, 1093, 655, + 656, 657, 0, 0, 0, 0, 0, 0, 0, 705, + 0, 706, 704, 122, 0, 0, 0, 0, 103, 102, + 123, 121, 0, 120, 0, 389, 394, 396, 395, 310, + 0, 0, 0, 223, 231, 228, 244, 236, 245, 237, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 759, 729, 1377, 541, 0, 0, 542, 550, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 552, 343, + 289, 274, 278, 858, 858, 0, 279, 858, 275, 858, + 272, 1578, 1310, 482, 489, 479, 481, 483, 480, 0, + 488, 454, 0, 0, 0, 1076, 0, 1144, 1145, 1146, + 1147, 1148, 1149, 1143, 1150, 0, 843, 842, 0, 0, + 0, 0, 0, 0, 0, 0, 321, 0, 0, 315, + 0, 0, 691, 309, 312, 313, 0, 476, 477, 0, + 300, 0, 434, 428, 0, 490, 468, 0, 1071, 906, + 302, 327, 362, 0, 377, 0, 364, 363, 365, 0, + 372, 825, 411, 408, 0, 633, 0, 0, 685, 688, + 686, 0, 666, 0, 671, 649, 0, 946, 1037, 1044, + 0, 1025, 0, 1051, 1047, 0, 1048, 0, 0, 1049, + 0, 0, 1044, 0, 0, 0, 700, 0, 698, 0, + 513, 0, 515, 0, 701, 260, 260, 415, 0, 378, + 619, 615, 0, 0, 592, 624, 913, 916, 931, 929, + 627, 0, 593, 626, 1335, 1111, 0, 1368, 1364, 0, + 1330, 0, 1348, 1347, 1349, 0, 1229, 0, 0, 1221, + 1219, 1220, 1213, 1214, 1215, 1216, 1217, 1218, 1210, 1222, + 1358, 1357, 1351, 1352, 1131, 1129, 0, 1266, 1267, 1268, + 1359, 1275, 0, 1294, 1293, 0, 0, 0, 1281, 0, + 0, 1290, 0, 1303, 1117, 1150, 1153, 0, 0, 1176, + 1363, 1194, 0, 0, 0, 1172, 0, 0, 0, 0, + 1181, 1319, 0, 0, 0, 0, 0, 0, 973, 972, + 1063, 0, 1009, 1244, 1245, 1416, 0, 0, 945, 936, + 0, 994, 0, 336, 0, 0, 691, 673, 0, 668, + 0, 0, 0, 0, 0, 507, 493, 0, 0, 508, + 509, 0, 0, 0, 118, 104, 125, 124, 105, 119, + 308, 0, 0, 0, 0, 262, 737, 0, 0, 0, + 0, 0, 767, 745, 766, 743, 742, 744, 738, 0, + 544, 0, 0, 0, 545, 556, 554, 553, 555, 547, + 290, 99, 0, 0, 0, 0, 0, 0, 0, 456, + 0, 0, 461, 450, 452, 0, 0, 0, 1074, 1077, + 1085, 449, 0, 838, 837, 836, 833, 832, 841, 840, + 831, 830, 835, 834, 0, 0, 319, 323, 324, 322, + 314, 691, 341, 374, 0, 0, 0, 436, 0, 0, + 469, 0, 1070, 904, 0, 325, 0, 366, 304, 380, + 381, 0, 0, 376, 0, 0, 0, 820, 0, 413, + 409, 0, 0, 632, 0, 0, 691, 690, 784, 785, + 782, 783, 0, 1036, 0, 0, 1038, 0, 0, 1040, + 1042, 0, 0, 0, 0, 0, 1402, 1243, 1067, 1066, + 260, 260, 260, 260, 790, 460, 0, 0, 0, 613, + 260, 0, 1367, 1260, 1270, 1346, 0, 0, 1230, 0, + 0, 1265, 1709, 0, 0, 1298, 1299, 1280, 0, 1564, + 1285, 0, 0, 0, 1419, 1200, 1198, 1195, 0, 1196, + 0, 0, 1178, 1174, 0, 1180, 1205, 977, 976, 975, + 974, 0, 0, 965, 1150, 942, 0, 848, 0, 691, + 374, 669, 761, 730, 0, 0, 499, 0, 0, 0, + 0, 762, 731, 760, 224, 225, 226, 227, 0, 229, + 0, 0, 0, 864, 0, 0, 548, 549, 543, 273, + 0, 276, 281, 0, 282, 277, 280, 458, 457, 455, + 451, 453, 1075, 0, 713, 0, 454, 839, 0, 0, + 311, 374, 348, 0, 316, 0, 825, 302, 435, 0, + 0, 429, 491, 366, 0, 0, 326, 0, 370, 0, + 367, 0, 371, 0, 0, 822, 410, 0, 405, 0, + 0, 0, 0, 634, 641, 641, 689, 648, 0, 0, + 1045, 1054, 0, 1041, 1039, 1030, 0, 1032, 714, 514, + 516, 702, 616, 623, 260, 1225, 0, 0, 0, 0, + 1276, 0, 1277, 1282, 1286, 0, 1283, 1284, 1197, 1201, + 1199, 1182, 1006, 1008, 187, 1321, 0, 374, 337, 0, + 0, 505, 494, 0, 0, 510, 261, 0, 0, 0, + 0, 0, 551, 265, 288, 283, 713, 0, 710, 448, + 0, 318, 317, 0, 353, 0, 503, 821, 437, 438, + 433, 0, 370, 331, 329, 333, 330, 328, 332, 0, + 372, 368, 369, 823, 824, 412, 866, 0, 0, 691, + 0, 0, 639, 644, 644, 1064, 1043, 0, 1031, 594, + 1226, 0, 1227, 0, 0, 1288, 1287, 341, 338, 0, + 497, 504, 0, 495, 0, 0, 860, 0, 861, 862, + 865, 709, 712, 711, 0, 345, 346, 347, 0, 320, + 349, 350, 0, 0, 0, 0, 372, 361, 292, 691, + 641, 372, 635, 640, 647, 647, 0, 1053, 1228, 1291, + 1278, 1289, 348, 0, 0, 512, 511, 0, 0, 0, + 0, 0, 351, 0, 352, 373, 502, 0, 441, 293, + 372, 644, 1064, 637, 636, 788, 353, 0, 505, 863, + 0, 358, 0, 357, 0, 355, 354, 492, 443, 445, + 446, 442, 0, 439, 444, 447, 1064, 647, 628, 787, + 786, 0, 454, 498, 496, 0, 356, 360, 359, 423, + 0, 629, 638, 770, 781, 769, 771, 779, 776, 778, + 777, 775, 339, 0, 440, 0, 780, 774, 964, 955, + 0, 772, 781, 441, 773, 0, 424 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short int yydefgoto[] = +{ + -1, 47, 48, 49, 50, 1000, 1590, 2057, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 1029, 60, 61, + 750, 1237, 1702, 62, 1534, 600, 1478, 1479, 1642, 1480, + 1462, 940, 1481, 1001, 1021, 64, 65, 935, 1452, 66, + 67, 68, 1058, 1059, 1034, 1060, 1007, 1271, 2979, 69, + 70, 2146, 1184, 2147, 2520, 466, 1667, 2801, 2802, 71, + 1234, 2196, 2197, 2198, 2199, 2171, 2563, 2564, 2565, 2200, + 2855, 3026, 2201, 1542, 1181, 1663, 1664, 3114, 3179, 3180, + 3181, 3235, 2857, 2207, 2590, 2863, 3014, 72, 1251, 1727, + 2202, 2203, 73, 74, 1047, 1604, 2064, 1482, 1464, 1465, + 75, 492, 2592, 2869, 3038, 76, 169, 77, 1239, 78, + 79, 1246, 1718, 1719, 2848, 3019, 3120, 3242, 3243, 3006, + 2812, 2813, 2814, 80, 81, 82, 83, 1581, 1694, 1695, + 2524, 991, 1188, 1670, 1671, 2574, 84, 2755, 2756, 493, + 3184, 3163, 85, 86, 2759, 2760, 87, 88, 89, 90, + 91, 528, 799, 800, 2021, 92, 93, 730, 2131, 94, + 544, 813, 95, 96, 551, 1815, 553, 1320, 2266, 2267, + 2644, 1781, 663, 97, 98, 1790, 1818, 99, 494, 2597, + 3042, 3043, 3143, 1974, 2419, 100, 495, 1025, 1568, 1569, + 1570, 1571, 2601, 1572, 2216, 2217, 2218, 2598, 2605, 101, + 1023, 1562, 102, 103, 104, 1586, 680, 105, 3108, 106, + 773, 107, 572, 1337, 108, 1607, 109, 110, 111, 2219, + 3265, 3275, 3276, 3277, 2882, 3251, 112, 3267, 114, 115, + 116, 149, 698, 699, 700, 117, 2867, 118, 119, 1689, + 2170, 2548, 120, 121, 1535, 1993, 122, 123, 124, 1228, + 125, 126, 127, 128, 706, 129, 130, 131, 624, 616, + 966, 1500, 132, 1305, 532, 133, 824, 1807, 134, 802, + 135, 3268, 1326, 1792, 1793, 1796, 3269, 1266, 138, 1330, + 1801, 1804, 3270, 1490, 1491, 1492, 1493, 1494, 1961, 140, + 767, 1737, 3271, 908, 143, 144, 145, 1446, 1944, 561, + 977, 590, 629, 630, 1505, 1506, 984, 1520, 1513, 1515, + 2732, 2953, 985, 1518, 986, 987, 1977, 146, 1948, 1741, + 1742, 1743, 2227, 2237, 2614, 2889, 1744, 612, 1745, 2398, + 1750, 2189, 2190, 1332, 1677, 1212, 909, 1213, 1687, 910, + 1369, 1215, 911, 912, 913, 1218, 914, 915, 916, 917, + 1353, 1411, 918, 919, 1388, 1685, 1302, 1856, 921, 922, + 2701, 2932, 2923, 1881, 1882, 1471, 2697, 923, 1935, 1439, + 682, 924, 2526, 1441, 1876, 1841, 1524, 1822, 1351, 1842, + 1853, 2313, 1860, 1865, 2336, 2337, 1877, 1903, 925, 1826, + 1827, 2297, 1355, 926, 703, 704, 1401, 1899, 969, 970, + 618, 927, 928, 929, 1321, 613, 2885, 780, 660, 2028, + 1157, 459, 558, 930, 931, 932, 933, 2268, 1468, 614, + 655, 1158, 453, 454, 657, 1162, 461 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -2901 +static const int yypact[] = +{ + 5939, 311, 4200, -2901, -2901, 311, -2901, 33528, 32394, 52, + 588, 97, 4480, 33906, 38442, 470, 161, 48207, 311, 38442, + 277, 24812, 29748, 573, 38442, -78, 433, 24812, 38442, 38820, + 531, 477, 39198, 34284, 29370, 693, 38442, 727, 39576, 34662, + 529, 433, 22505, 30504, 849, 508, 590, 1046, 669, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, 772, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, 1327, -2901, 582, 1378, 748, -2901, -2901, -2901, + 27858, 38442, 38442, 38442, 27858, 38442, 30504, 20152, -2901, 38442, + 38442, 30504, 30504, 38442, 924, 38442, 38442, 38442, 30504, 1057, + 66, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, 643, 941, 1072, + 1085, -2901, 3334, -78, -2901, -2901, 32394, 922, 27858, 38442, + 946, 994, 38442, -2901, 38442, 826, 38442, 848, 20547, 1087, + 38442, 38442, 38442, -2901, -2901, 1077, 38442, -2901, 38442, -2901, + 38442, -6, 1117, 1316, 1243, 447, -2901, 35040, -2901, -2901, + 30504, -2901, -2901, -2901, -2901, 28236, 38442, 1282, -2901, 39954, + -2901, 28614, 40332, -2901, 20942, 1415, 40710, 41088, -2901, -2901, + -2901, 41466, 1180, 41844, -2901, 42222, -2901, 1328, 42600, -2901, + 1126, -2901, 772, -106, -2901, 102, 112, 106, 115, 116, + 118, -106, -2901, 1133, 817, -2901, -2901, 1281, -2901, -2901, + -2901, 1310, 409, -2901, -2901, 32394, -2901, -2901, -2901, -2901, + -2901, 32394, 817, -2901, -2901, -78, 1149, 1522, 38442, -2901, + 38442, -2901, 32394, 38442, -2901, -2901, 1538, 1212, 1421, 1196, + -2901, 1375, 1432, 1385, 20, -78, 1379, -2901, -2901, 1465, + 11511, 30882, 42978, 49, 26720, 35418, 1348, 66, 1481, -2901, + 236, -2901, 1686, 1361, 1574, 1196, 66, 32394, -2901, -2901, + 18218, 43356, 1475, 1364, -2901, -2901, 1643, 11910, -2901, 1387, + 1389, -2901, 5939, -2901, 32394, 843, 843, 1745, 843, 970, + 1007, 508, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, 842, 643, 1405, -2901, 918, -2901, 906, 1404, + 915, -2901, 192, 909, 1420, 224, -2901, 1091, 38442, 38442, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + 1433, -2901, -2901, 1412, 856, 973, 12, 408, 1806, 1017, + 241, 1592, 704, 967, 1567, 38442, 1666, -7, -2901, 6, + -2901, 13905, 22127, -2901, 643, 38442, -2901, 32394, 27858, 1448, + -2901, 38442, -2901, -2901, -2901, 27858, -2901, 1628, 21337, -2901, + 38442, -2901, -2901, -2901, -2901, 1568, 38442, -2901, -2901, 1679, + 38442, -2901, 1454, -53, 1457, 1812, 47136, 38442, 1501, 1841, + -2901, -2901, 1501, -2901, -2901, 38442, 38442, 1462, 740, 1501, + 1839, 1842, 1636, 293, 1320, 101, 1501, 32394, 32394, 32394, + 1704, 38442, 43734, 27858, 38442, -2901, -2901, 198, 1536, 1764, + 1405, 237, 1766, 1483, 1769, -2901, 1770, 1420, 1771, 1484, + -2901, 44112, 44490, 1772, 1490, 38442, 1780, 1484, 1781, 1669, + 1791, -2901, 571, 1792, 1681, 1797, 1484, 27100, 1801, 108, + -2901, 13905, -2901, 625, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, 38442, -2901, 31260, 38442, 31638, 61, 78, + -2901, 38442, -2901, 47136, 1899, 38442, 1793, 1793, 1793, -2901, + -2901, -2901, 1741, 38442, 1802, 1803, 31260, 38442, -2901, 44868, + 1526, 1032, 1541, 810, 1548, 13905, 1530, 88, 88, 1531, + -2901, -2901, 1532, 1535, -2901, 976, 976, 1689, 1537, 1540, + -2901, 977, 1542, 1557, 1560, 1021, 1543, 1544, 1545, 1372, + 88, 13905, -2901, 1547, 976, 1549, 1550, 1554, 1575, 1555, + -2901, 1576, 1558, 804, 1026, 1561, 1562, -2901, 1537, -2901, + 90, 1565, 1566, 1569, 1572, 1573, 1577, 1580, -2901, -2901, + -2901, -2901, -2901, -2901, 13905, 13905, -2901, 12309, -2901, -78, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, 99, -2901, 1022, + 5458, -2901, -2901, 1711, 13905, -2901, -2901, 151, -2901, 643, + 1023, -2901, -2901, -2901, -2901, 205, 1563, 959, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, 26340, 1941, -2901, 659, 6, + 975, 1902, 23639, 24030, -2901, -2901, 1795, -2901, 128, 32394, + -2901, 38442, -2901, 18978, -2901, -2901, 772, -2901, 25170, -2901, + 1009, -2901, -2901, -2901, 1582, -2901, -2901, 590, 590, 13905, + 590, -10, 12708, 13905, 1858, 760, 1860, -2901, -2901, 643, + 22883, 771, 1663, 1665, 27480, 1587, 1667, 1671, 42978, -2901, + -2901, -2901, -2901, 139, 633, 1672, 121, -2901, 1768, -95, + 1707, -2901, 1674, 1675, 1782, -95, 177, 45246, -2901, -2901, + -2901, -2901, -2901, 2725, 10734, -2901, -2901, -2901, 1676, 1660, + 1680, 1682, 1462, 441, 1598, -2901, 1662, 1670, 46002, 21732, + 1684, -2901, -2901, 1690, 1691, 1692, 1728, 828, 129, 1964, + 1789, 394, 1177, 142, 32394, 1868, 181, 540, 1631, -2901, + -2901, 1714, 1715, 38442, 38442, 38442, 38442, 30504, 1716, 1759, + 1718, -2901, -2901, 1719, 1035, 926, -2901, -2901, 66, -2901, + 3616, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, 1405, 47136, 1815, + 1420, -95, 38442, 38442, 1645, 463, 640, 1819, 38442, 1881, + 38442, 1693, -2901, -2901, 1501, -2901, 23261, 1462, -2901, 1650, + -2901, 1702, -2901, 1702, 1702, 1653, 1653, 1654, -2901, -2901, + -2901, 1372, 1702, 1653, -2901, 47892, -2901, -88, 777, -2901, + -2901, 2038, 2041, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, 68, 1079, -2901, 2050, -2901, -2901, 47136, -2901, + 1975, 1720, 27480, -2901, 1712, -2901, 38442, 173, 38442, 1876, + 38442, 38442, 38442, 38442, -2901, -2901, 71, 55, -2901, -2901, + -2901, 2047, -30, 1454, 26720, 1942, 38442, 1840, 1420, 2049, + -2901, 310, -2901, 1787, -2901, 17078, 1721, 27858, 237, -2901, + -2901, -2901, -2901, 47136, 38442, 27858, 237, 38442, 38442, 1956, + 1733, 1962, 1736, 21732, 46002, 143, 38442, 38442, 32394, 38442, + -2901, -2901, -2901, -2901, 38442, 32394, 38442, 1965, 237, 38442, + 38442, -2901, 25170, 1055, 72, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, 38442, 27858, 38442, 38442, 32394, 32394, 38442, + 1756, 1563, 479, -2901, 1734, 18598, 1811, -2901, 140, 32394, + 1867, -2901, -2901, 1058, 491, 545, -2901, -2901, -2901, -2901, + -2901, -2901, 31638, 29748, 1959, 19, 38442, -2901, 13905, 13107, + -2901, -2901, -2901, 1696, 25170, 1737, 13905, -2901, -2901, 13905, + 1717, 1717, 13905, -2901, -2901, -2901, -2901, 514, 1717, -2901, + 13905, 13905, 1717, 1717, 1702, 1702, -2901, 2347, 13905, -2901, + 21732, 13905, 15501, 9956, 13905, 1775, 1784, 1717, -2901, 1717, + -2901, 13905, 11112, -2901, 13905, 1908, 13905, 975, 1909, 13905, + 975, 643, 1709, 1709, 508, 908, 6279, 1710, -2901, 1817, + 1717, -2901, 1717, 136, 13905, 27480, 1790, 155, 13905, 1723, + 542, -2901, 13905, 157, -2901, 1724, 13905, 1804, 147, 13905, + 13905, 13905, 13905, 13905, 13905, 13905, 13905, 13905, 47136, -2901, + 15900, 160, -40, 294, 32016, 11511, 1984, 972, 9556, -2901, + -2901, -2901, -2901, 1941, -2901, -2901, 1799, -2901, -2901, -2901, + -2901, 854, -2901, -2901, -2901, -2901, 1031, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, 1722, -2901, + -2901, -2901, -2901, -2901, 1722, -2901, -2901, 1725, -2901, 38442, + 22, -2901, -2901, -2901, 1742, -2901, 30126, -2901, 11910, 38442, + -2901, -2901, 1957, -2901, -2901, 1726, -2901, 4031, 1957, 1900, + 1913, 1913, -2901, -43, 25170, 1960, 25170, -2901, -2901, -2901, + -2901, 611, -2901, 1738, 1075, 1814, 1816, 1865, 38442, 38442, + -2901, 27480, 38442, 38442, -2901, 2095, 1758, 38442, 1985, 1988, + 1761, -2901, -2901, 38442, -2901, 1937, 38442, 13905, 1943, 38442, + 1945, -2901, 642, 38442, 38442, 1938, -2901, -2901, -2901, 38442, + -2901, -2901, -2901, 1933, -2901, -2901, 47892, -2901, 1083, -2901, + 47514, 45624, -2901, -2901, 193, 38442, 38442, 38442, 38442, -2901, + 38442, -2901, 24, 38442, 38442, 1767, 1773, 1774, -2901, 38442, + 5226, 38442, 38442, 38442, 38442, -95, -2901, 2134, -95, -95, + 709, 2136, 1501, 1501, -2901, -2901, -2901, 38442, 38442, 38442, + 38442, 32772, 38442, 38442, 752, 780, 38442, 33150, -2901, 32394, + 38442, 38442, 38442, 538, 1305, 38442, 38442, 697, -15, 1910, + 1915, 1916, 38442, 38442, 38442, 5226, 38442, 1849, 1854, 111, + 1925, -2901, -2901, -2901, -2901, 13905, 2016, 2166, 38442, 2018, + 2020, 1846, 1847, 46002, 216, 38442, 38442, 38442, 38442, 38442, + 38442, 2024, 216, 1088, -2901, -2901, 1967, 73, -2901, 1808, + 1100, -2901, -2901, 13905, 2178, 47136, 1800, 1805, 1873, 1875, + 1877, -2901, -2901, 1878, 1717, -2901, 1228, -2901, 71, 605, + -2901, 5226, 2080, 38442, 1103, -2901, 1822, 32394, 5226, -2901, + 943, 29748, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -78, 1462, 1462, 1462, 1462, -2901, -2901, -2901, 1981, 1979, + 1818, 38442, 5226, 828, 154, 32394, 28992, 1078, 2196, 2078, + -78, 1990, 32394, 1914, -2901, 2079, 2083, 2102, -2901, 16698, + 35796, 1824, 1249, -2901, 35796, 36174, -2901, 643, 1831, 14304, + 1811, 1405, -2901, 2214, -2901, 1420, -2901, 1484, -2901, 38442, + 38442, 38442, 38442, 1834, 1836, -2901, 1484, 2006, 237, -2901, + 2009, 237, 1484, 26720, -2901, 108, -2901, -2901, 13905, 1924, + 1484, 1835, -2901, 1484, 1484, 1563, 1563, 1484, 36552, 2235, + 2108, -2901, 1114, -2901, -2901, 11511, -2901, 137, -2901, 255, + 2, 2051, -2901, -2901, -2901, -2901, 47136, -2901, -2901, -2901, + -2901, -2901, 38442, 23, 2017, 1843, 36552, 2210, 237, -2901, + 1128, 260, 663, -2901, 13905, 13905, 53, -2901, 6712, 1130, + 1848, 1850, 1131, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, 1852, 2120, 1853, 1136, 1139, 1855, 1856, -2901, -2901, + 3929, 1861, 6816, 1863, 15501, 15501, 2364, -2901, -2901, 15501, + 1864, -2901, 1145, 4720, 1862, 1872, 1882, 1886, 1879, 1880, + 7053, 13506, 13905, 13506, 13506, 7240, 1862, 1883, 1146, 27480, + 7342, 1151, -2901, 13905, 27480, 4009, 13905, -2901, -2901, 13905, + 38442, 1884, 1888, -2901, 2347, -2901, 1893, -2901, 15501, 15501, + 5163, 12309, -2901, -2901, 2131, -2901, -2901, 630, -2901, 1869, + -2901, -2901, 5865, 165, 13905, 1723, 13905, 1952, 21732, 7137, + 13905, 4467, 5477, 5477, 148, 148, 107, 107, 107, 98, + -2901, 294, -2901, -2901, -2901, 1891, 1555, 13905, -2901, 1370, + 1382, 32394, 2980, 3496, -2901, -2901, -2901, 17078, 1922, 13905, + 13905, 1892, -2901, 1154, 66, -2901, 1717, 136, 24421, -2901, + -2901, 1161, 18978, 1721, 11910, 643, -2901, -2901, -2901, 1164, + 13905, -2901, -2901, 1447, 1025, -2901, 38442, 1867, 1867, 13905, + 13905, 12708, -2901, -2901, 38442, 38442, 38442, -2901, -2901, -2901, + -2901, -2901, 2097, -2901, 13905, 113, 1894, 1895, 38442, 237, + -2901, -2901, 25170, -2901, -2901, 2125, -2901, -2901, -2901, -2901, + 2073, -2901, -2901, 1079, -2901, 45624, 47514, -2901, 47514, -2901, + 1079, 674, -2901, 1484, -2901, -2901, -2901, -2901, 1048, -2901, + 186, 47136, 2056, 46380, -2901, 38442, 2115, -2901, -2901, -2901, + 2058, 462, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + 333, 38442, -2901, 1717, 2060, 38442, 1966, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -95, -2901, -2901, -2901, -2901, -2901, + 38442, -95, -95, -2901, 47136, 320, -2901, -2901, -2901, -2901, + -2901, 237, 237, 38442, 38442, 38442, 38442, -2901, -2901, -2901, + -2901, -2901, -2901, 1980, -2901, -2901, -2901, 802, -2901, -2901, + -2901, 2114, 2122, 2124, 1992, 1993, 1995, 1996, -2901, 1998, + 1999, 2000, -2901, -2901, -2901, -2901, 38442, 38442, -2901, -2901, + -2901, 7624, 216, 47136, 2157, 216, 216, 38442, 38442, 1898, + -2901, -2901, -2901, 2158, 2159, 2160, 2161, 2162, 2163, 216, + -2901, -2901, 38442, -2901, -2901, -2901, -53, 1298, 19757, -2901, + 1953, 7646, 1936, 1805, 1934, 1717, 788, 557, 47, 2052, + 2142, 1939, -2901, 2113, 2164, 1961, 1961, 1961, 1961, 1961, + -2901, 903, 2010, -2901, -2901, 27480, 19757, 1454, 173, 2077, + 699, -2901, -2901, -2901, -2901, -2901, 32394, 71, -78, 1167, + -2901, 47136, 38442, -2901, 1949, 32394, 1954, 1940, -2901, -2901, + -2901, -2901, 1174, -2901, 47136, -14, 2127, 2128, 590, 38442, + 2032, 32394, 2015, -78, 26720, 46758, 1944, -2901, -2901, 2130, + -2901, -2901, 590, 10356, 1249, 1963, 38442, -2901, 1968, 17078, + 2189, 2126, -2901, 17078, 2126, 1041, 2126, 2190, -2901, 19358, + -2901, 1969, 912, 9556, 2141, 25170, -2901, 237, 47136, 237, + 2023, 237, 2027, 237, 46002, 237, 32394, -2901, 32394, -2901, + 237, -2901, 25170, 32394, 27858, 38442, 617, -2901, -2901, 2135, + -2901, 590, 38442, 643, 1970, -2901, -2901, -2901, -2901, 2258, + 2259, -2901, -2901, -2901, 38442, 31260, 146, 38442, -2901, -2901, + -2901, -2901, 1976, 1175, 7675, 13905, -2901, 2268, 47136, -2901, + -2901, -2901, -2901, -2901, 13905, -2901, -2901, -2901, -2901, -2901, + 13905, -2901, 13905, 2248, -2901, 1978, 1978, 15501, 917, 1549, + 15501, 15501, 15501, 15501, 15501, 15501, 15501, 15501, 15501, 47136, + 16299, 690, -2901, -2901, 13905, 13905, 2257, 2248, -2901, -2901, + -2901, 1264, 1264, 47136, 1982, 1862, 1983, 1986, 13905, -2901, + -2901, 1182, 27480, -2901, 13905, 4759, 1183, 2036, 7938, 643, + 7961, -2901, 2345, -78, 13905, 1390, 1635, 13905, 1189, 13905, + 2260, -2901, -2901, -2901, 1991, -2901, -2901, 47136, 13905, 15501, + 15501, 6199, -2901, 7755, 13905, 1997, 8547, 12309, -2901, 433, + 433, 433, 433, -2901, 32394, 32394, 1824, 13905, 2255, 1200, + 1205, -2901, -78, 6, 2001, -2901, -2901, 2012, 38442, -2901, + 1811, -2901, -2901, -2901, 2003, -2901, 1025, -2901, -2901, -2901, + 1484, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, 1961, + 8084, -2901, 38442, 38442, 1208, -2901, -2901, 2238, 1054, -2901, + -2901, -2901, 2067, 2081, 2082, 543, 103, 2085, 2088, -2901, + 2090, -2901, -2901, 1484, -106, -78, 38442, 38442, -2901, -2901, + 1484, -2901, -78, 1484, -78, -2901, -2901, -2901, -2901, -2901, + 619, 594, 47136, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + 38442, 2276, 134, 1118, 38442, 38442, 38442, 38442, 38442, 38442, + 38442, -2901, -2901, -2901, -2901, 2019, 216, -2901, -2901, 2236, + 2239, 2249, 216, 216, 216, 216, 216, 216, -2901, -2901, + 149, -2901, -2901, 1841, 1841, 768, -2901, 1841, -2901, 1841, + -2901, 2003, 854, -2901, -2901, -2901, -2901, -2901, -2901, 1808, + -2901, 528, 1717, 1455, 2022, -2901, 2031, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, 136, 32394, 1961, -2901, 59, 62, + 36930, 37308, 37686, 2044, 38442, 15501, -2901, 726, 539, -2901, + 2246, 32394, 2061, -2901, -2901, -2901, 47136, -2901, -2901, 2403, + 72, 32394, 2313, 2207, 1214, -2901, -2901, 38442, -2901, 1126, + 28992, -2901, 2287, 28992, -2901, 38442, -2901, -2901, -2901, 2391, + 2132, 1277, 2101, 1404, -78, 2015, 38442, 2053, -2901, 2045, + -2901, 2573, -2901, 1462, -2901, -2901, 629, -2901, 35796, 2059, + 38442, 1249, 17078, -2901, -2901, 117, -2901, 17078, 2278, -2901, + 17078, 38442, 2062, 38442, 1215, 25571, -2901, 2055, -2901, 38442, + -2901, 38442, -2901, 2057, -2901, 237, 237, -2901, 2432, 2064, + -2901, -2901, 2326, 36552, -2901, -2901, -2901, -2901, -2901, -2901, + 19, 2331, -2901, -2901, -2901, -2901, 13905, 25170, -2901, 2065, + 25170, 8191, 25170, 2257, 2392, 2335, -2901, 792, 2068, 2392, + 2782, 2782, 1104, 1104, 839, 839, 839, 1978, -2901, 690, + 25170, 25170, -2901, -2901, -2901, -2901, 2066, -2901, -2901, -2901, + 1862, -2901, 14703, -2901, -2901, 2112, 2118, 2069, -2901, 13905, + 15102, 2071, 47892, -2901, -2901, 136, 1709, 15501, 15501, 902, + -2901, 213, 13905, 47136, 1229, 902, 1757, 2040, 13905, 13905, + 8730, 180, 13905, 8421, 32394, 32394, 32394, 32394, -2901, -2901, + 25170, 2436, 2333, -2901, -2901, -2901, -78, 508, -2901, -2901, + 21732, -2901, -106, -2901, 1275, 1285, 2061, -2901, 2144, -2901, + 38442, 38442, 1717, 1717, 47136, 2074, -2901, 1717, 1717, 2089, + -2901, 38442, 38442, 38442, -2901, -2901, 1484, 1484, -2901, -2901, + 903, 2266, 2267, -106, 38442, 2145, -2901, 38442, 38442, 38442, + 38442, 2371, -2901, -2901, -2901, -2901, -2901, -2901, -2901, 2322, + -2901, 216, 216, 216, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, 1501, 2400, -78, -78, 2277, 38442, -78, -78, -2901, + 789, 2409, -2901, 2349, 683, 2109, 2368, 2375, -2901, -2901, + -2901, 2379, -106, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, 13905, 110, 2392, -2901, -2901, -2901, + -2901, 2061, 1454, 2167, 2170, 590, -5, 2410, 2402, 71, + -2901, -78, -2901, -2901, 2117, 730, 2119, 1078, -2901, -2901, + -2901, 533, 38442, -2901, 2474, 2475, 2290, -2901, 38442, 2351, + 1587, 2396, 2140, -2901, 17458, -78, 1944, -2901, -2901, -2901, + -2901, -2901, 2206, -2901, 38442, 1287, -2901, 13905, 2148, -2901, + -2901, 17078, 117, 1295, 38442, 1321, 47136, -2901, -2901, -2901, + 237, 237, 237, 237, -2901, -2901, 2416, 38442, 2309, -2901, + 237, 36552, 25170, -2901, -2901, -2901, 15501, 2414, -2901, 2149, + 47136, -2901, 2150, 1323, 1324, -2901, -2901, -2901, 8465, 2198, + 25170, 2250, 2151, 2152, -2901, 1479, 1479, 213, 1332, -2901, + 15501, 15501, 902, 902, 13905, 902, -2901, -2901, -2901, -2901, + -2901, 13905, 13905, -2901, 136, -2901, 2153, -2901, 2295, 2061, + 2167, -2901, -2901, -2901, 17838, 21732, -2901, 543, 2165, 2168, + 103, -2901, -2901, -2901, -2901, -2901, -2901, -2901, 13905, -2901, + 739, 414, 2199, 1484, 2437, 216, -2901, -2901, -2901, -2901, + -78, -2901, -2901, 38442, 2169, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, 27858, 2544, 32394, 528, -2901, 8492, 2348, + -2901, 2167, 2374, 2418, -2901, 38442, 1277, 28992, -2901, 969, + 2315, -2901, -2901, 1078, 185, 200, -2901, 32394, 2128, 2292, + -2901, 2294, -2901, 2343, 2344, -2901, -2901, -78, -2901, 38442, + 17458, 13905, 1335, -2901, 38064, 9173, -2901, -2901, 32394, 1338, + -2901, 25170, 38442, -2901, -2901, -2901, 1340, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, 146, 874, 15501, 47136, 1350, 13905, + -2901, 13905, -2901, -2901, -2901, -13, -2901, -2901, -2901, 1479, + 1479, 902, 1862, 25170, -2901, -2901, 32394, 2167, -2901, 47136, + 1420, -28, -2901, 47136, 47136, -2901, 25170, 38442, 38442, 38442, + 38442, 38442, -2901, 1298, -2901, 2169, 2544, 660, -2901, -2901, + 2452, -2901, -2901, 483, 2353, 2264, 2464, -2901, -2901, -2901, + -2901, 27858, 2128, -2901, -2901, -2901, -2901, -2901, -2901, 1353, + 2132, -2901, -2901, -2901, -2901, -2901, -2901, 1355, 25139, 2061, + 17458, 38442, -2901, 248, 248, 1922, -2901, 1358, -2901, -2901, + 874, 1360, -2901, 1363, 1386, 2240, -2901, 1454, -2901, 1394, + -2901, -2901, 46002, -2901, 1395, 1396, 2183, 2232, 2183, -2901, + 1484, -2901, -2901, -2901, 2487, -2901, -2901, -2901, 152, -2901, + 2365, 2367, 38442, 38442, 2578, 2202, 2132, -2901, -2901, 2061, + 38064, 2132, -2901, -2901, 1025, 1025, 2499, -2901, -2901, -2901, + -2901, -2901, 2374, 27858, 2203, -2901, -2901, 38442, 2328, 378, + 378, 2516, -2901, 2271, -2901, -2901, -2901, 543, 25956, -2901, + 2132, 248, 1922, -2901, -2901, 637, 2353, 1420, 2354, -2901, + 2493, -2901, 2608, -2901, 174, -2901, -2901, 2074, -2901, -2901, + -2901, -2901, 1397, -2901, -2901, -2901, 1922, 1025, -2901, -2901, + -2901, 581, 528, -2901, -2901, 2360, -2901, -2901, -2901, -2901, + 25956, -2901, -2901, -2901, 613, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, 27858, -2901, 1345, -2901, -2901, 1365, 1389, + 2217, -2901, 613, 25956, -2901, 1422, -2901 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short int yypgoto[] = +{ + -2901, -2901, -2901, 2004, -2901, -645, -444, -2901, -2901, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, + -2901, 920, -2901, -2901, 67, 1312, 1668, 665, -2901, -2901, + -2901, -2901, -569, 85, 498, -2901, -2901, -2901, -2901, -2901, + -2901, -2901, -2901, 1001, -2901, -612, 553, 819, -2901, -2901, + -2901, -2901, 485, -357, -2901, -2901, -2901, -2901, -2901, -1192, + 3, 54, -2901, 58, 1029, 169, -2901, -193, -2901, -2901, + -2901, -2901, -352, 648, -1241, -1957, 503, -554, -577, -531, + -529, -558, -2901, -2628, -2782, -1991, -2710, -2901, 391, -2901, + -2901, 70, -1178, -2901, 1406, -2901, -2901, -845, -2901, -116, + -2901, -2901, -209, -2901, -2901, -2901, 84, -2901, -2901, -2901, + -1177, -2901, 974, -2117, -2901, -2901, -2901, -622, -597, -2901, + -2814, -150, -148, -2901, -2901, -2901, -2901, -682, -2901, 492, + 490, -694, -2901, -2901, 518, -2901, -2901, -545, -293, 1446, + -2901, -551, -2901, -2901, -2901, -290, -2901, -2901, -2901, -2901, + -2901, -2901, -1292, 653, -639, -2901, -2901, -2901, -1060, -2901, + 2655, 2121, -1171, -2901, -3, 10, 1870, -807, -1786, 42, + -2901, -2901, -1304, -2901, -2901, -2901, -1729, -1170, -2901, 91, + -351, -452, -2434, -2171, -2318, -2901, -2901, -771, -2901, 676, + 1123, 1127, -2901, -1446, 95, -537, -2154, -2901, -2462, -2901, + -2901, -2901, -2901, -2901, -2901, -1256, -462, -2901, -407, -2901, + -2901, -2901, -2901, 668, -2901, 417, -2901, -2901, -2901, -2901, + -2901, -2901, -549, -582, -2901, -2901, -2901, 94, -2901, -2901, + -2901, 1444, -690, -575, 2098, -1169, -311, -2901, -2901, -2901, + -2901, -2028, -2901, -2901, -2901, -2901, -2901, -2901, -2901, -1235, + -2901, -2901, -2901, -2901, -2901, -2901, 1210, 2687, -418, -2901, + -2901, -2901, -2901, -2901, -2901, -2901, -2901, -2901, 1905, 130, + -2901, 26, -2901, -2901, 438, -1675, 33, -2901, -2901, -2901, + -2901, -464, 34, -2901, 749, -2901, -2901, -1452, -2901, 1912, + -2901, -2901, 4, 0, -45, 410, 544, -2901, -2901, -38, + 1012, -2901, -2901, -2901, -2901, 742, 1731, -2901, 732, -333, + -2901, -2901, 1743, -2901, -2901, 1732, 1206, -2901, 1231, 778, + -1692, 987, -1654, 493, -556, -163, 13, 2230, -2901, -2900, + 770, -2398, 168, 1356, 1064, -1191, -2901, -2901, -746, 4160, + -2901, -2901, -2901, 4236, 4515, -2901, -2901, 4674, 4760, -2901, + -728, 369, 4792, 3267, -866, -1364, 3783, 645, -1071, -1223, + -2901, -2901, -2901, -323, 397, 451, -2901, -1220, -2901, -155, + -2901, 6077, 782, -2901, -780, -2901, -806, -2901, -1296, -2901, + -2901, -2901, -2901, -2901, -2038, -2205, -44, 847, -2901, -2901, + 940, -2901, -2901, -2901, -623, -617, -1373, 855, -1390, -2901, + -626, 979, 1330, 153, -553, 2445, -382, 1958, -422, -1541, + -898, -625, -2901, -127, -2901, -1004, 434, -60, -8, 50, + 5215, -1181, 2701, -678, -667, -1183, -2901 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1643 +static const short int yytable[] = +{ + 142, 620, 681, 607, 141, 988, 1276, 1775, 819, 1079, + 1782, 467, 1728, 546, 1674, 491, 747, 1333, 1390, 546, + 995, 1303, 949, 654, 1160, 943, 136, 664, 1764, 1344, + 2286, 583, 552, 137, 139, 1161, 989, 1960, 936, 1041, + 1187, 2434, 1746, 2030, 584, 1703, 619, 2224, 1071, 1893, + 738, 1696, 784, 1823, 958, 1035, 611, 452, 460, 1704, + 1705, 2270, 2604, 452, 452, 1233, 1706, 1707, 1708, 452, + 2573, 452, 554, 1248, 556, 2246, 1268, 452, 564, 452, + 1164, 1163, 574, 580, 554, 63, 587, 775, 580, 580, + 2238, 2240, 609, 1226, 113, 665, 1530, 1229, 2741, 684, + 2843, 527, -1453, 1463, 1235, 599, -1517, 693, 1968, 1363, + 1364, 1249, -1515, 805, 803, -1545, -1563, 807, -1589, 1357, + 1358, 1247, 1965, 1416, 2017, 2019, 1022, 1407, 1379, 465, + 779, 2682, 1416, -1126, 787, -1121, 939, 1257, 2549, 2550, + 2551, 2552, 1376, 796, 1409, 1797, 2823, 1269, 1324, 2826, + 1678, 837, 2173, 1947, 2284, 1817, 1614, 2553, -1307, 2295, + 1536, 457, 1858, 1715, 1551, -1307, 1720, 1269, 2118, 667, + 1556, 1932, 501, 1416, 686, 688, 1536, 696, 1933, 1897, + -1562, 694, 1269, 1605, 1979, 1269, 1536, 1913, 2230, 1897, + 1537, -1323, 3110, 2445, 3155, 1725, 457, 2555, -1323, 1003, + 1537, 659, 661, 659, 2144, 666, 475, 683, 1547, 666, + 452, 1679, -1093, 452, 2586, 452, 659, 666, 1678, 2251, + 1725, 2253, 1938, 2893, 1076, 2895, 2106, 1328, 1298, 3028, + 1260, 1026, 1716, 3161, 1895, 1605, 2757, 696, 1416, 1936, + 1700, 1538, 2540, -291, 3209, 3196, 3130, 3123, 1509, 2231, + 3088, 2107, 2275, 1182, 1183, 1798, 1174, 1538, 477, 1079, + 2778, 3257, 3126, 1680, 697, 1030, 1681, 1538, 1557, 1971, + 2192, 1385, 1386, 3124, 2232, 2663, 1269, 1261, 1045, 1679, + 542, 2279, 462, 757, 2960, 1510, 1460, 543, 3127, 2233, + 2446, 542, 3, 4, 1032, 1450, 1004, 2234, 1461, 2683, + 1063, 3112, 1914, 653, 557, 1046, 1915, 653, 1701, 457, + 758, 1857, 1447, 1387, 457, 457, 1160, 1033, 1444, 1416, + 2235, 457, 3248, 681, 697, 3009, 1650, 1161, 1027, 557, + 2559, 1680, 1511, 2541, 1681, 2758, 1548, 1064, 3125, 1916, + 3186, 734, 1390, 1972, 2280, 1558, 3261, 2887, 759, 37, + 1579, 1451, 1240, 3128, 1682, 1077, 1830, 1831, 1262, 681, + 3156, 1937, 2560, 1980, 1843, 1539, 1163, 951, 1846, 1847, + 2277, 1726, 2561, 3162, -1562, 1674, 1455, 3158, 770, 3011, + 1270, 1539, -1643, 1868, 777, 1869, 1232, 1232, 1643, 1241, + 483, 1539, 484, 2236, 3258, 3122, 3017, 2129, 2145, 1649, + 1270, 2742, 2779, 1285, 1549, 1263, 1891, 502, 1892, 1825, + 45, 1615, 1078, 1717, 3047, 1270, 742, 3231, 1270, 1799, + 749, 2273, 1682, 1616, 2470, 1278, 817, 2447, 1962, 817, + 756, 557, 2276, 1005, 1322, 1800, 2130, -1562, 3272, 1352, + 1683, 557, 37, 1335, 557, 902, 2119, -1307, 2562, 1363, + 1364, 1540, 2448, -1562, 1917, 1345, 1721, 1379, 2915, 559, + 1934, 2888, 1325, 1420, 1421, 1357, 1358, 1540, 1898, 1684, + -1126, 1617, -1121, 1646, 1376, 2744, 2745, 1540, 2379, 503, + -1323, 504, 1264, 1065, 1329, 1006, 1561, 1733, 542, -1126, + 1028, -1121, 542, 2800, 3210, 543, 3056, 3087, 46, 543, + 1410, 1438, 1232, 45, 1437, 1672, 1620, -1453, 1683, 1270, + 1438, -1517, 1424, 611, 1300, 2359, 1746, -1515, 2822, 452, + -1545, -1563, 661, -1589, 659, 804, 666, 806, 683, 808, + 666, 751, 452, 809, 1329, 1242, 452, 2611, 659, 1668, + 666, 2615, 1434, 1435, 1436, 1437, 729, 452, 1496, 1278, + 2278, 1438, 2643, 2458, 1160, 46, 452, 1445, 568, 661, + 1066, 952, 452, 681, 683, 1161, 452, 452, 1820, 1821, + 2440, 452, 2441, 452, 2411, 452, 760, 1588, 659, 1829, + 763, 1167, 1832, 15, 1686, 3232, 2499, 2500, 1170, 2095, + 1844, 1845, -1093, 2405, 1362, -1093, 1833, 994, 557, -1093, + 2456, 500, 2140, 1862, 1864, 1432, 1433, 1434, 1435, 1436, + 1437, 3144, 1243, 2471, 1878, 3175, 1438, 2809, 452, 457, + 452, 653, 142, 829, 953, 3029, 141, 1635, 2839, 569, + 1290, 1731, 1654, 1989, 1858, 1858, 1258, 3030, 147, 1858, + 833, 1904, 580, 1905, 944, 580, 1848, 1849, 136, 3249, + 3233, 1541, 23, 457, 2472, 137, 139, 1834, 653, 938, + 2290, 962, 947, 1906, 653, 2164, 1778, 1291, 1953, 1735, + 1736, 3234, 148, 15, -1055, 1610, 2752, 3191, 1858, 1858, + 2161, 1547, 3098, 3172, 2810, 1729, 1432, 1433, 1434, 1435, + 1436, 1437, 1304, 1655, 1543, 625, 1606, 1438, 2351, 1656, + 2537, -1055, 2525, 2356, 2101, 15, 1544, 63, 457, 1835, + 2102, 14, 1836, 2165, 457, 557, 113, 15, 659, 659, + 1544, 2878, 2604, 1611, 1746, 457, 3176, 3220, 764, 2370, + 2525, 2371, 3021, 2006, 816, 2739, 1657, 1160, 588, 2457, + 555, 19, 23, 2811, 457, 452, 1457, 626, 1161, 560, + 2062, 2372, 2538, 2065, 2066, 1165, 3221, 1907, 1580, 2840, + 457, 452, 1908, 457, 1785, 1786, 2096, 1909, 683, 2602, + 452, 567, 2809, 3099, 23, 2753, 452, 457, 1887, 37, + 659, 3177, 3031, 1857, 1857, 1691, 23, 452, 1857, 2067, + 2879, 1698, 570, 571, 2166, 659, 659, 3263, 28, 3250, + 1837, 2103, 964, 142, 658, 1722, 662, 1311, 3173, 2772, + 2007, 659, 1165, 1292, 452, 817, 2837, 627, 142, 692, + 1278, 1763, 1327, 1622, 1163, 1200, 589, 1857, 1857, 1307, + 28, 659, 659, 43, 2771, 452, 1308, 1309, 1789, 463, + 45, 1350, 1232, 2539, 3024, 1458, 2167, 944, 1545, 2994, + 2373, 2754, 1754, 1160, 975, 2374, 606, 1580, 1366, 2318, + 457, 653, 620, 452, 1161, 1595, 452, 554, 653, 37, + 1812, 452, 2838, 1910, 475, 452, 3223, 3224, 37, 2997, + 3025, 1911, 1658, 1341, 681, 1278, 1838, 452, 1393, 1347, + 1293, 2917, 46, 2918, 1839, 1757, 1840, 731, 2811, 2773, + 1623, 37, 2774, 2068, 1766, 2069, 1510, 1405, 1596, 617, + 457, 457, 457, 37, 1772, 147, 653, 2880, 1851, 628, + 2886, 2910, 2168, 43, 2169, 2890, 477, 1416, 2892, 3262, + 45, 1780, 1417, 1783, 1784, 2998, 2569, 1787, 2104, 45, + 2162, 1232, 976, 982, 585, 1068, 2108, 1008, 811, 148, + 2553, 1278, 2404, 1511, 2883, 43, 2738, 2071, 2072, 1659, + 2640, 2375, 45, 2105, 2554, 2528, 812, 43, 457, 2376, + 2027, 2881, 3194, 3195, 45, 1009, 2642, 1501, 1501, 1597, + 1501, 615, 3264, 2805, 2249, 945, 1703, 983, 757, 457, + 2555, 46, 2556, 2528, 1696, 944, 2654, 1069, 2633, 822, + 1704, 1705, 944, 944, 471, 1453, 1746, 1706, 1707, 1708, + 1746, 1488, 1525, 1495, 46, 2571, 2665, 2919, 2666, 838, + 147, -964, 1598, 2643, 1599, 2806, 46, 941, 1010, 2182, + 2183, 2184, 2185, 2083, -964, 1600, 3105, 1526, 1469, 1459, + 1460, 557, 701, -1643, 2293, 542, 621, 702, 580, 2461, + 3247, 1419, 1461, 759, 148, 2873, 1011, 2247, 483, 2557, + 484, 2085, 2494, 2291, 1527, 2497, 2498, 580, 1601, 2292, + 2442, 1420, 1421, -964, 622, 1362, 1470, 475, 1531, 2508, + 1631, 2084, 2323, 2324, 2325, 2326, 2327, 2328, 2901, 683, + 2902, -964, 2345, 2329, -300, -631, 981, 1858, 3097, 1602, + 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, 2086, + 1858, 1991, 457, 659, 659, 659, 659, 1969, 2558, 1580, + 1424, 2368, 1040, 2559, 623, 3064, 33, 739, 681, 477, + 2242, 1603, 2667, -989, 1425, -964, 1385, 1386, 1748, 3188, + 1751, 755, 2668, -964, 740, 1278, 741, 992, 1755, 998, + 1012, 2534, 2536, 982, 631, 2560, 996, 1407, 1002, 1858, + 1858, 1352, 1623, 1385, 1386, 2561, 743, 1185, 744, 2399, + 2400, 2693, 993, 2231, 902, 1013, 1699, 2179, 1389, 33, + 2820, 997, 1042, 1014, 1639, 33, -1136, 664, 2535, 1015, + -989, 1072, -1126, 1640, 2023, 3219, 1016, 983, 2232, 3053, + 3222, 1160, 1017, 1232, 2260, 1387, 1160, 457, 998, 690, + 1018, -1126, 1161, 2617, 1043, 999, 1641, 1161, 1019, 2465, + 457, 2234, 659, 659, -1431, 681, 2467, 2468, 659, 3246, + 1665, 1605, 695, 1070, -989, 1955, 2328, 33, 1612, 1044, + 810, 2562, 2329, -1431, 2780, -964, 1857, 733, 3118, 1857, + 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1061, 1857, + 998, 483, 2781, 484, 1020, 1740, 2323, 2324, 2325, 2326, + 2327, 2328, 486, 3119, 999, 2162, 1637, 2329, 2803, 2804, + 620, 489, 2807, 1062, 2808, 705, 666, 1428, 452, 2443, + 659, 659, 659, 659, 1432, 1433, 1434, 1435, 1436, 1437, + -1432, 1638, 707, 2523, 944, 1438, 1165, 1779, 1857, 1857, + 971, 701, 1048, -1409, 2444, -1406, 702, 2236, 1049, -1432, + 2230, 1036, 1037, 737, 661, 619, 999, 452, 452, 1244, + 2511, 2523, 1030, 683, 142, 1858, 452, 452, 1811, 452, + 1814, 2934, 1887, 1408, 452, 579, 452, 736, 1245, 659, + 659, 605, 1813, 1413, -1409, 748, 1050, 1031, -1093, -1106, + 1808, 1032, 753, 452, 1449, 452, 452, 1809, 1810, 452, + 2512, 701, 158, -1409, 2438, 1794, 702, 1362, 1368, 2403, + 761, 2231, 1467, 1179, 1033, 1385, 1386, 1502, 1504, 1746, + 1508, 2513, 554, 554, 1746, 762, 1819, 1746, 1230, 1231, + 2417, 2418, 1051, -1133, 557, 557, 2232, 2707, -1136, 1052, + 2514, 1497, 1053, 557, 1255, 1498, 1374, 1375, 1747, 1902, + 653, 2233, -1133, 1412, 1448, 2515, 772, 1389, 653, 2234, + 683, 1349, 1956, 46, 1280, 1282, 2790, 2205, 2206, 2516, + -964, 457, 2794, 2795, 2796, 2797, 2798, 2799, 457, 170, + 2748, 785, 2235, -964, 464, 1362, 2385, 1777, 1531, 1054, + 1805, 1778, 529, 2624, 1806, 792, 1608, 653, 1987, 1613, + 457, 457, 1990, 1621, 3116, 2684, 2685, 1983, 2651, 586, + 1362, 1806, 457, 994, 1857, 2014, 2001, 1858, 1858, 2015, + 2141, -963, -964, 2008, 2142, 1338, 1339, 1160, 2325, 2326, + 2327, 2328, 2149, 797, -963, 2174, 2150, 2329, 1161, 2175, + -964, 2933, 1055, 2421, 2422, 2022, 2271, 2024, 2517, 810, + 2272, 1503, 1503, 2587, 1503, 2236, 2518, 801, 2815, 2034, + 2289, 2058, 2299, 2302, 1778, 814, 1778, 1778, 2306, 1495, + 815, 2307, 1778, -963, 2824, 1778, 1030, 2333, 2350, 452, + 823, 1778, 1778, 2353, -964, 2519, 2402, 2354, 825, 2318, + 1778, -963, -964, 2407, 830, 2099, 2412, 2408, 2690, 2576, + 1278, 2714, 2112, 2577, 2114, 1032, 2584, 2655, 666, 452, + 2585, 1778, 666, 661, 2691, 2698, 831, 452, 2692, 2699, + 3084, 2710, 832, 452, 2420, 1778, 666, 457, 2097, 452, + 833, 3012, 2733, 666, 452, -963, 1778, 2734, 834, 452, + 2746, 1778, 1748, -963, 2142, 836, 2850, 2897, 1301, 1163, + 2851, 1778, 2319, 1385, 1386, 666, 452, 666, 452, 1362, + 452, 2939, 1531, 2029, 2029, 1806, 1857, 1857, 978, 666, + 980, 666, 452, 452, 452, 2600, 2423, 2424, 2318, 457, + 1887, 3044, 2708, 2453, 2864, 2865, 2866, 2074, 2075, 452, + 452, 452, 452, 2082, -964, 835, 452, 452, 1746, 2460, + 452, 452, 452, 2463, 1160, 666, 452, 2958, 2616, 2414, + 2619, 2142, 666, 452, 666, 1161, 452, 2959, 2389, 3050, + 2390, 2142, 2162, 1278, 620, 840, 1858, 3055, 659, 3106, + 2391, 2577, 2392, 2180, 839, 659, 659, 659, 659, 659, + 659, 2319, 954, 1079, 950, -963, 1627, 1628, 1629, 1630, + 1858, 1858, 948, 3057, 142, 3070, 3072, 2577, 2193, 3071, + 1778, 2986, 2987, 2988, 3078, 955, 1887, 3139, 1806, 2223, + 3146, 3140, 3148, 2029, 1278, 956, 2577, 3281, 2964, 2965, + 3282, 554, 3152, 2968, 2969, 3187, 1806, 3189, 964, 1329, + 3197, 3140, 3198, 681, 1278, 3199, 1806, 971, 963, 2354, + -956, 2191, 457, 965, 2940, 901, 2204, 1486, 2320, 2321, + 2322, 979, 2323, 2324, 2325, 2326, 2327, 2328, 3200, 971, + 2228, 972, 1778, 2329, 2228, 2241, 3203, 3205, 3206, 3259, + 1806, 1806, 1806, 3260, 2318, 3166, 990, 3168, 994, 659, + 2029, 659, 2029, 1048, 2816, 2817, 1039, 3044, 2415, 1049, + 1748, 1024, 1067, 944, 3286, 1651, 1652, 2344, 3260, 2346, + 2347, 1661, 670, 1073, 1038, 671, 672, 673, 666, 674, + 675, 676, 677, 678, 679, 1857, 1858, 1075, 1883, 1168, + 457, 1886, 1171, 1176, 1178, 1180, 620, 1050, 1186, 1189, + 999, 1227, 452, 1232, 901, 1236, 666, 2319, -143, 1857, + 1857, 2323, 2324, 2325, 2326, 2327, 2328, 1238, 457, 1254, + 1265, 1267, 2329, 1272, 1273, 457, 1274, 1275, 1277, 1283, + 1278, 1284, 1747, 1711, 1712, 1713, 1714, 1286, 1287, 1288, + 1957, 1405, 2650, 1051, 2394, 2395, 3204, 2938, 1289, 1294, + 1052, 1295, 2924, 1053, 1296, 1902, 3202, 3044, 1299, 1334, + 1336, 2877, 1340, -1097, 2426, 3102, 2318, 1348, 1342, 1343, + -1104, 1356, 1359, 1360, 2213, 2388, 1361, 1365, 46, -1094, + 2361, 1367, -1095, 1370, 1371, 1372, 1373, 1740, 1378, 1442, + 1380, 1381, 1008, 1776, 2870, 1382, 1383, -1098, -1096, 1384, + 1054, 1456, 1391, 1392, 2213, 451, 1394, 1395, 683, 1329, + 1396, 498, 499, 1397, 1398, 1472, 1485, 530, 1399, 545, + 1009, 1400, 1008, 1499, 981, 563, 1521, 566, 1528, 2319, + 1529, 1531, 1532, 2415, 1552, 1857, 1533, 1546, 1550, 1553, + 1554, 1575, 1555, 1576, 1582, 1577, 1583, 1578, 944, 1589, + 1009, 1594, 1495, 1055, 1584, 1591, 1592, 1593, 1605, 1609, + 901, 2415, 1619, 2320, 2321, 2322, 452, 2323, 2324, 2325, + 2326, 2327, 2328, 1010, 666, 452, 452, 1624, 2329, 1625, + 1626, 1632, 1633, 1634, 1636, 1648, 1653, 1030, 1665, 1660, + 1662, 1673, 1666, 1352, 1362, 1368, 2491, 2941, 1675, 1688, + 1676, 1011, 473, 1010, 1693, 1710, 1697, 1724, 1730, 1734, + 1732, 1738, 1056, 1759, 2766, 2767, 1032, 1760, 1749, 1761, + 1762, 1788, 1773, 1791, 1795, 452, 1803, 1752, 2132, 2214, + 1816, 1011, 1211, 1825, 457, 1756, 2132, 1824, 1866, 1057, + 1747, 452, 1748, 902, 1765, 452, 1748, 1867, 1879, 1884, + 1890, 2955, 1438, 1896, 3068, 1947, 1889, 1774, 685, 2214, + 659, 689, 626, 691, 1901, 1918, 1954, 1959, 1958, 1920, + 1964, 1975, 1970, 452, 452, 452, 452, 664, 1976, 1984, + 1982, 1985, 901, 1981, 2181, 2320, 2321, 2322, 1986, 2323, + 2324, 2325, 2326, 2327, 2328, 1992, 2989, 2000, 1996, 1994, + 2329, 1997, 1998, 2003, 2210, 2005, 666, 452, 2010, 2012, + 2063, 3082, 2070, 2031, 2116, 2032, 2109, 2029, 2029, 2117, + 2033, 2110, 2111, 2120, 33, 2122, 2123, 2125, 2215, 2126, + 2127, 2128, 1665, 2139, 1015, 2143, 2148, 2152, 2157, 2155, + 2158, 1016, 2159, 2160, 2156, 2641, 2172, 998, 142, 2318, + 2176, 2186, 2591, 2187, 33, 1018, 2208, 2209, 1014, 2188, + 2211, 2220, 142, 1019, 1015, 2221, 2607, 2653, 2222, 1740, + 2229, 1016, 2243, 1740, 2248, 2254, 2256, 998, 2255, 2258, + 2263, 2264, 452, 2269, 1817, 1018, 2287, 2285, 2281, 817, + 2300, 2304, 2301, 1019, 2303, 2305, 2339, 2308, 2309, 452, + 2340, 3151, 2369, 2311, 944, 2314, 2332, 2364, 1778, 1020, + 2377, 142, 2319, 2228, 2338, 2646, 2609, 2384, 2956, 2397, + 2429, 2341, 2342, 3159, 2436, 2349, 2362, 3164, 3165, 2622, + 2363, 3154, 2387, 2437, 2401, 2432, 2433, 2450, 2454, 1020, + 2501, 2124, 2455, 2603, 2462, 2480, 2481, 2464, 2133, 2134, + 2135, 2136, 2137, 2138, 2482, 666, 2483, 2484, 2485, 3160, + 2486, 2487, 1794, 2488, 2489, 2490, 2496, 2502, 2503, 2504, + 2505, 2506, 2507, 2529, 452, 2532, 2533, 666, 2542, 457, + 2543, 2544, 620, 2545, 2566, 2570, 2583, 2546, 457, 2547, + 2580, 2724, 2725, 2726, 2727, 2588, 2582, 2594, 2589, 2596, + 2606, 2612, 2620, 2613, 457, 2608, 2625, 2629, 2645, 2610, + 2623, 2631, 1416, 2648, 2649, 1349, 1445, 1417, 2658, 2335, + 1573, 2329, 1747, 2334, 2687, 2688, 1747, 1405, 2689, 2700, + 1409, 2712, 2713, 2731, 1587, 2980, 2981, 2747, 2983, 2721, + 2737, 2749, 2777, 2736, 2740, 2791, 2750, 2751, 2792, 457, + 2761, 457, 2250, 2762, 2252, 2763, 457, 653, 2793, 2841, + 2603, 2789, 2818, 2845, 2782, 901, 2784, 735, 2320, 2321, + 2322, 2819, 2323, 2324, 2325, 2326, 2327, 2328, 457, 2847, + 752, 2849, 2856, 2329, 754, 2834, 2764, 2861, 2868, 2862, + 2891, 2875, 2906, 458, 2874, 766, 3253, 2900, 1495, 2903, + 2884, 2908, 2911, 2894, 771, 2907, 2916, 2913, 2921, 2920, + 2925, 2927, 2951, 2952, 3129, 789, 2926, 2931, 2961, 791, + 2967, 794, 1665, 1665, 2459, 1748, 2974, 2975, 2984, 2978, + 1748, 2985, 1418, 1748, 2990, 2970, 1419, 2993, 2999, 2315, + 2316, 3003, 3049, 3091, 2331, 2810, 452, 452, 3004, 3002, + 3005, 3013, 3049, 2317, 3015, 3018, 1420, 1421, 3020, 3023, + 3027, 3033, 3034, 3035, 1647, 3037, 826, 3039, 827, 1422, + 452, 3048, 2192, 2318, 666, 452, 666, 452, 452, 452, + 452, 3040, 3062, 2365, 2366, 3066, 3074, 457, 457, 3052, + 3067, 3069, 3075, 3076, 3077, 3085, 2132, 3086, 3100, 2132, + 2132, 2318, 1423, 3101, 3107, 1424, 3093, 3113, 2840, 3094, + 3115, 3121, 3131, 2132, 3132, 2142, 3133, 3134, 3174, 1425, + 1185, 3182, 2527, 3178, 1690, 681, 3183, 2257, 3201, 1300, + 2259, 3207, 3208, 2213, 2261, 3211, 2319, 3213, 3217, 3225, + 452, 452, 452, 3218, 452, 3228, 687, 3230, 3209, 3255, + 2527, 1008, 1740, 3210, 3256, 3161, 3273, 1740, 3283, 2178, + 1740, 1484, 2575, 2406, 2319, 2098, 973, 2191, 2473, 1753, + 2074, 2510, 3103, 2074, 2854, 2860, 2073, 2288, 2770, 1009, + 1587, 2858, 3010, 2431, 1427, 2509, 2029, 2599, 3226, 3252, + 3214, 3212, 3236, 1074, 2638, 2859, 1723, 2976, 2228, 3036, + 452, 3285, 2163, 3274, 3001, 3000, 2568, 2567, 2530, 1169, + 3147, 2191, 3237, 2896, 3092, 452, 1692, 3254, 1175, 2029, + 3095, 2029, 562, 821, 1177, 2909, 2872, 1323, 3192, 3137, + 2962, 2439, 1010, 666, 2018, 1225, 2876, 2016, 457, 3171, + 3284, 2971, 3266, 2973, 957, 3117, 1966, 531, 1306, 2853, + 2647, 2409, 2413, 2425, 457, 1310, 1519, 1978, 1522, 3170, + 1011, 1963, 1259, 2466, 457, 2396, 2225, 1517, 2618, 3054, + 768, 2704, 1428, 2410, 2957, 1429, 1430, 1431, 2153, 1432, + 1433, 1434, 1435, 1436, 1437, 2852, 3153, 1748, 2214, 901, + 1438, 2694, 2320, 2321, 2322, 2416, 2323, 2324, 2325, 2326, + 2327, 2328, 2382, 1008, 1748, 1747, 2296, 2329, 2380, 0, + 1747, 1312, 0, 1747, 2274, 1946, 0, 901, 0, 1331, + 2320, 2321, 2322, 0, 2323, 2324, 2325, 2326, 2327, 2328, + 683, 1009, 0, 0, 1930, 2329, 0, 2705, 0, 0, + 666, 452, 0, 0, 0, 0, 0, 0, 0, 0, + 681, 666, 452, 666, 3007, 0, 0, 0, 2435, 0, + 0, 0, 0, 0, 2977, 0, 0, 452, 452, 659, + 452, 0, 0, 0, 0, 0, 2735, 3090, 0, 0, + 0, 0, 0, 33, 1010, 142, 0, 1014, 0, 3016, + 0, 656, 0, 1015, 0, 656, 1665, 0, 0, 0, + 1016, 0, 0, 0, 0, 0, 998, 0, 0, 0, + 0, 0, 1011, 0, 1018, 0, 664, 457, 457, 457, + 457, 0, 1019, 0, 0, 0, 0, 0, 0, 2765, + 0, 1740, 0, 0, 0, 0, 2768, 0, 2769, 0, + 2474, 2475, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 732, 452, 1748, 0, 0, 0, 0, 452, 0, + 0, 0, 0, 0, 3045, 0, 1573, 1573, 1020, 0, + 2132, 0, 0, 0, 452, 0, 2132, 2132, 2132, 2132, + 2132, 2132, 0, 0, 2896, 0, 0, 0, 0, 0, + 0, 2318, 0, 0, 0, 0, 0, 2860, 0, 0, + 0, 666, 2664, 0, 0, 2669, 2670, 2671, 2672, 2673, + 2674, 2675, 2676, 2677, 0, 2679, 0, 0, 0, 0, + -1640, 0, 2825, 2827, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3185, 33, 0, 1560, 0, 1014, + 818, 0, 0, 0, 0, 1015, 820, 0, 0, 1587, + 0, 0, 1016, 1748, 2319, 683, 0, 828, 998, 0, + 0, 0, 0, 0, 2716, 2717, 1018, 653, 2871, 0, + 0, 2154, 0, 0, 1019, 0, 820, 0, 0, 0, + 0, 0, 0, 1665, 1747, 0, 0, -1640, 0, 0, + 0, 0, 820, 0, 0, 960, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2029, 2626, 2074, 2628, 974, + 2630, 0, 2632, 0, 2634, 0, 3227, 0, 0, 2637, + 1020, 0, 0, 0, 0, 0, 0, 0, 0, 659, + 3045, 0, 0, -1640, 659, 659, 0, 0, 0, 0, + 0, 0, 452, 0, 0, 2652, -1640, 0, 0, 0, + 0, -1640, 0, 0, 0, -1640, 0, 653, -1640, 0, + -1640, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -1640, 3280, 659, 659, 659, + 659, 452, 1166, 0, 0, 0, 653, 0, 457, 0, + 0, 0, 2282, -1640, 0, 0, 0, 901, 0, 656, + 2954, -1643, -1643, 0, 2323, 2324, 2325, 2326, 2327, 2328, + 457, 0, 0, 0, 0, 2329, 0, 0, 0, 0, + 3045, 659, 0, 653, 0, 0, 1709, 0, 0, 0, + 2836, 457, 1250, 1252, 1253, 0, 656, -1640, 0, 0, + 0, 0, 656, 0, 0, -1640, 0, 0, 0, 3279, + 0, 0, 0, 0, 0, 2132, 2132, 2132, 0, 0, + 0, 0, 452, 659, 0, 0, 1758, 2991, 2992, 457, + 659, 2995, 2996, 0, 0, 1767, 0, 1769, 0, 0, + 0, 142, 1770, -1640, 0, 0, 0, 659, 0, 0, + 820, 0, 0, 0, 3278, 0, 0, 0, 3245, 0, + 0, 0, 0, 0, 653, 0, 0, 0, 0, 0, + 0, 820, 142, 0, 0, 3022, 0, 0, 0, 0, + 0, 656, 0, 653, 0, 0, 560, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3046, + 3245, 0, 0, 0, 0, 0, 0, -1640, 656, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3245, 0, 0, 0, -1640, 0, 0, + 0, 0, 0, 0, 708, 0, 0, 0, 0, 0, + 0, 0, 2935, 2936, 0, 0, 653, -1640, -1640, -1640, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1573, 1573, 0, 1573, 0, 709, 0, 0, -1640, + 0, 0, -1640, 0, -1640, -1640, 0, 2449, 710, 2452, + 0, 0, 0, 0, 0, 711, 0, 0, 712, 0, + 0, 0, 656, 1159, 1487, 0, 0, 0, 0, 656, + 0, 0, 0, 0, 0, 713, 656, 0, 0, 2132, + 0, 0, 0, 0, 3104, 0, 653, 0, 0, 0, + 2469, 0, 2982, 0, 0, 0, 714, 1224, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2904, 2905, 0, 0, 0, 0, + 0, 0, 0, 0, 656, 0, 0, 715, 0, 0, + 0, 3135, 0, 0, 0, 0, 0, 0, 0, 2495, + 0, 0, 0, 0, 0, 0, 716, 1988, 0, 0, + 0, 0, 0, 0, 0, 1995, -1642, 0, 0, 1618, + 0, 1999, 656, 0, 1573, 0, 0, 2004, 0, 0, + 717, 0, 2009, 0, 0, 0, 0, 2011, 0, 0, + 0, 0, 0, 0, 1224, 0, 0, 0, 0, 0, + 0, 0, 1573, 0, 0, 0, 2025, 0, 2026, 0, + 0, 0, 0, 0, 0, 0, 656, 2578, 0, 0, + 2059, 2060, 2061, 0, 0, 0, 0, 0, 0, 0, + 2469, 3065, 0, -1642, 0, 0, 718, 2076, 2077, 2080, + 2081, 1573, 656, 0, 2087, 2090, 0, 0, 2092, 2093, + 2094, 0, 0, 0, 2100, 3079, 3080, 0, 0, 158, + 0, 2113, 0, 0, 2115, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2627, 656, 656, 0, 656, -1642, + 1587, 719, 0, 0, 0, 720, 0, 721, 0, 0, + 0, 0, -1642, 722, 0, 656, 0, -1642, 0, 0, + 0, -1642, 0, 1414, -1642, 0, -1642, 0, 0, 0, + 0, 1416, 0, 0, 0, 0, 1417, 0, 0, 0, + 723, 724, 3244, 0, 2659, 725, 0, 0, 0, 0, + 0, -1642, 0, 726, 0, 0, 0, 0, 727, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -1642, + 656, 0, 0, 656, 656, 2678, 0, 0, 728, 0, + 0, 1224, 3136, 0, 3244, 1159, 0, 3142, 3142, 2686, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3150, 0, 0, 0, 0, 0, 3244, 0, 3058, + 3059, 3060, 3061, -1642, 0, 1224, 0, 0, 0, 3063, + 0, -1642, 0, 1768, 0, 0, 0, 0, 0, 1224, + 1771, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3167, 0, 3169, 0, 0, 0, 0, 0, 0, + 0, 1418, 820, 820, 0, 1419, 0, 0, 0, -1642, + 2283, 0, 0, 0, 1802, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1420, 1421, 0, 0, 0, + 0, 0, 0, 0, 3193, 0, 0, 0, 1422, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 560, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2775, 0, + 0, 1423, 0, -1642, 1424, 0, 3216, 0, 0, 0, + 0, 0, 0, 3142, 0, 0, 0, 0, 1425, 0, + 1426, 0, 0, -1642, 0, 0, 0, 0, 0, 0, + 3229, 0, 0, 0, 0, 0, 0, 0, 0, 1224, + 0, 0, 0, -1642, -1642, -1642, 0, 0, 0, 0, + 0, 0, 0, 3149, 0, 0, 0, 1224, 0, 1945, + 0, 0, 0, 0, 0, -1642, 0, 0, -1642, 0, + -1642, -1642, 0, 0, 0, 0, 1224, 0, 0, 0, + 0, 0, 0, 1427, 0, 0, 0, 0, 0, 0, + 0, 0, 2844, 0, 0, 0, 0, 0, 0, 1224, + 0, 0, 0, 1159, 0, 0, 0, 0, 0, 0, + 0, 1967, 0, 2427, 2428, 0, 1414, 0, 0, 0, + 0, 0, 0, 0, 1416, 0, 0, 0, 0, 1417, + 0, 0, 0, 0, 0, 0, 656, 0, 656, 0, + 0, 0, 0, 0, 1224, 0, 656, 0, 0, 0, + 0, 0, 0, 0, 0, 1224, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1428, 0, 1222, 1429, 1430, 1431, 0, 1432, 1433, + 1434, 1435, 1436, 1437, 0, 656, 1644, 0, 0, 1438, + 0, 0, 0, 1645, 0, 0, 1414, 0, 0, 0, + 0, 0, 0, 0, 1416, 0, 0, 0, 0, 1417, + 0, 2476, 2477, 2478, 2479, 0, 0, 0, 1414, 656, + 656, 0, 1971, 0, 0, 0, 1416, 656, 0, 0, + 656, 1417, 0, 656, 2091, 0, 0, 0, 0, 0, + 0, 656, 656, 0, 1418, 2492, 0, 0, 1419, 656, + 0, 0, 656, 656, 656, 656, 0, 0, 0, 0, + 1222, 0, 656, 656, 0, 656, 0, 656, 1420, 1421, + 656, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2966, 1422, 0, 0, 0, 656, 1159, 0, 0, 656, + 0, 0, 0, 656, 0, 0, 1972, 656, 0, 0, + 656, 656, 656, 656, 656, 656, 656, 656, 656, 1224, + 0, 656, 2177, 0, 1423, 0, 656, 1424, 0, 656, + 2579, 0, 0, 0, 1418, 0, 0, 0, 1419, 0, + 0, 1425, 0, 1426, 0, 0, 0, 2593, 0, 0, + 2194, 0, 0, 0, 0, 0, 1418, 2212, 1420, 1421, + 1419, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1422, 0, 0, 0, 0, 0, 0, 0, 656, + 1420, 1421, 0, 0, 0, 0, 0, 0, 0, 0, + 150, 0, 0, 1422, 0, 1466, 0, 0, 0, 0, + 0, 0, 0, 0, 1423, 0, 1427, 1424, 0, 0, + 0, 0, 1159, 0, 0, 0, 0, 0, 0, 0, + 0, 1425, 0, 1426, 0, 0, 1423, 0, 656, 1424, + 0, 0, 2578, 0, 0, 0, 0, 1222, 0, 0, + 0, 0, 0, 1425, 151, 1426, 0, 1224, 0, 0, + 0, 1224, 1224, 0, 0, 0, 0, 0, 0, 0, + 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1222, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 153, 0, 0, 1222, 1427, 0, 0, 0, + 0, 0, 0, 0, 1428, 0, 0, 1429, 1430, 1431, + 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, 1427, 0, + 0, 0, 1438, 154, 0, 2310, 0, 0, 155, 0, + 0, 0, 0, 0, 0, 0, 656, 0, 0, 0, + 0, 0, 156, 0, 1224, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 920, 656, 1973, 1224, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2393, 0, 0, 0, + 0, 0, 0, 0, 1428, 0, 0, 1429, 1430, 1431, + 968, 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, 0, + 0, 0, 1438, 0, 0, 2357, 1428, 0, 0, 1429, + 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, + 0, 0, 157, 0, 1438, 1222, 0, 0, 2776, 0, + 656, 0, 0, 2783, 0, 2785, 2786, 2787, 2788, 0, + 656, 0, 0, 1222, 0, 158, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1222, 0, 0, 0, 0, 159, 0, 656, + 0, 0, 0, 160, 1080, 0, 0, 0, 0, 161, + 468, 0, 1416, 0, 0, 1222, 656, 1417, 0, 0, + 0, 0, 469, 0, 0, 0, 0, 1224, 2829, 2831, + 2833, 0, 2835, 0, 0, 0, 162, 163, 1587, 0, + 0, 164, 470, 0, 0, 656, 656, 0, 0, 165, + 0, 0, 0, 0, 166, 0, 0, 0, 0, 0, + 1222, 471, 0, 167, -501, 0, 0, 0, 0, 0, + 0, 1222, 0, 0, 168, 656, 656, 0, 0, 0, + 656, 472, 0, 0, 0, 0, 0, 473, 0, 0, + 0, 0, 656, 656, 656, 656, 0, 0, 0, 0, + 1159, 0, 474, 2899, 656, 1159, 0, 656, 0, 0, + 656, 0, 0, 0, 0, 0, 0, 0, 0, 656, + 656, 0, 656, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1418, -651, 475, 656, 1419, 656, 476, 0, + 0, 656, 0, 0, 0, 0, 0, 0, 1354, 0, + 0, 2572, -631, 0, 0, 0, 1420, 1421, 656, 0, + 2581, 0, 0, 0, 0, 0, 0, 0, 656, 1422, + 656, 656, 0, 0, 1377, -407, 2595, 0, 0, 0, + 0, 0, 0, 0, 0, 656, 477, 0, 0, 0, + 0, 656, 0, 0, 0, 0, 0, 0, 0, 0, + 656, 656, 656, 0, 0, 1424, 0, 1402, 1403, 0, + 1406, 0, 0, 0, 0, 656, 0, 0, 0, 1425, + 0, 2635, 0, 2636, 0, 1222, 0, 1443, 2639, 2963, + 0, 0, 478, 0, 479, 0, 1224, 1224, 0, 1224, + 2972, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 820, 0, 1224, 0, 1224, -407, 0, 1414, 0, 0, + 0, 0, 0, 0, 0, 1416, 0, 0, 0, 0, + 1417, 0, 0, 0, 0, 0, 0, 480, 0, 0, + 0, -651, 1507, 481, 1427, 1514, 1516, 0, 0, 0, + 0, 0, 0, 0, 0, 1224, 1414, 0, 0, 0, + 0, 0, 0, 0, 1416, 0, 0, 0, 0, 1417, + 0, 0, 0, 0, 0, 0, 0, 482, 483, 0, + 484, 485, 0, 0, 0, 0, 0, 0, 0, 486, + 0, 0, 0, 487, 488, 0, 0, 0, 489, 0, + 3032, 0, 0, 490, 1224, 0, 2593, 0, 0, 0, + 0, 0, 0, 1222, 0, 0, 0, 1222, 1222, 2728, + 2729, 0, 0, 0, 0, 0, 2334, 0, 0, 1224, + 0, 2335, 1428, 0, 0, 1429, 1430, 1431, 0, 1432, + 1433, 1434, 1435, 1436, 1437, 1418, 0, 0, 0, 1419, + 1438, 0, 0, 0, 0, 0, 1159, 1224, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1420, + 1421, 0, 1224, 0, 0, 0, 1214, 0, 0, 0, + 0, 0, 1422, 0, 1418, 1224, 0, 0, 1419, 0, + 0, 0, 0, 0, 0, 0, 1224, 0, 0, 0, + 1222, 0, 0, 0, 0, 0, 0, 0, 1420, 1421, + 656, 0, 0, 0, 656, 1423, 0, 0, 1424, 0, + 0, 1422, 1222, 0, 656, 0, 0, 0, 0, 1224, + 0, 0, 1425, 0, 1426, 1224, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 656, 0, 0, 0, 0, + 0, 0, 1216, 0, 1423, 0, 0, 1424, 0, 0, + 0, 0, 0, 1214, 0, 0, 0, 0, 0, 0, + 2821, 1425, 0, 1426, 0, 0, 656, 0, 0, 1224, + 0, 0, 0, 0, 0, 656, 2842, 0, 2695, 0, + 0, 656, 0, 656, 0, 0, 2846, 1427, 656, 0, + 0, 656, 656, 656, 656, 656, 656, 656, 656, 656, + 1224, 656, 0, 0, 0, 656, 656, 0, 0, 0, + 0, 0, 0, 0, 1224, 0, 0, 0, 0, 656, + 0, 0, 0, 1159, 0, 656, 1427, 0, 0, 1216, + 0, 0, 0, 0, 0, 656, 0, 0, 656, 2696, + 656, 0, 0, 1222, 0, 0, 0, 0, 1224, 656, + 656, 656, 0, 0, 0, 656, 0, 0, 656, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 656, 0, + 0, 0, 0, 0, 0, 1428, 0, 0, 1429, 1430, + 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, + 0, 0, 0, 1438, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1828, + 3215, 0, 0, 0, 1428, 0, 0, 1429, 1430, 1431, + 1214, 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, 0, + 0, 1850, 1438, 0, 1852, 0, 0, 1863, 0, 2947, + 2948, 2949, 2950, 1224, 1870, 1875, 0, 0, 0, 1880, + 0, 0, 1885, 0, 1214, 0, 0, 0, 1416, 0, + 0, 0, 0, 1417, 0, 0, 0, 1894, 1214, 0, + 0, 1900, 0, 0, 0, 1912, 0, 0, 0, 1919, + 0, 0, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, + 1929, 0, 0, 1931, 0, 0, 1216, 0, 920, 0, + 0, 0, 0, 0, 2035, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1217, 0, 0, 0, 0, 656, 0, 0, 0, + 1216, 0, 0, 0, 0, 0, 0, 1224, 0, 0, + 0, 0, 0, 0, 1216, 2367, 0, 0, 0, 0, + 0, 968, 1222, 1222, 0, 1222, 2036, 0, 0, 0, + 0, 0, 0, 0, 2037, 2038, 2039, 0, 1222, 0, + 1222, 0, 0, 0, 0, 0, 0, 0, -1643, 0, + 0, 0, 1419, 656, 0, 0, 0, 0, 656, 0, + 0, 656, 0, 0, 0, 0, 0, 0, 1214, 0, + 2002, 0, 1420, 1421, 0, 2040, 0, 0, 1217, 0, + 0, 1222, 0, 0, 0, -1643, 1214, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 656, 0, 0, + 0, 0, 0, 0, 0, 1214, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2041, 0, 0, 0, 0, + 2042, 1424, 0, 0, 0, 0, 0, 0, 1214, 0, + 1222, 0, 0, 656, 0, 1425, 0, 0, 0, 0, + 656, 656, 0, 1224, 1216, 0, 0, 0, 656, 656, + 1219, 0, 0, 656, 1224, 1222, 0, 2043, 0, 656, + 656, 0, 1216, 656, 0, 0, 0, 0, 2121, 0, + 0, 0, 0, 1214, 2044, 2045, 2046, 2047, 2048, 0, + 2049, 1216, 0, 1222, 1214, 0, 0, 0, 0, 0, + 3109, 0, 0, 0, 0, 1224, 2151, 0, 1222, 0, + -1643, 0, 0, 0, 1216, 0, 0, 0, 0, 0, + 2050, 1222, 820, 0, 0, 1414, 0, 0, 1415, 0, + 0, 0, 1222, 1416, 0, 0, 0, 0, 1417, 0, + 0, 0, 0, 3145, 0, 0, 1220, 1219, 0, 0, + 0, 0, 1416, 2051, 0, 1217, 0, 1417, 0, 1216, + 0, 0, 0, 0, 0, 1222, 0, 0, 0, 0, + 1216, 1222, 0, 0, 0, 0, 0, 0, 1221, 0, + 0, 3157, 2245, 0, 0, 656, 0, 0, 2052, 1217, + 2053, 0, 0, 0, 0, 0, 0, 0, 1428, 0, + 0, 0, 0, 1217, 0, 1432, 1433, 1434, 1435, 1436, + 1437, 2262, 2054, 0, 0, 1222, 1438, 0, 0, 2055, + 0, 0, 2056, 0, 0, 656, 0, 0, 920, 0, + 0, 0, 0, 1220, 0, 0, 0, 0, 656, 0, + 0, 0, 656, 0, 0, 0, 1222, 1224, 1214, 0, + 0, 0, 0, 1418, 0, 0, 0, 1419, 2294, 0, + 1222, 0, 0, 0, 0, 1221, 0, 656, 0, 0, + 0, 1224, 1418, 0, 0, 0, 1419, 1420, 1421, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1422, 656, 656, 0, 1222, 656, 1420, 1421, 0, 0, + 0, 0, 656, 656, 1875, 0, 1875, 1875, 0, 1422, + 0, 0, 0, 0, 1219, 656, 2355, 0, 0, 2358, + 0, 0, 2360, 1423, 1216, 0, 1424, 0, 0, 656, + 0, 0, 0, 1217, 0, 0, 0, 0, 0, 0, + 1425, 0, 1426, 0, 0, 1424, 0, 2381, 1219, 2383, + 0, 1217, 0, 2386, 656, 0, 0, 0, 0, 1425, + 0, 0, 1219, 0, 0, 0, 0, 0, 0, 0, + 1217, 0, 0, 0, 0, 0, 1214, 0, 0, 0, + 1214, 1214, 0, 0, 0, 0, 0, 0, 0, 1222, + 0, 656, 656, 1217, 0, 0, 0, 968, 0, 0, + 1220, 0, 0, 1507, 0, 1427, 0, 0, 0, 0, + 0, 0, 1516, 1516, 1514, 0, 0, 656, 1224, 0, + 656, 0, 656, 0, 1427, 0, 0, 2430, 0, 0, + 0, 0, 1221, 0, 1220, 0, 0, 0, 1217, 0, + 1224, 0, 0, 0, 1224, 1224, 0, 0, 1220, 1217, + 0, 0, 1216, 0, 0, 0, 1216, 1216, 0, 0, + 0, 0, 0, 1214, 0, 0, 1221, 0, 0, 0, + 0, 0, 656, 0, 0, 0, 0, 0, 0, 0, + 1221, 0, 0, 1222, 0, 1214, 0, 0, 0, 0, + 0, 656, 1219, 1428, 0, 0, 1429, 1430, 1431, 0, + 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, 0, 0, + 1219, 1438, 1428, 1224, 0, 0, -1643, -1643, 0, 1432, + 1433, 1434, 1435, 1436, 1437, 0, 0, 0, 0, 1219, + 1438, 0, 0, 0, 0, 0, 0, 0, 0, 1216, + 1416, 0, 0, 0, 0, 1417, 0, 0, 0, 0, + 0, 0, 1219, 0, 656, 0, 0, 0, 0, 0, + 0, 1216, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1220, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 1220, 1219, 0, 0, + 0, 1223, 2, 1217, 3, 4, 0, 0, 1219, 0, + 1221, 0, 0, 0, 0, 1220, 1214, 0, 5, 1222, + 0, 0, 0, 0, 656, 0, 0, 2378, 1221, 0, + 1222, 0, 0, 0, 0, 0, 0, 6, 1220, 7, + 8, 0, 0, 0, 9, 10, 0, 1221, 0, 0, + 0, 0, 0, 0, 11, 0, 12, 0, 0, 0, + -1643, 0, 0, 0, 1419, 0, 0, 0, 0, 0, + 1221, 1222, 13, 0, 0, 14, 0, 0, 0, 0, + 0, 15, 0, 1220, 1420, 1421, 0, 16, 1223, 0, + 0, 0, 1216, 17, 1220, 0, 0, -1643, 0, 18, + 0, 0, 0, 0, 0, 19, 0, 20, 0, 0, + 0, 0, 21, 0, 0, 1221, 0, 0, 0, 0, + 0, 0, 0, 0, 22, 0, 1221, 0, 2657, 0, + 0, 1217, 0, 1424, 0, 1217, 1217, 2660, 0, 0, + 0, 0, 0, 2661, 0, 2662, 0, 1425, 0, 0, + 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1219, 0, 0, 0, 0, 2680, 2681, 0, + 0, 0, 0, 24, 25, 0, 0, 0, 0, 26, + 0, 0, 0, 0, 0, 0, 0, 1880, 27, 0, + 0, 0, 0, 0, 0, 0, 0, 2706, 0, 0, + 2709, 0, 2711, 0, 0, 0, 28, 0, 0, 0, + 0, 2715, -1643, 1222, 0, 0, 0, 2720, 1217, 0, + 2723, 0, 0, 0, 0, 1214, 1214, 0, 1214, 0, + 2730, 0, 0, 0, 0, 0, 0, 1222, 0, 29, + 1217, 1214, 0, 1214, 0, 0, 0, 0, 1220, 30, + 0, 0, 31, 0, 32, 1223, 0, 0, 0, 33, + 0, 0, 0, 0, 34, 0, 0, 35, 0, 0, + 0, 36, 0, 0, 1416, 0, 0, 37, 0, 1417, + 1221, 0, 38, 0, 1214, 39, 0, 0, 0, 1574, + 1219, 0, 40, 0, 1219, 1219, 0, 0, 0, 0, + 1428, 1216, 1216, 1223, 1216, 0, 0, 1432, 1433, 1434, + 1435, 1436, 1437, 0, 0, 0, 0, 1216, 1438, 1216, + 0, 41, 0, 0, 0, 0, 0, 0, 0, 42, + 0, 43, 0, 1214, 44, 0, 0, 0, 45, 0, + 0, 0, 0, 0, 0, 0, 1414, 0, 0, 0, + 0, 0, 0, 0, 1416, 0, 0, 0, 1214, 1417, + 1216, 2718, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1217, 0, 0, 0, 0, 1220, 1219, 0, 0, + 1220, 1220, 0, 0, 1222, 0, 1214, 0, 0, 0, + 46, 0, 0, 0, -1643, 0, 0, 0, 1419, 1219, + 0, 1214, 0, 0, 0, 0, 1222, 0, 1221, 1216, + 1222, 1222, 1221, 1221, 1214, 0, 0, 0, 1420, 1421, + 0, 0, 0, 0, 0, 1214, 0, 0, 0, 0, + 0, -1643, 0, 1223, 1216, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1223, 0, 0, 0, 0, 0, 0, 1214, 0, + 0, 0, 1216, 1220, 1214, 0, 0, 1424, 0, 0, + 1223, 0, 0, 0, 1418, 0, 0, 1216, 1419, 1222, + 0, 1425, 0, 0, 0, 1220, 0, 0, 0, 2912, + 1216, 0, 0, 1223, 0, 1221, 0, 0, 1420, 1421, + 0, 1216, 0, 0, 0, 0, 0, 0, 1214, 0, + 0, 1422, 0, 0, 0, 0, 0, 1221, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1219, 0, 2928, 2930, 1216, 0, 0, 0, 1223, 1214, + 1216, 0, 0, 0, 1423, 2937, -1643, 1424, 0, 1223, + 0, 2942, 2943, 1214, 0, 2945, 0, 0, 0, 0, + 0, 1425, 0, 1426, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1217, 1217, 0, 1217, 1216, 0, 0, 1214, 0, 0, + 0, 0, 0, 0, 0, 0, 1217, 0, 1217, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1216, 1220, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1427, 0, 0, 1216, + 0, 0, 0, 0, 1428, 0, 0, 0, 0, 1217, + 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, 1221, 0, + 0, 0, 1438, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1216, 0, 0, 0, 3008, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1214, 0, 0, 0, 0, 0, 1217, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1223, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1217, 1428, 0, 0, 1429, 1430, 1431, + 3051, 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, 0, + 0, 1888, 1438, 0, 0, 0, 0, 0, 0, 1219, + 1219, 1217, 1219, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1219, 1217, 1219, 1216, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1217, + 0, 0, 0, 0, 0, 0, 1214, 3081, 0, 1414, + 1217, 0, 2298, 0, 0, 3083, 0, 1416, 0, 0, + 0, 0, 1417, 0, 0, 0, 0, 0, 1219, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3096, 0, 1217, 0, 0, 0, 0, 0, 1217, + 0, 0, 0, 0, 0, 1220, 1220, 0, 1220, 0, + 0, 2013, 0, 0, 0, 1574, 2020, 0, 0, 0, + 0, 1220, 0, 1220, 0, 0, 0, 1219, 0, 0, + 0, 0, 1216, 0, 0, 0, 0, 1221, 1221, 0, + 1221, 0, 0, 1217, 0, 0, 0, 0, 0, 0, + 0, 0, 1219, 1221, 3138, 1221, 0, 0, 0, 0, + 0, 0, 0, 1414, 1220, 0, 0, 0, 0, 0, + 0, 1416, 0, 0, 1217, 0, 1417, 0, 0, 0, + 1219, 0, 1880, 0, 0, 0, 0, 1418, 1217, 0, + 0, 1419, 1214, 0, 0, 1219, 1221, 0, 1223, 0, + 0, 0, 0, 1214, 0, 0, 0, 0, 1219, 0, + 0, 1420, 1421, 1220, 0, 0, 0, 0, 0, 1219, + 1223, 0, 1217, 0, 1422, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1220, 0, + 0, 0, 0, 0, 1214, 1221, 0, 0, 0, 0, + 0, 0, 1219, 0, 0, 0, 0, 1423, 1219, 0, + 1424, 0, 0, 0, 0, 0, 1220, 0, 1216, 0, + 1221, 0, 0, 0, 1425, 0, 1426, 0, 0, 1216, + 0, 1220, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1418, 0, 0, 1220, 1419, 0, 0, 1221, 0, + 0, 0, 1219, 0, 0, 1220, 0, 0, 0, 0, + 0, 0, 0, 1221, 0, 1420, 1421, 1217, 0, 0, + 1216, 0, 0, 0, 0, 0, 1221, 1440, 1422, 0, + 0, 0, 0, 1219, 0, 0, 0, 1221, 1220, 1427, + 0, 0, 0, 0, 1220, 0, 0, 1219, 0, 0, + 0, 1223, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1423, 0, 0, 1424, 0, 0, 0, 0, 0, + 1221, 0, 0, 0, 0, 1440, 1221, 0, 1425, 0, + 1426, 1219, 0, 0, 0, 0, 1214, 0, 1220, 0, + 0, 2312, 0, 0, 0, 0, 0, 0, 0, 0, + 1414, 0, 0, 2343, 0, 0, 0, 0, 1416, 0, + 1214, 1217, 0, 1417, 0, 0, 0, 0, 0, 1220, + 1221, 0, 0, 0, 0, 0, 0, 1428, 0, 0, + 1429, 1430, 1431, 1220, 1432, 1433, 1434, 1435, 1436, 1437, + 0, 0, 0, 1427, 0, 1438, 0, 0, 0, 0, + 0, 1221, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1216, 0, 0, 1221, 0, 1220, 0, 0, + 0, 0, 0, 0, 0, 0, 1219, 0, 0, 0, + 0, 0, 0, 0, 1414, 0, 1216, 1440, 0, 0, + 0, 0, 1416, 0, 0, 0, 0, 1417, 0, 1221, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1418, 0, + 0, 1428, 1419, 0, 1429, 1430, 1431, 0, 1432, 1433, + 1434, 1435, 1436, 1437, 0, 0, 0, 1217, 0, 1438, + 0, 0, 1420, 1421, 0, 0, 0, 1214, 1217, 0, + 1574, 2020, 1220, 2020, 0, 1422, 0, 0, 0, 0, + 1219, 0, 0, 0, 0, 0, 1223, 0, 1223, 1214, + 0, 0, 0, 1214, 1214, 0, 0, 1414, 0, 0, + 0, 0, 0, 0, 1221, 1416, 0, 0, 1423, 1217, + 1417, 1424, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1418, 0, 0, 1425, 1419, 1426, 0, 1223, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1216, 0, 0, 1420, 1421, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1422, + 0, 0, 1214, 0, 0, 1216, 1220, 0, 0, 1216, + 1216, 0, 0, 0, 0, 0, 0, 0, 1223, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1427, 0, 1423, 0, 0, 1424, 0, 0, 1221, 1414, + 0, 0, 2352, 2020, 0, 0, 0, 1416, 0, 1425, + 0, 2348, 1417, 0, 0, 0, 1219, 0, 0, 1440, + 0, 0, 0, 0, 0, 1418, 0, 1219, 0, 1419, + 0, 2020, 0, 0, 0, 0, 0, 0, 1216, 0, + 0, 0, 0, 0, 0, 0, 1223, 0, 0, 1420, + 1421, 1217, 0, 0, 0, 0, 0, 0, 0, 1223, + 0, 0, 1422, 0, 0, 0, 0, 0, 1219, 0, + 2020, 1440, 0, 0, 1427, 1217, 0, 0, 1428, 0, + 0, 1429, 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, + 1437, 0, 0, 0, 1440, 1423, 1438, 0, 1424, 1859, + 0, 0, 1220, 1223, 0, 0, 0, 0, 0, 1223, + 0, 0, 1425, 1220, 1426, 0, 0, 0, 0, 1440, + 1440, 0, 0, 1440, 0, 0, 0, 1418, 0, 0, + 0, 1419, 0, 0, 1221, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1221, 0, 0, 0, 0, + 0, 1420, 1421, 1223, 1220, 0, 0, 0, 0, 0, + 1440, 0, 1428, 0, 1422, 1429, 1430, 1431, 0, 1432, + 1433, 1434, 1435, 1436, 1437, 0, 0, 1427, 0, 0, + 1438, 0, 0, 0, 1223, 0, 1221, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1423, 1223, 0, + 1424, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1219, 0, 0, 0, 1425, 0, 1426, 0, 0, 0, + 0, 0, 1217, 0, 1440, 0, 0, 0, 0, 0, + 0, 1440, 1223, 1440, 1219, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1217, 0, 0, 0, 1217, 1217, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1428, 0, 0, 1429, 1430, + 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, 1427, + 0, 1414, 0, 1438, 0, 0, 0, 0, 0, 1416, + 0, 0, 0, 0, 1417, 0, 1220, 0, 0, 0, + 0, 0, 0, 1414, 0, 0, 0, 0, 0, 0, + 0, 1416, 0, 0, 0, 0, 1417, 1217, 0, 0, + 1220, 0, 0, 0, 0, 0, 0, 1223, 1221, 0, + 0, 0, 1414, 0, 0, 0, 0, 0, 0, 0, + 1416, 0, 0, 0, 0, 1417, 0, 0, 0, 0, + 0, 0, 1221, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1428, 0, 0, + 1429, 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, + 0, 1219, 0, 0, 0, 1438, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1219, 0, 0, 0, 1219, 1219, 1418, + 0, 0, 0, 1419, 0, 0, 0, 0, 0, 0, + 1416, 1223, 0, 0, 0, 1417, 0, 0, 0, 0, + 0, 1418, 0, 1420, 1421, 1419, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1422, 0, 0, 0, + 0, 0, 0, 0, 0, 1420, 1421, 0, 0, 0, + 1418, 0, 0, 0, 1419, 0, 0, 1220, 1422, 0, + 0, 0, 0, 0, 0, 0, 1219, 0, 0, 1423, + 0, 0, 1424, 0, 1420, 1421, 0, 0, 0, 1220, + 0, 0, 0, 1220, 1220, 0, 1425, 1422, 1426, 1221, + 0, 1423, 0, 0, 1424, 0, 0, 2719, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1425, 0, + 1426, 1221, 0, 0, 0, 1221, 1221, 0, 0, 0, + 1423, 0, 0, 1424, 0, 0, 0, 0, 0, 0, + -1643, 0, 0, 0, 1419, 1440, 0, 1425, 0, 1426, + 0, 0, 0, 0, 0, 0, 0, 1223, 0, 0, + 0, 1427, 1220, 0, 1420, 1421, 0, 1440, 1223, 1440, + 0, 1859, 1859, 2330, 0, 0, 1859, -1643, 0, 0, + 1440, 0, 0, 1427, 0, 0, 0, 1440, 0, 0, + 0, 0, 1440, 0, 1221, 1414, 0, 1440, 2702, 0, + 0, 0, 1440, 1416, 0, 0, 0, 0, 1417, 1223, + 0, 1440, 1427, 1424, 0, 1859, 1859, 1440, 1414, 0, + 0, 0, 0, 0, 0, 0, 1416, 1425, 0, 1440, + 0, 1417, 0, 0, 0, 0, 1440, 2656, 1440, 1440, + 1440, 1440, 1440, 1440, 1440, 1440, 1440, 0, 1440, 1428, + 0, 0, 1429, 1430, 1431, 0, 1432, 1433, 1434, 1435, + 1436, 1437, 0, 0, 2493, 0, 0, 1438, 0, 0, + 0, 1428, 0, 0, 1429, 1430, 1431, 0, 1432, 1433, + 1434, 1435, 1436, 1437, 0, 0, 0, 0, 2531, 1438, + 0, 0, -1643, 0, 0, 0, 0, 0, 0, 0, + 1428, 0, 0, 1429, 1430, 1431, 0, 1432, 1433, 1434, + 1435, 1436, 1437, 0, 0, 0, 0, 0, 1438, 1440, + 0, 0, 0, 1418, 0, 0, 0, 1419, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1414, 0, 0, 0, 0, 1418, 1420, 1421, 1416, + 1419, 1223, 0, 0, 1417, 0, 0, 0, 0, 0, + 1422, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1420, 1421, 0, 0, 0, 1223, 0, 0, 0, 0, + 1428, 0, 0, 1422, 0, 0, 0, 1432, 1433, 1434, + 1435, 1436, 1437, 1423, 0, 0, 1424, 0, 1438, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1425, 0, 1426, 0, 0, 0, 1423, 0, 0, 1424, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1425, 0, 1426, 0, 0, 1440, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1414, 0, + 0, 0, 0, 0, 0, 0, 1416, 0, 0, 0, + 0, 1417, 0, 0, 0, 0, 0, 0, 1440, 1418, + 0, 0, 0, 1419, 0, 1427, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1420, 1421, 0, 0, 0, 1427, 0, + 0, 0, 0, 0, 0, 0, 1422, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1223, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1423, + 0, 0, 1424, 0, 1223, 0, 0, 0, 1223, 1223, + 0, 0, 0, 0, 0, 0, 1425, 0, 1426, 0, + 0, 0, 1440, 1428, 0, 0, 1429, 1430, 1431, 0, + 1432, 1433, 1434, 1435, 1436, 1437, 1418, 0, 0, 1440, + 1419, 1438, 0, 0, 0, 0, 1428, 0, 0, 1429, + 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, + 1420, 1421, 0, 2703, 1438, 0, 0, 0, 0, 0, + 0, 1440, 0, 1422, 0, 0, 0, 1223, 0, 0, + 0, 1427, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2330, 2330, 1859, 0, 0, 1859, 1859, 1859, + 1859, 1859, 1859, 1859, 1859, 1859, 1423, 1859, 2330, 1424, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1425, 0, 1426, 0, 0, 0, 0, + 0, 0, 1440, 0, 0, 1440, 0, 1440, 1414, 0, + 0, 0, 2330, 2330, 0, 0, 1416, 0, 0, 0, + 0, 1417, 0, 0, 0, 0, 1859, 1859, 1440, 0, + 1440, 0, 0, 1440, 0, 0, 0, 0, 0, 1428, + 0, 0, 1429, 1430, 1431, 0, 1432, 1433, 1434, 1435, + 1436, 1437, 1414, 0, 0, 0, 2743, 1438, 1427, 0, + 1416, 0, 0, 0, 0, 1417, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1440, 0, 1414, + 0, 0, 0, 0, 0, 0, 0, 1416, 0, 0, + 0, 0, 1417, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1418, 0, 0, 0, + 1419, 0, 1416, 0, 0, 0, 1428, 1417, 0, 1429, + 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, + 1420, 1421, 0, 2914, 1438, 0, 0, 0, 0, 0, + 0, 0, 0, 1422, 0, 0, 0, 0, 0, 0, + 1418, 0, 0, 0, 1419, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1859, 0, 1420, 1421, 1423, 1418, 0, 1424, + 0, 1419, 0, 0, 0, 0, 0, 1422, 0, 0, + 0, 0, 0, 1425, 0, 1426, 0, 0, 0, 2722, + 0, 1420, 1421, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1422, 0, 0, 0, 0, 0, + 1423, 0, 0, 1424, 0, 0, 0, 0, 0, 0, + 0, 0, -1643, 0, 0, 0, 1419, 1425, 0, 1426, + 0, 0, 0, 0, 0, 0, 0, 1423, 0, 0, + 1424, 0, 0, 0, 0, 0, 1420, 1421, 1427, 0, + 0, 0, 0, 0, 1425, 0, 1426, 0, 0, -1643, + 0, 0, 0, 0, 1440, 0, 0, 1440, 1440, 1440, + 0, 2330, 0, 0, 0, 0, 2330, 2330, 2330, 2330, + 2330, 2330, 2330, 2330, 2330, 1416, 2330, 1440, 1440, 0, + 1417, 0, 1427, 0, 0, 1424, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1425, + 0, 0, 0, 1440, 1859, 1859, 1440, 0, 1440, 1427, + 0, 0, 1440, 2330, 2330, 0, 0, 1440, 0, 0, + 1440, 0, 0, 0, 0, 0, 1428, 1440, 0, 1429, + 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, + 0, 0, 0, 2946, 1438, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2944, 0, -1643, 0, 0, 0, 0, 0, + 1428, 0, 0, 1429, 1430, 1431, 0, 1432, 1433, 1434, + 1435, 1436, 1437, 0, 0, 0, 0, 3073, 1438, 0, + 0, 0, 0, 0, 0, -1643, 0, 1428, 0, 1419, + 1429, 1430, 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, + 0, 0, 0, 0, 3111, 1438, 0, 0, 0, 1420, + 1421, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -1643, 2330, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1428, 0, 0, 0, 0, 0, 0, 1432, + 1433, 1434, 1435, 1436, 1437, 0, 0, 0, 1424, 0, + 1438, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1425, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1440, + 0, 0, 0, 1859, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1440, 0, 1440, 0, 0, + 0, 0, 2330, 2330, 1440, 0, 0, 1859, 1859, 1440, + 1440, 0, 1440, 0, 0, 0, 0, -1643, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1440, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1428, 0, 0, 0, 0, + 0, 0, 1432, 1433, 1434, 1435, 1436, 1437, 1440, 0, + 0, 0, 0, 1438, 0, 0, 0, 0, 0, 0, + 0, 0, 2330, 1859, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2330, 2330, 1440, 0, + 1440, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1440, 0, 0, 171, 172, 173, 174, + 175, 176, 177, 178, 0, 180, 181, 182, 0, 0, + 0, 0, 0, 0, 0, 183, 184, 0, 185, 0, + 186, 187, 188, 0, 189, 0, 190, 191, 0, 192, + 193, 194, 195, 196, 0, 1440, 197, 198, 199, 200, + 0, 201, 202, 203, 204, 205, 0, 2330, 206, 207, + 208, 209, 210, 211, 0, 212, 213, 214, 215, 216, + 0, 217, 218, 219, 0, 220, 221, 0, 0, 0, + 0, 0, 222, 223, 224, 225, 226, 227, 228, 229, + 0, 230, 0, 231, 232, 233, 234, 235, 0, 236, + 237, 238, 0, 0, 239, 240, 241, 242, 243, 0, + 244, 245, 246, 0, 247, 248, 0, 249, 250, 251, + 252, 253, 254, 255, 0, 256, 257, 258, 259, 0, + 260, 0, 261, 0, 0, 0, 262, 263, 0, 264, + 265, 0, 266, 0, 267, 268, 269, 270, 0, 271, + 272, 273, 0, 274, 275, 276, 277, 278, 279, 0, + 0, 280, 281, 282, 283, 284, 285, 286, 0, 287, + 0, 288, 0, 0, 289, 0, 290, 291, 292, 293, + 294, 0, 295, 0, 296, 0, 0, 297, 298, 299, + 0, 0, 300, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 0, 314, 0, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 0, 324, + 325, 0, 326, 0, 327, 328, 329, 330, 331, 0, + 0, 332, 0, 0, 0, 333, 334, 0, 0, 335, + 0, 0, 336, 337, 338, 339, 340, 341, 0, 342, + 343, 344, 345, 346, 347, 0, 348, 349, 350, 351, + 352, 353, 354, 355, 356, 0, 357, 358, 359, 360, + 361, 362, 363, 364, 365, 366, 0, 367, 368, 0, + 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, + 379, 0, 380, 381, 382, 0, 383, 384, 385, 386, + 0, 387, 388, 0, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 399, 400, 0, 401, 402, 0, + 403, 404, 405, 406, 407, 0, 408, 409, 0, 0, + 410, 411, 412, 413, 0, 414, 415, 416, 417, 418, + 0, 0, 419, 420, 421, 422, 0, 3141, 423, 424, + 425, 426, 427, 428, 429, 0, 430, 431, 432, 0, + 0, 433, 434, 435, 436, 437, 438, 439, 440, 441, + 442, 443, 444, 445, 446, 447, 448, 449, 0, 0, + 0, 0, 0, 450, 0, 0, 0, 0, 0, 171, + 172, 173, 174, 175, 176, 177, 178, 1949, 180, 181, + 182, 0, -1395, 0, 0, 841, 0, -1395, 183, 184, + 0, 185, 632, 186, 187, 188, 633, 842, 634, 843, + 844, 0, 192, 193, 194, 195, 196, 845, 846, 197, + 847, 848, 200, 0, 201, 202, 203, 204, 849, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 635, 220, 221, + 850, 851, 852, 853, 854, 222, 223, 224, 225, 226, + 855, 856, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 1950, 0, 239, 240, 857, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 858, 253, 254, 859, 860, 256, 257, + 258, 861, 0, 260, 0, 261, 636, 0, 637, 262, + 263, 0, 264, 862, 0, 266, 0, 267, 268, 269, + 270, 638, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 639, 280, 281, 282, 283, 284, 863, + 864, 0, 865, 0, 288, 640, 641, 289, 642, 290, + 291, 292, 293, 294, 0, 866, 643, 296, 644, 0, + 297, 298, 299, 867, 868, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 869, 645, + 870, 455, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 871, 324, 325, 646, 326, 872, 873, 328, 874, + 330, 331, 0, 0, 332, 456, 0, 0, 875, 334, + 0, 0, 335, 647, 648, 876, 337, 338, 339, 340, + 341, 0, 342, 877, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 878, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 649, 369, 370, 879, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 880, 383, + 384, 385, 386, 650, 387, 881, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 882, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 883, + 884, 0, 0, 410, 885, 412, 886, 887, 414, 415, + 416, 417, 418, 0, 888, 419, 420, 421, 422, 889, + 0, 423, 424, 425, 426, 427, 890, 429, 651, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 891, 892, 893, 894, 895, 896, 897, 447, 448, + 449, 0, 0, 0, 0, 0, 652, 898, 557, 899, + 900, 901, 902, 903, 0, 0, 0, 0, 904, 905, + 1951, 0, 0, 0, 0, 0, 0, 907, 1952, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 841, 0, 0, 183, 184, + 0, 185, 632, 186, 187, 188, 633, 842, 634, 843, + 844, 0, 192, 193, 194, 195, 196, 845, 846, 197, + 847, 848, 200, 0, 201, 202, 203, 204, 849, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 635, 220, 221, + 850, 851, 852, 853, 854, 222, 223, 224, 225, 226, + 855, 856, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 857, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 858, 253, 254, 859, 860, 256, 257, + 258, 861, 0, 260, 0, 261, 636, 0, 637, 262, + 263, 0, 264, 862, 0, 266, 0, 267, 268, 269, + 270, 638, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 639, 280, 281, 282, 283, 284, 863, + 864, 0, 865, 0, 288, 640, 641, 289, 642, 290, + 291, 292, 293, 294, 0, 866, 643, 296, 644, 0, + 297, 298, 299, 867, 868, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 869, 645, + 870, 455, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 871, 324, 325, 646, 326, 872, 873, 328, 874, + 330, 331, 0, 0, 332, 456, 0, 0, 875, 334, + 0, 0, 335, 647, 648, 876, 337, 338, 339, 340, + 341, 0, 342, 877, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 878, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 649, 369, 370, 879, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 880, 383, + 384, 385, 386, 650, 387, 881, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 882, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 883, + 884, 0, 0, 410, 885, 412, 886, 887, 414, 415, + 416, 417, 418, 0, 888, 419, 420, 421, 422, 889, + 0, 423, 424, 425, 426, 427, 890, 429, 651, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 891, 892, 893, 894, 895, 896, 897, 447, 448, + 449, 0, 0, 0, 0, 0, 652, 898, 557, 899, + 900, 901, 902, 903, 0, 0, 0, 0, 904, 905, + 0, 0, 0, 0, 0, 0, 0, 907, 1861, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 2226, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, -1033, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, -1033, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, -1033, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, -1033, 290, + 291, 292, 293, 294, 0, 295, -1033, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, -1033, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, -1033, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 971, 185, + 632, 186, 187, 188, 633, 1190, 634, 1191, 1192, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 1193, 1194, + 200, 0, 201, 202, 203, 204, 0, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 635, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 1195, 1196, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 857, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 0, 253, 254, 0, 0, 256, 257, 258, 1197, + 0, 260, 0, 261, 636, 0, 637, 262, 263, 0, + 264, 0, 0, 266, 0, 267, 268, 269, 270, 638, + 271, 272, 273, 1563, 274, 275, 276, 277, 278, 279, + 0, 639, 1564, 281, 282, 283, 284, 1198, 1199, 0, + 1200, 0, 288, 640, 641, 289, 642, 290, 291, 292, + 293, 294, 0, 0, 643, 296, 644, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 1201, 645, 1202, 0, + 315, 316, 317, 318, 319, 320, 321, 0, 323, 0, + 324, 325, 646, 326, 0, 0, 328, 1203, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 1565, 647, 648, 0, 337, 338, 339, 340, 341, 0, + 342, 0, 0, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 1204, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 649, 369, 370, 0, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 1566, 385, + 386, 650, 387, 1206, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 0, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 1207, 1208, 0, + 0, 410, 0, 412, 0, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 0, 1209, 429, 651, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 0, 0, + 0, 0, 0, 0, 0, 0, 447, 448, 449, 0, + 0, 0, 0, 0, 1210, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 841, 0, 0, 183, 184, 1567, 185, 632, 186, + 187, 188, 633, 842, 634, 843, 844, 1871, 192, 193, + 194, 195, 196, 845, 846, 197, 847, 848, 200, 0, + 201, 202, 203, 204, 849, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 635, 220, 221, 850, 851, 852, 853, + 854, 222, 223, 224, 225, 226, 855, 856, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 857, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 858, + 253, 254, 859, 860, 256, 257, 258, 861, 0, 260, + 0, 261, 636, 1872, 637, 262, 263, 0, 264, 862, + 0, 266, 0, 267, 268, 269, 270, 638, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 639, + 280, 281, 282, 283, 284, 863, 864, 0, 865, 0, + 288, 640, 641, 289, 642, 290, 291, 292, 293, 294, + 1873, 866, 643, 296, 644, 0, 297, 298, 299, 867, + 868, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 869, 645, 870, 455, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 871, 324, 325, + 646, 326, 872, 873, 328, 874, 330, 331, 0, 0, + 332, 456, 0, 0, 875, 334, 0, 0, 335, 647, + 648, 876, 337, 338, 339, 340, 341, 0, 342, 877, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 878, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 649, 369, + 370, 879, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 880, 383, 384, 385, 386, 650, + 387, 881, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 882, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 883, 884, 0, 1874, 410, + 885, 412, 886, 887, 414, 415, 416, 417, 418, 0, + 888, 419, 420, 421, 422, 889, 0, 423, 424, 425, + 426, 427, 890, 429, 651, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 891, 892, 893, + 894, 895, 896, 897, 447, 448, 449, 0, 0, 0, + 0, 0, 652, 898, 557, 899, 900, 901, 902, 903, + 0, 0, 0, 0, 904, 905, 0, 0, 0, 0, + 0, 0, 0, 907, 171, 172, 173, 174, 175, 176, + 177, 178, 0, 180, 181, 182, 0, 0, 0, 0, + 841, 0, 0, 183, 184, 0, 185, 632, 186, 187, + 188, 633, 842, 634, 843, 844, 0, 192, 193, 194, + 195, 196, 845, 846, 197, 847, 848, 200, 0, 201, + 202, 203, 204, 849, 0, 0, 206, 207, 208, 209, + 210, 211, 0, 212, 213, 214, 215, 216, 0, 217, + 218, 219, 635, 220, 221, 850, 851, 852, 853, 854, + 222, 223, 224, 225, 226, 855, 856, 229, 0, 230, + 0, 231, 232, 233, 234, 235, 0, 236, 237, 238, + 0, 0, 239, 240, 857, 242, 243, 0, 244, 245, + 246, 0, 247, 248, 0, 249, 250, 251, 858, 253, + 254, 859, 860, 256, 257, 258, 861, 0, 260, 0, + 261, 636, 0, 637, 262, 263, 0, 264, 862, 0, + 266, 0, 267, 268, 269, 270, 638, 271, 272, 273, + 0, 274, 275, 276, 277, 278, 279, 0, 639, 280, + 281, 282, 283, 284, 863, 864, 0, 865, 0, 288, + 640, 641, 289, 642, 290, 291, 292, 293, 294, 0, + 866, 643, 296, 644, 0, 297, 298, 299, 867, 868, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 869, 645, 870, 455, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 871, 324, 325, 646, + 326, 872, 873, 328, 874, 330, 331, 0, 0, 332, + 456, 0, 0, 875, 334, 0, 0, 335, 647, 648, + 876, 337, 338, 339, 340, 341, 0, 342, 877, 344, + 345, 346, 347, 0, 348, 349, 350, 351, 352, 353, + 878, 355, 356, 0, 357, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 0, 367, 368, 649, 369, 370, + 879, 372, 373, 374, 375, 376, 377, 378, 379, 0, + 380, 381, 382, 880, 383, 384, 385, 386, 650, 387, + 881, 0, 389, 390, 391, 392, 393, 394, 395, 396, + 397, 398, 882, 400, 0, 401, 402, 0, 403, 404, + 405, 406, 407, 0, 883, 884, 0, 0, 410, 885, + 412, 886, 887, 414, 415, 416, 417, 418, 0, 888, + 419, 420, 421, 422, 889, 0, 423, 424, 425, 426, + 427, 890, 429, 651, 430, 431, 432, 0, 0, 433, + 434, 435, 436, 437, 438, 439, 891, 892, 893, 894, + 895, 896, 897, 447, 448, 449, 0, 0, 0, 0, + 0, 652, 898, 557, 899, 900, 901, 902, 903, 0, + 0, 0, 0, 904, 905, 906, 0, 0, 0, 0, + 0, 0, 907, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 841, + 0, 0, 183, 184, 0, 185, 632, 186, 187, 188, + 633, 842, 634, 843, 844, 0, 192, 193, 194, 195, + 196, 845, 846, 197, 847, 848, 200, 0, 201, 202, + 203, 204, 849, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 635, 220, 221, 850, 851, 852, 853, 854, 222, + 223, 224, 225, 226, 855, 856, 229, 967, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 857, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 858, 253, 254, + 859, 860, 256, 257, 258, 861, 0, 260, 0, 261, + 636, 0, 637, 262, 263, 0, 264, 862, 0, 266, + 0, 267, 268, 269, 270, 638, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 639, 280, 281, + 282, 283, 284, 863, 864, 0, 865, 0, 288, 640, + 641, 289, 642, 290, 291, 292, 293, 294, 0, 866, + 643, 296, 644, 0, 297, 298, 299, 867, 868, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 869, 645, 870, 455, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 871, 324, 325, 646, 326, + 872, 873, 328, 874, 330, 331, 0, 0, 332, 456, + 0, 0, 875, 334, 0, 0, 335, 647, 648, 876, + 337, 338, 339, 340, 341, 0, 342, 877, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 878, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 649, 369, 370, 879, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 880, 383, 384, 385, 386, 650, 387, 881, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 882, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 883, 884, 0, 0, 410, 885, 412, + 886, 887, 414, 415, 416, 417, 418, 0, 888, 419, + 420, 421, 422, 889, 0, 423, 424, 425, 426, 427, + 890, 429, 651, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 891, 892, 893, 894, 895, + 896, 897, 447, 448, 449, 0, 0, 0, 0, 0, + 652, 898, 557, 899, 900, 901, 902, 903, 0, 0, + 0, 0, 904, 905, 0, 0, 0, 0, 0, 0, + 0, 907, 171, 172, 173, 174, 175, 176, 177, 178, + 0, 180, 181, 182, 0, 0, 0, 0, 841, 0, + 0, 183, 184, 0, 185, 632, 186, 187, 188, 633, + 842, 634, 843, 844, 0, 192, 193, 194, 195, 196, + 845, 846, 197, 847, 848, 200, 0, 201, 202, 203, + 204, 849, 0, 0, 206, 207, 208, 209, 210, 211, + 0, 212, 213, 214, 215, 216, 0, 217, 218, 219, + 635, 220, 221, 850, 851, 852, 853, 854, 222, 223, + 224, 225, 226, 855, 856, 229, 0, 230, 0, 231, + 232, 233, 234, 235, 0, 236, 237, 238, 0, 0, + 239, 240, 857, 242, 243, 0, 244, 245, 246, 0, + 247, 248, 0, 249, 250, 251, 858, 253, 254, 859, + 860, 256, 257, 258, 861, 0, 260, 0, 261, 636, + 0, 637, 262, 263, 0, 264, 862, 0, 266, 0, + 267, 268, 269, 270, 638, 271, 272, 273, 0, 274, + 275, 276, 277, 278, 279, 0, 639, 280, 281, 282, + 283, 284, 863, 864, 0, 865, 0, 288, 640, 641, + 289, 642, 290, 291, 292, 293, 294, 0, 866, 643, + 296, 644, 0, 297, 298, 299, 867, 868, 300, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 869, 645, 870, 455, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 871, 324, 325, 646, 326, 872, + 873, 328, 874, 330, 331, 0, 0, 332, 456, 0, + 0, 875, 334, 0, 0, 335, 647, 648, 876, 337, + 338, 339, 340, 341, 0, 342, 877, 344, 345, 346, + 347, 0, 348, 349, 350, 351, 352, 353, 878, 355, + 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 0, 367, 368, 649, 369, 370, 879, 372, + 373, 374, 375, 376, 377, 378, 379, 37, 380, 381, + 382, 880, 383, 384, 385, 386, 650, 387, 881, 0, + 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, + 882, 400, 0, 401, 402, 0, 403, 404, 405, 406, + 407, 0, 883, 884, 0, 0, 410, 885, 412, 886, + 887, 414, 415, 416, 417, 418, 0, 888, 419, 420, + 421, 422, 889, 0, 423, 424, 425, 426, 1404, 890, + 429, 651, 430, 431, 432, 0, 0, 433, 434, 435, + 436, 437, 438, 439, 891, 892, 893, 894, 895, 896, + 897, 447, 448, 449, 0, 0, 0, 0, 0, 652, + 898, 557, 899, 900, 901, 902, 903, 0, 0, 0, + 0, 904, 905, 0, 0, 0, 0, 0, 0, 0, + 907, 171, 172, 173, 174, 175, 176, 177, 178, 1512, + 180, 181, 182, 0, 0, 0, 0, 841, 0, 0, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 842, + 634, 843, 844, 0, 192, 193, 194, 195, 196, 845, + 846, 197, 847, 848, 200, 0, 201, 202, 203, 204, + 849, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 850, 851, 852, 853, 854, 222, 223, 224, + 225, 226, 855, 856, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 857, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 858, 253, 254, 859, 860, + 256, 257, 258, 861, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 862, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 280, 281, 282, 283, + 284, 863, 864, 0, 865, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 866, 643, 296, + 644, 0, 297, 298, 299, 867, 868, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 869, 645, 870, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 871, 324, 325, 646, 326, 872, 873, + 328, 874, 330, 331, 0, 0, 332, 456, 0, 0, + 875, 334, 0, 0, 335, 647, 648, 876, 337, 338, + 339, 340, 341, 0, 342, 877, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 878, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 879, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 880, 383, 384, 385, 386, 650, 387, 881, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 882, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 883, 884, 0, 0, 410, 885, 412, 886, 887, + 414, 415, 416, 417, 418, 0, 888, 419, 420, 421, + 422, 889, 0, 423, 424, 425, 426, 427, 890, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 891, 892, 893, 894, 895, 896, 897, + 447, 448, 449, 0, 0, 0, 0, 0, 652, 898, + 557, 899, 900, 901, 902, 903, 0, 0, 0, 0, + 904, 905, 0, 0, 0, 0, 0, 0, 0, 907, + 171, 172, 173, 174, 175, 176, 177, 178, 0, 180, + 181, 182, 0, 0, 0, 0, 841, 0, 0, 183, + 184, 0, 185, 632, 186, 187, 188, 633, 842, 634, + 843, 844, 0, 192, 193, 194, 195, 196, 845, 846, + 197, 847, 848, 200, 0, 201, 202, 203, 204, 849, + 0, 0, 206, 207, 208, 209, 210, 211, 0, 212, + 213, 214, 215, 216, 0, 217, 218, 219, 635, 220, + 221, 850, 851, 852, 853, 854, 222, 223, 224, 225, + 226, 855, 856, 229, 0, 230, 0, 231, 232, 233, + 234, 235, 0, 236, 237, 238, 0, 0, 239, 240, + 857, 242, 243, 0, 244, 245, 246, 0, 247, 248, + 0, 249, 250, 251, 858, 253, 254, 859, 860, 256, + 257, 258, 861, 0, 260, 0, 261, 636, 0, 637, + 262, 263, 0, 264, 862, 0, 266, 0, 267, 268, + 269, 270, 638, 271, 272, 273, 0, 274, 275, 276, + 277, 278, 279, 0, 639, 280, 281, 282, 283, 284, + 863, 864, 0, 865, 0, 288, 640, 641, 289, 642, + 290, 291, 292, 293, 294, 0, 866, 643, 296, 644, + 0, 297, 298, 299, 867, 868, 300, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 869, + 645, 870, 455, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 871, 324, 325, 646, 326, 872, 873, 328, + 874, 330, 331, 0, 0, 332, 456, 0, 0, 875, + 334, 0, 0, 335, 647, 648, 876, 337, 338, 339, + 340, 341, 0, 342, 877, 344, 345, 346, 347, 0, + 348, 349, 350, 351, 352, 353, 878, 355, 356, 0, + 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 0, 367, 368, 649, 369, 370, 879, 372, 373, 374, + 375, 376, 377, 378, 379, 0, 380, 381, 382, 880, + 383, 384, 385, 386, 650, 387, 881, 0, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 882, 400, + 0, 401, 402, 0, 403, 404, 405, 406, 407, 0, + 883, 884, 0, 0, 410, 885, 412, 886, 887, 414, + 415, 416, 417, 418, 0, 888, 419, 420, 421, 422, + 889, 0, 423, 424, 425, 426, 427, 890, 429, 651, + 430, 431, 432, 0, 0, 433, 434, 435, 436, 437, + 438, 439, 891, 892, 893, 894, 895, 896, 897, 447, + 448, 449, 0, 0, 0, 0, 0, 652, 898, 557, + 899, 900, 901, 902, 903, 0, 0, 0, 0, 904, + 905, 0, 0, 0, 0, 0, 1349, 0, 907, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 841, 0, 0, 183, 184, + 0, 185, 632, 186, 187, 188, 633, 842, 634, 843, + 844, 0, 192, 193, 194, 195, 196, 845, 846, 197, + 847, 848, 200, 0, 201, 202, 203, 204, 849, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 635, 220, 221, + 850, 851, 852, 853, 854, 222, 223, 224, 225, 226, + 855, 856, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 857, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 858, 253, 254, 859, 860, 256, 257, + 258, 861, 0, 260, 0, 261, 636, 1872, 637, 262, + 263, 0, 264, 862, 0, 266, 0, 267, 268, 269, + 270, 638, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 639, 280, 281, 282, 283, 284, 863, + 864, 0, 865, 0, 288, 640, 641, 289, 642, 290, + 291, 292, 293, 294, 0, 866, 643, 296, 644, 0, + 297, 298, 299, 867, 868, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 869, 645, + 870, 455, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 871, 324, 325, 646, 326, 872, 873, 328, 874, + 330, 331, 0, 0, 332, 456, 0, 0, 875, 334, + 0, 0, 335, 647, 648, 876, 337, 338, 339, 340, + 341, 0, 342, 877, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 878, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 649, 369, 370, 879, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 880, 383, + 384, 385, 386, 650, 387, 881, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 882, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 883, + 884, 0, 0, 410, 885, 412, 886, 887, 414, 415, + 416, 417, 418, 0, 888, 419, 420, 421, 422, 889, + 0, 423, 424, 425, 426, 427, 890, 429, 651, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 891, 892, 893, 894, 895, 896, 897, 447, 448, + 449, 0, 0, 0, 0, 0, 652, 898, 557, 899, + 900, 901, 902, 903, 0, 0, 0, 0, 904, 905, + 0, 0, 0, 0, 0, 0, 0, 907, 171, 172, + 173, 174, 175, 176, 177, 178, 0, 180, 181, 182, + 0, 0, 0, 0, 841, 0, 0, 183, 184, 0, + 185, 632, 186, 187, 188, 633, 842, 634, 843, 844, + 0, 192, 193, 194, 195, 196, 845, 846, 197, 847, + 848, 200, 0, 201, 202, 203, 204, 849, 0, 0, + 206, 207, 208, 209, 210, 211, 0, 212, 213, 214, + 215, 216, 0, 217, 218, 219, 635, 220, 221, 850, + 851, 852, 853, 854, 222, 223, 224, 225, 226, 855, + 856, 229, 0, 230, 0, 231, 232, 233, 234, 235, + 0, 236, 237, 238, 0, 0, 239, 240, 857, 242, + 243, 0, 244, 245, 246, 0, 247, 248, 0, 249, + 250, 251, 858, 253, 254, 859, 860, 256, 257, 258, + 861, 0, 260, 0, 261, 636, 0, 637, 262, 263, + 0, 264, 862, 0, 266, 0, 267, 268, 269, 270, + 638, 271, 272, 273, 0, 274, 275, 276, 277, 278, + 279, 0, 639, 280, 281, 282, 283, 284, 863, 864, + 0, 865, 0, 288, 640, 641, 289, 642, 290, 291, + 292, 293, 294, 0, 866, 643, 296, 644, 0, 297, + 298, 299, 867, 868, 300, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 869, 645, 870, + 455, 315, 316, 317, 318, 319, 320, 321, 322, 323, + 871, 324, 325, 646, 326, 872, 873, 328, 874, 330, + 331, 0, 0, 332, 456, 0, 0, 875, 334, 0, + 0, 335, 647, 648, 876, 337, 338, 339, 340, 341, + 0, 342, 877, 344, 345, 346, 347, 0, 348, 349, + 350, 351, 352, 353, 878, 355, 356, 0, 357, 358, + 359, 360, 361, 362, 363, 364, 365, 366, 0, 367, + 368, 649, 369, 370, 879, 372, 373, 374, 375, 376, + 377, 378, 379, 0, 380, 381, 382, 880, 383, 384, + 385, 386, 650, 387, 881, 0, 389, 390, 391, 392, + 393, 394, 395, 396, 397, 398, 882, 400, 0, 401, + 402, 0, 403, 404, 405, 406, 407, 0, 883, 884, + 0, 0, 410, 885, 412, 886, 887, 414, 415, 416, + 417, 418, 0, 888, 419, 420, 421, 422, 889, 0, + 423, 424, 425, 426, 427, 890, 429, 651, 430, 431, + 432, 0, 0, 433, 434, 435, 436, 437, 438, 439, + 891, 892, 893, 894, 895, 896, 897, 447, 448, 449, + 0, 0, 0, 0, 0, 652, 898, 557, 899, 900, + 901, 902, 903, 0, 0, 0, 0, 904, 905, 0, + 0, 0, 0, 0, 0, 0, 907, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 841, 0, 0, 183, 184, 0, 185, + 632, 186, 187, 188, 633, 842, 634, 843, 844, 0, + 192, 193, 194, 195, 196, 845, 846, 197, 847, 848, + 200, 0, 201, 202, 203, 204, 849, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 635, 220, 2244, 850, 851, + 852, 853, 854, 222, 223, 224, 225, 226, 855, 856, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 857, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 858, 253, 254, 859, 860, 256, 257, 258, 861, + 0, 260, 0, 261, 636, 0, 637, 262, 263, 0, + 264, 862, 0, 266, 0, 267, 268, 269, 270, 638, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 639, 280, 281, 282, 283, 284, 863, 864, 0, + 865, 0, 288, 640, 641, 289, 642, 290, 291, 292, + 293, 294, 0, 866, 643, 296, 644, 0, 297, 298, + 299, 867, 868, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 869, 645, 870, 455, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 871, + 324, 325, 646, 326, 872, 873, 328, 874, 330, 331, + 0, 0, 332, 456, 0, 0, 875, 334, 0, 0, + 335, 647, 648, 876, 337, 338, 339, 340, 341, 0, + 342, 877, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 878, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 649, 369, 370, 879, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 880, 383, 384, 385, + 386, 650, 387, 881, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 882, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 883, 884, 0, + 0, 410, 885, 412, 886, 887, 414, 415, 416, 417, + 418, 0, 888, 419, 420, 421, 422, 889, 0, 423, + 424, 425, 426, 427, 890, 429, 651, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 891, + 892, 893, 894, 895, 896, 897, 447, 448, 449, 0, + 0, 0, 0, 0, 652, 898, 557, 899, 900, 901, + 902, 903, 0, 0, 0, 0, 904, 905, 0, 0, + 0, 0, 0, 0, 0, 907, 171, 172, 173, 174, + 175, 176, 177, 178, 0, 180, 181, 182, 0, 0, + 0, 0, 841, 0, 0, 183, 184, 0, 185, 632, + 186, 187, 188, 633, 842, 634, 843, 844, 0, 192, + 193, 194, 195, 196, 845, 846, 197, 847, 848, 200, + 0, 201, 202, 203, 204, 849, 0, 0, 206, 207, + 208, 209, 210, 211, 0, 212, 213, 214, 215, 216, + 0, 217, 218, 219, 635, 220, 221, 850, 851, 852, + 853, 854, 222, 223, 224, 225, 226, 855, 856, 229, + 0, 230, 0, 231, 232, 233, 234, 235, 0, 236, + 237, 238, 0, 0, 239, 240, 857, 242, 243, 0, + 244, 245, 246, 0, 247, 248, 0, 249, 250, 251, + 858, 253, 254, 859, 860, 256, 257, 258, 861, 0, + 260, 0, 261, 636, 0, 637, 262, 263, 0, 264, + 862, 0, 266, 0, 267, 268, 269, 270, 638, 271, + 272, 273, 0, 274, 275, 276, 277, 278, 279, 0, + 639, 280, 281, 282, 283, 284, 863, 864, 0, 865, + 0, 288, 640, 641, 289, 642, 290, 291, 292, 293, + 294, 0, 866, 643, 296, 644, 0, 297, 298, 299, + 867, 868, 300, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 869, 645, 870, 455, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 871, 324, + 325, 646, 326, 872, 873, 328, 874, 330, 331, 0, + 0, 332, 456, 0, 0, 875, 334, 0, 0, 335, + 647, 648, 876, 337, 338, 339, 340, 341, 0, 342, + 877, 344, 345, 346, 347, 0, 348, 349, 350, 351, + 352, 353, 878, 355, 356, 0, 357, 358, 359, 360, + 361, 362, 363, 364, 365, 366, 0, 367, 368, 649, + 369, 370, 879, 372, 373, 374, 375, 376, 377, 378, + 379, 0, 380, 381, 382, 880, 383, 384, 385, 386, + 650, 387, 881, 0, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 882, 400, 0, 401, 402, 0, + 403, 404, 405, 406, 407, 0, 883, 884, 0, 0, + 410, 885, 412, 886, 887, 414, 415, 416, 417, 418, + 0, 888, 419, 420, 421, 422, 889, 0, 423, 424, + 425, 426, 427, 890, 429, 651, 430, 431, 432, 0, + 0, 433, 434, 435, 436, 437, 438, 2922, 891, 892, + 893, 894, 895, 896, 897, 447, 448, 449, 0, 0, + 0, 0, 0, 652, 898, 557, 899, 900, 901, 902, + 903, 0, 0, 0, 0, 904, 905, 0, 0, 0, + 0, 0, 0, 0, 907, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 841, 0, 0, 183, 184, 0, 185, 632, 186, + 187, 188, 633, 842, 634, 843, 844, 0, 192, 193, + 194, 195, 196, 845, 846, 197, 847, 848, 200, 0, + 201, 202, 203, 204, 849, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 635, 220, 221, 850, 851, 852, 853, + 854, 222, 223, 224, 225, 226, 855, 856, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 857, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 858, + 253, 254, 859, 860, 256, 257, 258, 861, 0, 260, + 0, 261, 636, 0, 637, 262, 263, 0, 264, 862, + 0, 266, 0, 267, 268, 269, 270, 638, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 639, + 280, 281, 282, 283, 284, 863, 864, 0, 865, 0, + 288, 640, 641, 289, 642, 290, 291, 292, 293, 294, + 0, 866, 643, 296, 644, 0, 297, 298, 299, 867, + 868, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 869, 645, 870, 455, 315, 2929, + 317, 318, 319, 320, 321, 322, 323, 871, 324, 325, + 646, 326, 872, 873, 328, 874, 330, 331, 0, 0, + 332, 456, 0, 0, 875, 334, 0, 0, 335, 647, + 648, 876, 337, 338, 339, 340, 341, 0, 342, 877, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 878, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 649, 369, + 370, 879, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 880, 383, 384, 385, 386, 650, + 387, 881, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 882, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 883, 884, 0, 0, 410, + 885, 412, 886, 887, 414, 415, 416, 417, 418, 0, + 888, 419, 420, 421, 422, 889, 0, 423, 424, 425, + 426, 427, 890, 429, 651, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 891, 892, 893, + 894, 895, 896, 897, 447, 448, 449, 0, 0, 0, + 0, 0, 652, 898, 557, 899, 900, 901, 902, 903, + 0, 0, 0, 0, 904, 905, 0, 0, 0, 0, + 0, 0, 0, 907, 171, 172, 173, 174, 175, 176, + 177, 178, 0, 180, 181, 182, 0, 0, 0, 0, + 841, 0, 0, 183, 184, 0, 185, 632, 186, 187, + 188, 633, 842, 634, 843, 844, 0, 192, 193, 194, + 195, 196, 845, 846, 197, 847, 848, 200, 0, 201, + 202, 203, 204, 849, 0, 0, 206, 207, 208, 209, + 210, 211, 0, 212, 213, 214, 215, 216, 0, 217, + 218, 219, 635, 220, 221, 850, 851, 852, 853, 854, + 222, 223, 224, 225, 226, 855, 856, 229, 0, 230, + 0, 231, 232, 233, 234, 235, 0, 236, 237, 238, + 0, 0, 239, 240, 857, 242, 243, 0, 244, 245, + 246, 0, 247, 248, 0, 249, 250, 251, 858, 253, + 254, 859, 860, 256, 257, 258, 861, 0, 260, 0, + 261, 636, 0, 637, 262, 263, 0, 264, 862, 0, + 266, 0, 267, 268, 269, 270, 638, 271, 272, 273, + 0, 274, 275, 276, 277, 278, 279, 0, 639, 280, + 281, 282, 283, 284, 863, 864, 0, 865, 0, 288, + 640, 641, 289, 642, 290, 291, 292, 293, 294, 0, + 866, 643, 296, 644, 0, 297, 298, 299, 867, 868, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 869, 645, 870, 455, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 0, 324, 325, 646, + 326, 872, 873, 328, 874, 330, 331, 0, 0, 332, + 456, 0, 0, 875, 334, 0, 0, 335, 647, 648, + 876, 337, 338, 339, 340, 341, 0, 342, 877, 344, + 345, 346, 347, 0, 348, 349, 350, 351, 352, 353, + 878, 355, 356, 0, 357, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 0, 367, 368, 649, 369, 370, + 879, 372, 373, 374, 375, 376, 377, 378, 379, 0, + 380, 381, 382, 880, 383, 384, 385, 386, 650, 387, + 881, 0, 389, 390, 391, 392, 393, 394, 395, 396, + 397, 398, 882, 400, 0, 401, 402, 0, 403, 404, + 405, 406, 407, 0, 883, 884, 0, 0, 410, 885, + 412, 886, 887, 414, 415, 416, 417, 418, 0, 0, + 419, 420, 421, 422, 889, 0, 423, 424, 425, 426, + 427, 890, 429, 651, 430, 431, 432, 0, 0, 433, + 434, 435, 436, 437, 438, 439, 891, 892, 893, 894, + 895, 896, 897, 447, 448, 449, 0, 0, 0, 0, + 0, 652, 898, 557, 899, 900, 901, 902, 903, 0, + 0, 0, 0, 1854, 1855, 0, 0, 0, 0, 0, + 0, 0, 907, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 841, + 0, 0, 183, 184, 0, 185, 632, 186, 187, 188, + 0, 842, 634, 843, 844, 0, 192, 193, 194, 195, + 196, 845, 846, 197, 847, 848, 200, 0, 201, 202, + 203, 204, 849, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 635, 220, 221, 850, 851, 852, 853, 854, 222, + 223, 224, 225, 226, 855, 856, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 857, 242, 243, 0, 244, 245, 246, + 0, 247, 0, 0, 249, 250, 251, 858, 253, 254, + 859, 860, 256, 257, 258, 861, 0, 260, 0, 261, + 636, 0, 637, 262, 263, 0, 264, 862, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 639, 280, 281, + 282, 283, 284, 863, 864, 0, 865, 0, 288, 640, + 641, 289, 642, 290, 291, 292, 293, 294, 0, 866, + 643, 296, 0, 0, 297, 298, 299, 867, 868, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 869, 645, 870, 455, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 646, 326, + 872, 873, 328, 874, 330, 331, 0, 0, 332, 456, + 0, 0, 875, 334, 0, 0, 335, 647, 648, 876, + 337, 338, 339, 340, 341, 0, 342, 877, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 878, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 649, 369, 370, 879, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 880, 383, 384, 385, 386, 0, 387, 881, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 882, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 883, 884, 0, 0, 410, 885, 412, + 886, 887, 414, 415, 416, 417, 418, 0, 888, 419, + 420, 421, 422, 889, 0, 423, 424, 425, 426, 427, + 890, 429, 651, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 891, 892, 893, 894, 895, + 896, 897, 447, 448, 449, 0, 0, 0, 0, 0, + 652, 898, 557, 899, 900, 901, 902, 903, 0, 0, + 0, 0, 904, 905, 0, 0, 0, 0, 0, 0, + 0, 907, 171, 172, 173, 174, 175, 176, 177, 178, + 0, 180, 181, 182, 0, 0, 0, 0, 841, 0, + 0, 183, 184, 0, 185, 632, 186, 187, 188, 0, + 842, 634, 843, 844, 0, 192, 193, 194, 195, 196, + 845, 846, 197, 847, 848, 200, 0, 201, 202, 203, + 204, 849, 0, 0, 206, 207, 208, 209, 210, 211, + 0, 212, 213, 214, 215, 216, 0, 217, 218, 219, + 635, 220, 221, 850, 851, 852, 853, 854, 222, 223, + 224, 225, 226, 855, 856, 229, 0, 230, 0, 231, + 232, 233, 234, 235, 0, 236, 237, 238, 0, 0, + 239, 240, 857, 242, 243, 0, 244, 245, 246, 0, + 247, 0, 0, 249, 250, 251, 858, 253, 254, 859, + 860, 256, 257, 258, 861, 0, 260, 0, 261, 636, + 0, 637, 262, 263, 0, 264, 862, 0, 266, 0, + 267, 268, 269, 270, 0, 271, 272, 273, 0, 274, + 275, 276, 277, 278, 279, 0, 639, 280, 281, 282, + 283, 284, 863, 864, 0, 865, 0, 288, 640, 641, + 289, 642, 290, 291, 292, 293, 294, 0, 866, 643, + 296, 0, 0, 297, 298, 299, 867, 868, 300, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 869, 645, 870, 455, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 0, 324, 325, 646, 326, 872, + 873, 328, 874, 330, 331, 0, 0, 332, 456, 0, + 0, 875, 334, 0, 0, 335, 647, 648, 876, 337, + 338, 339, 340, 341, 0, 342, 877, 344, 345, 346, + 347, 0, 348, 349, 350, 351, 352, 353, 878, 355, + 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 0, 367, 368, 649, 369, 370, 879, 372, + 373, 374, 375, 376, 377, 378, 379, 0, 380, 381, + 382, 880, 383, 384, 385, 386, 0, 387, 881, 0, + 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, + 882, 400, 0, 401, 402, 0, 403, 404, 405, 406, + 407, 0, 883, 884, 0, 0, 410, 885, 412, 886, + 887, 414, 415, 416, 417, 418, 0, 0, 419, 420, + 421, 422, 889, 0, 423, 424, 425, 426, 427, 890, + 429, 651, 430, 431, 432, 0, 0, 433, 434, 435, + 436, 437, 438, 439, 891, 892, 893, 894, 895, 896, + 897, 447, 448, 449, 0, 0, 0, 0, 0, 652, + 898, 557, 899, 900, 901, 902, 903, 0, 0, 0, + 0, 1854, 1855, 0, 0, 0, 0, 0, 0, 0, + 907, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 189, + 634, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 846, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 849, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 850, 851, 852, 853, 854, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 859, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 862, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 866, 643, 296, + 644, 0, 297, 298, 299, 867, 868, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 645, 314, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 646, 326, 0, 873, + 328, 329, 330, 331, 0, 0, 332, 456, 0, 610, + 333, 334, 0, 0, 335, 647, 648, 876, 337, 338, + 339, 340, 341, 0, 342, 877, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 37, 380, 381, 382, + 880, 383, 384, 385, 386, 650, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 882, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 885, 412, 886, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 889, 0, 423, 424, 425, 426, 1404, 428, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 891, 892, 893, 894, 895, 896, 897, + 447, 448, 449, 0, 0, 0, 0, 0, 652, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 1739, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 189, + 634, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 846, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 849, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 850, 851, 852, 853, 854, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 859, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 862, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 866, 643, 296, + 644, 0, 297, 298, 299, 867, 868, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 645, 314, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 646, 326, 0, 873, + 328, 329, 330, 331, 0, 0, 332, 456, 0, 610, + 333, 334, 0, 0, 335, 647, 648, 876, 337, 338, + 339, 340, 341, 0, 342, 877, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 880, 383, 384, 385, 386, 650, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 882, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 885, 412, 886, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 889, 0, 423, 424, 425, 426, 427, 428, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 891, 892, 893, 894, 895, 896, 897, + 447, 448, 449, 0, 0, 0, 0, 0, 652, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 1739, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 189, + 634, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 846, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 849, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 850, 851, 852, 853, 854, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 859, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 862, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 866, 643, 296, + 644, 0, 297, 298, 299, 867, 868, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 645, 314, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 646, 326, 0, 873, + 328, 329, 330, 331, 0, 0, 332, 456, 0, 0, + 333, 334, 0, 0, 335, 647, 648, 876, 337, 338, + 339, 340, 341, 0, 342, 877, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 880, 383, 384, 385, 386, 650, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 882, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 885, 412, 886, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 889, 0, 423, 424, 425, 426, 427, 428, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 891, 892, 893, 894, 895, 896, 897, + 447, 448, 449, 0, 0, 0, 0, 0, 652, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 3041, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 189, + 634, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 295, 643, 296, + 644, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 645, 314, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 646, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 456, 0, 0, + 333, 334, 0, 0, 335, 647, 648, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 650, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 652, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 3089, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 456, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 959, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 37, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 1404, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 46, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 0, + 0, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 1489, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2621, + 171, 172, 173, 174, 175, 176, 177, 178, 1081, 180, + 181, 182, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 183, + 184, 1089, 185, 632, 186, 187, 188, 633, 1190, 634, + 1191, 1192, 1090, 192, 193, 194, 195, 196, 1091, 1092, + 197, 1193, 1194, 200, 1093, 201, 202, 203, 204, 0, + 1094, 1095, 206, 207, 208, 209, 210, 211, 1096, 212, + 213, 214, 215, 216, 1097, 217, 218, 219, 635, 220, + 221, 1098, 1099, 1100, 1101, 1102, 222, 223, 224, 225, + 226, 1195, 1196, 229, 1103, 230, 1104, 231, 232, 233, + 234, 235, 1105, 236, 237, 238, 1106, 1107, 239, 240, + 857, 242, 243, 1108, 244, 245, 246, 1109, 247, 248, + 1110, 249, 250, 251, 0, 253, 254, 0, 1111, 256, + 257, 258, 1197, 1112, 260, 1113, 261, 636, 1114, 637, + 262, 263, 1115, 264, 0, 1116, 266, 1117, 267, 268, + 269, 270, 638, 271, 272, 273, 1118, 274, 275, 276, + 277, 278, 279, 1119, 639, 0, 281, 282, 283, 284, + 1198, 1199, 1120, 1200, 1121, 288, 640, 641, 289, 642, + 290, 291, 292, 293, 294, 1122, 0, 643, 296, 644, + 1123, 297, 298, 299, 1124, 1125, 300, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 1201, + 645, 1202, 1126, 315, 316, 317, 318, 319, 320, 321, + 0, 323, 1127, 324, 325, 646, 326, 1128, 0, 328, + 1203, 330, 331, 1129, 1130, 332, 1131, 1132, 1133, 2521, + 334, 1134, 1135, 0, 647, 648, 0, 337, 338, 339, + 340, 341, 1136, 342, 0, 0, 345, 346, 347, 1137, + 348, 349, 350, 351, 352, 353, 1204, 355, 356, 1138, + 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 1139, 367, 368, 649, 369, 370, 0, 372, 373, 374, + 375, 376, 377, 378, 379, 1140, 380, 381, 382, 1141, + 383, 1566, 385, 386, 650, 387, 1206, 1142, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 0, 400, + 1143, 401, 402, 1144, 403, 404, 405, 406, 407, 1145, + 1207, 1208, 1146, 1147, 410, 0, 412, 0, 1148, 414, + 415, 416, 417, 418, 1149, 1150, 419, 420, 421, 422, + 1151, 1152, 423, 424, 425, 426, 0, 1209, 429, 651, + 430, 431, 432, 1153, 1154, 433, 434, 435, 436, 437, + 438, 0, 0, 0, 0, 0, 0, 0, 0, 447, + 448, 449, 0, 0, 0, 0, 0, 1210, 1460, 557, + 0, 0, 670, 542, 0, 671, 672, 673, 0, 674, + 2522, 676, 677, 678, 679, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 668, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 669, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 0, 0, 0, 0, 670, 0, 0, + 671, 672, 673, 0, 674, 675, 676, 677, 678, 679, + 171, 172, 173, 174, 175, 176, 177, 178, 0, 180, + 181, 182, 0, 0, 0, 0, 0, 0, 0, 183, + 184, 0, 185, 0, 186, 187, 188, 0, 189, 0, + 190, 191, 0, 192, 193, 194, 195, 196, 0, 0, + 197, 198, 199, 200, 0, 201, 745, 203, 204, 205, + 0, 0, 206, 207, 208, 209, 210, 211, 0, 212, + 213, 214, 215, 216, 0, 217, 218, 219, 0, 220, + 221, 0, 0, 0, 0, 0, 222, 223, 224, 225, + 226, 227, 228, 229, 0, 230, 0, 231, 232, 233, + 234, 235, 0, 236, 237, 238, 0, 0, 239, 240, + 241, 242, 243, 0, 244, 245, 246, 0, 247, 248, + 0, 249, 250, 251, 252, 253, 254, 255, 0, 746, + 257, 258, 259, 0, 260, 0, 261, 0, 0, 0, + 262, 263, 0, 264, 265, 0, 266, 0, 267, 268, + 269, 270, 0, 271, 272, 273, 0, 274, 275, 276, + 277, 278, 279, 0, 0, 280, 281, 282, 283, 284, + 285, 286, 0, 287, 0, 288, 0, 0, 289, 0, + 290, 291, 292, 293, 294, 0, 295, 0, 296, 0, + 0, 297, 298, 299, 0, 0, 300, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, + 0, 314, 0, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 0, 324, 325, 0, 326, 0, 327, 328, + 329, 330, 331, 0, 0, 332, 0, 0, 0, 333, + 334, 0, 0, 335, 0, 0, 336, 337, 338, 339, + 340, 341, 0, 342, 343, 344, 345, 346, 347, 0, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 0, + 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 0, 367, 368, 0, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 0, 380, 381, 382, 0, + 383, 384, 385, 386, 0, 387, 388, 0, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, + 0, 401, 402, 0, 403, 404, 405, 406, 407, 0, + 408, 409, 0, 0, 410, 411, 412, 413, 0, 414, + 415, 416, 417, 418, 0, 0, 419, 420, 421, 422, + 0, 0, 423, 424, 425, 426, 427, 428, 429, 0, + 430, 431, 432, 0, 0, 433, 434, 435, 436, 437, + 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, + 448, 449, 0, 0, 0, 0, 0, 450, 0, 0, + 0, 0, 670, 0, 0, 671, 672, 673, 0, 674, + 675, 676, 677, 678, 679, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 781, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 782, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 783, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 0, 0, 0, 0, 670, 0, 0, + 671, 672, 673, 0, 674, 675, 676, 677, 678, 679, + 171, 172, 173, 174, 175, 176, 177, 178, 0, 180, + 181, 182, 0, 0, 0, 0, 0, 0, 0, 183, + 184, 0, 185, 0, 186, 187, 188, 0, 189, 0, + 190, 191, 0, 192, 193, 194, 195, 196, 0, 0, + 197, 198, 199, 200, 0, 201, 1172, 203, 204, 205, + 0, 0, 206, 207, 208, 209, 210, 211, 0, 212, + 213, 214, 215, 216, 0, 217, 218, 219, 0, 220, + 221, 0, 0, 0, 0, 0, 222, 223, 224, 225, + 226, 227, 228, 229, 0, 230, 0, 231, 232, 233, + 234, 235, 0, 236, 237, 238, 0, 0, 239, 240, + 241, 242, 243, 0, 244, 245, 246, 0, 247, 248, + 0, 249, 250, 251, 252, 253, 254, 255, 0, 1173, + 257, 258, 259, 0, 260, 0, 261, 0, 0, 0, + 262, 263, 0, 264, 265, 0, 266, 0, 267, 268, + 269, 270, 0, 271, 272, 273, 0, 274, 275, 276, + 277, 278, 279, 0, 0, 280, 281, 282, 283, 284, + 285, 286, 0, 287, 0, 288, 0, 0, 289, 0, + 290, 291, 292, 293, 294, 0, 295, 0, 296, 0, + 0, 297, 298, 299, 0, 0, 300, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, + 0, 314, 0, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 0, 324, 325, 0, 326, 0, 327, 328, + 329, 330, 331, 0, 0, 332, 0, 0, 0, 333, + 334, 0, 0, 335, 0, 0, 336, 337, 338, 339, + 340, 341, 0, 342, 343, 344, 345, 346, 347, 0, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 0, + 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 0, 367, 368, 0, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 0, 380, 381, 382, 0, + 383, 384, 385, 386, 0, 387, 388, 0, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, + 0, 401, 402, 0, 403, 404, 405, 406, 407, 0, + 408, 409, 0, 0, 410, 411, 412, 413, 0, 414, + 415, 416, 417, 418, 0, 0, 419, 420, 421, 422, + 0, 0, 423, 424, 425, 426, 427, 428, 429, 0, + 430, 431, 432, 0, 0, 433, 434, 435, 436, 437, + 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, + 448, 449, 0, 0, 0, 0, 0, 450, 0, 0, + 0, 0, 670, 0, 0, 671, 672, 673, 0, 674, + 675, 676, 677, 678, 679, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 0, 0, 0, 0, 670, 0, 0, + 671, 672, 673, 0, 674, 675, 676, 677, 678, 679, + 171, 172, 173, 174, 175, 176, 177, 178, 1081, 180, + 181, 182, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 183, + 184, 1089, 185, 632, 186, 187, 188, 633, 189, 634, + 190, 191, 1090, 192, 193, 194, 195, 196, 1091, 1092, + 197, 198, 199, 200, 1093, 201, 202, 203, 204, 205, + 1094, 1095, 206, 207, 208, 209, 210, 211, 1096, 212, + 213, 214, 215, 216, 1097, 217, 218, 219, 635, 220, + 221, 1098, 1099, 1100, 1101, 1102, 222, 223, 224, 225, + 226, 227, 228, 229, 1103, 230, 1104, 231, 232, 233, + 234, 235, 1105, 236, 237, 238, 1106, 1107, 239, 240, + 241, 242, 243, 1108, 244, 245, 246, 1109, 247, 248, + 1110, 249, 250, 251, 252, 253, 254, 255, 1111, 256, + 257, 258, 259, 1112, 260, 1113, 261, 636, 1114, 637, + 262, 263, 1115, 264, 265, 1116, 266, 1117, 267, 268, + 269, 270, 638, 271, 272, 273, 1118, 274, 275, 276, + 277, 278, 279, 1119, 639, 280, 281, 282, 283, 284, + 285, 286, 1120, 287, 1121, 288, 640, 641, 289, 642, + 290, 291, 292, 293, 294, 1122, 295, 643, 296, 644, + 1123, 297, 298, 299, 1124, 1125, 300, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, + 645, 314, 1126, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 1127, 324, 325, 646, 326, 1128, 327, 328, + 329, 330, 331, 1129, 1130, 332, 1131, 1132, 1133, 333, + 334, 1134, 1135, 335, 647, 648, 336, 337, 338, 339, + 340, 341, 1136, 342, 343, 344, 345, 346, 347, 1137, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 1138, + 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 1139, 367, 368, 649, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 379, 1140, 380, 381, 382, 1141, + 383, 384, 385, 386, 650, 387, 388, 1142, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, + 1143, 401, 402, 1144, 403, 404, 405, 406, 407, 1145, + 408, 409, 1146, 1147, 410, 411, 412, 413, 1148, 414, + 415, 416, 417, 418, 1149, 1150, 419, 420, 421, 422, + 1151, 1152, 423, 424, 425, 426, 427, 428, 429, 651, + 430, 431, 432, 1153, 1154, 433, 434, 435, 436, 437, + 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, + 448, 449, 0, 0, 0, 0, 0, 1155, 171, 172, + 173, 174, 175, 176, 177, 178, 0, 180, 181, 182, + 0, 1156, 0, 0, 0, 0, 0, 183, 184, 0, + 185, 0, 186, 187, 188, 0, 189, 0, 190, 191, + 0, 192, 193, 194, 195, 196, 0, 0, 197, 198, + 199, 200, 0, 201, 202, 203, 204, 205, 0, 0, + 206, 207, 208, 209, 210, 211, 0, 212, 213, 214, + 215, 216, 0, 217, 218, 219, 0, 220, 221, 0, + 0, 0, 0, 0, 222, 223, 224, 225, 226, 227, + 228, 229, 0, 230, 0, 231, 232, 233, 234, 235, + 0, 236, 237, 238, 0, 0, 239, 240, 241, 242, + 243, 0, 244, 245, 246, 0, 247, 248, 0, 249, + 250, 251, 252, 253, 254, 255, 0, 256, 257, 258, + 259, 0, 260, 0, 261, 0, 0, 0, 262, 263, + 0, 264, 265, 0, 266, 0, 267, 268, 269, 270, + 0, 271, 272, 273, 0, 274, 275, 276, 277, 278, + 279, 0, 0, 280, 281, 282, 283, 284, 285, 286, + 0, 287, 0, 288, 0, 0, 289, 0, 290, 291, + 292, 293, 294, 0, 295, 0, 296, 0, 0, 297, + 298, 299, 0, 0, 300, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, 313, 0, 314, + 0, 315, 316, 317, 318, 319, 320, 321, 322, 323, + 0, 324, 325, 0, 326, 0, 327, 328, 329, 330, + 331, 0, 0, 332, 0, 0, 0, 333, 334, 0, + 0, 335, 0, 0, 336, 337, 338, 339, 340, 341, + 0, 342, 343, 344, 345, 346, 347, 0, 348, 349, + 350, 351, 352, 353, 354, 355, 356, 0, 357, 358, + 359, 360, 361, 362, 363, 364, 365, 366, 0, 367, + 368, 0, 369, 370, 371, 372, 373, 374, 375, 376, + 377, 378, 379, 0, 380, 381, 382, 0, 383, 384, + 385, 386, 0, 387, 388, 0, 389, 390, 391, 392, + 393, 394, 395, 396, 397, 398, 399, 400, 0, 401, + 402, 0, 403, 404, 405, 406, 407, 0, 408, 409, + 0, 0, 410, 411, 412, 413, 0, 414, 415, 416, + 417, 418, 0, 0, 419, 420, 421, 422, 0, 0, + 423, 424, 425, 426, 427, 428, 429, 0, 430, 431, + 432, 0, 0, 433, 434, 435, 436, 437, 438, 439, + 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, + 0, 0, 0, 0, 0, 450, 171, 172, 173, 174, + 175, 176, 177, 178, 0, 180, 181, 182, 0, 608, + 0, 0, 0, 0, 0, 183, 184, 0, 185, 632, + 186, 187, 188, 633, 1190, 634, 1191, 1192, 0, 192, + 193, 194, 195, 196, 0, 0, 197, 1193, 1194, 200, + 0, 201, 202, 203, 204, 0, 0, 0, 206, 207, + 208, 209, 210, 211, 0, 212, 213, 214, 215, 216, + 0, 217, 218, 219, 635, 220, 221, 0, 0, 0, + 0, 0, 222, 223, 224, 225, 226, 1195, 1196, 229, + 0, 230, 0, 231, 232, 233, 234, 235, 0, 236, + 237, 238, 0, 0, 239, 240, 857, 242, 243, 0, + 244, 245, 246, 0, 247, 248, 0, 249, 250, 251, + 0, 253, 254, 0, 0, 256, 257, 258, 1197, 0, + 260, 0, 261, 636, 0, 637, 262, 263, 0, 264, + 0, 0, 266, 0, 267, 268, 269, 270, 638, 271, + 272, 273, 0, 274, 275, 276, 277, 278, 279, 0, + 639, 0, 281, 282, 283, 284, 1198, 1199, 0, 1200, + 0, 288, 640, 641, 289, 642, 290, 291, 292, 293, + 294, 0, 0, 643, 296, 644, 0, 297, 298, 299, + 0, 0, 300, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 1201, 645, 1202, 0, 315, + 316, 317, 318, 319, 320, 321, 0, 323, 0, 324, + 325, 646, 326, 0, 0, 328, 1203, 330, 331, 0, + 0, 332, 0, 0, 0, 333, 334, 0, 0, 0, + 647, 648, 0, 337, 338, 339, 340, 341, 0, 342, + 0, 0, 345, 346, 347, 0, 348, 349, 350, 351, + 352, 353, 1204, 355, 356, 0, 357, 358, 359, 360, + 361, 362, 363, 364, 365, 366, 0, 367, 368, 649, + 369, 370, 0, 372, 373, 374, 375, 376, 377, 378, + 379, 0, 380, 381, 382, 0, 383, 1205, 385, 386, + 650, 387, 1206, 0, 389, 390, 391, 392, 393, 394, + 395, 396, 397, 398, 0, 400, 0, 401, 402, 0, + 403, 404, 405, 406, 407, 0, 1207, 1208, 0, 0, + 410, 0, 412, 0, 0, 414, 415, 416, 417, 418, + 0, 0, 419, 420, 421, 422, 0, 0, 423, 424, + 425, 426, 0, 1209, 429, 651, 430, 431, 432, 0, + 0, 433, 434, 435, 436, 437, 438, 0, 0, 0, + 0, 0, 0, 0, 0, 447, 448, 449, 0, 0, + 0, 0, 0, 1210, 171, 172, 173, 174, 175, 176, + 177, 178, 0, 180, 181, 182, 0, 1523, 0, 0, + 0, 0, 0, 183, 184, 0, 185, 632, 186, 187, + 188, 633, 1190, 634, 1191, 1192, 0, 192, 193, 194, + 195, 196, 0, 0, 197, 1193, 1194, 200, 0, 201, + 202, 203, 204, 0, 0, 0, 206, 207, 208, 209, + 210, 211, 0, 212, 213, 214, 215, 216, 0, 217, + 218, 219, 635, 220, 221, 0, 0, 0, 0, 0, + 222, 223, 224, 225, 226, 1195, 1196, 229, 0, 230, + 0, 231, 232, 233, 234, 235, 0, 236, 237, 238, + 0, 0, 239, 240, 857, 242, 243, 0, 244, 245, + 246, 0, 247, 248, 0, 249, 250, 251, 0, 253, + 254, 0, 0, 256, 257, 258, 1197, 0, 260, 0, + 261, 636, 0, 637, 262, 263, 0, 264, 0, 0, + 266, 0, 267, 268, 269, 270, 638, 271, 272, 273, + 0, 274, 275, 276, 277, 278, 279, 0, 639, 0, + 281, 282, 283, 284, 1198, 1199, 0, 1200, 0, 288, + 640, 641, 289, 642, 290, 291, 292, 293, 294, 0, + 0, 643, 296, 644, 0, 297, 298, 299, 0, 0, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 1201, 645, 1202, 0, 315, 316, 317, + 318, 319, 320, 321, 0, 323, 0, 324, 325, 646, + 326, 0, 0, 328, 1203, 330, 331, 0, 0, 332, + 0, 0, 0, 333, 334, 0, 0, 0, 647, 648, + 0, 337, 338, 339, 340, 341, 0, 342, 0, 0, + 345, 346, 347, 0, 348, 349, 350, 351, 352, 353, + 1204, 355, 356, 0, 357, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 0, 367, 368, 649, 369, 370, + 0, 372, 373, 374, 375, 376, 377, 378, 379, 0, + 380, 381, 382, 0, 383, 1205, 385, 386, 650, 387, + 1206, 0, 389, 390, 391, 392, 393, 394, 395, 396, + 397, 398, 0, 400, 0, 401, 402, 0, 403, 404, + 405, 406, 407, 0, 1207, 1208, 0, 0, 410, 0, + 412, 0, 0, 414, 415, 416, 417, 418, 0, 0, + 419, 420, 421, 422, 0, 0, 423, 424, 425, 426, + 0, 1209, 429, 651, 430, 431, 432, 0, 0, 433, + 434, 435, 436, 437, 438, 0, 0, 0, 0, 0, + 0, 0, 0, 447, 448, 449, 0, 0, 0, 0, + 0, 1669, 171, 172, 173, 174, 175, 176, 177, 178, + 0, 180, 181, 182, 0, 1523, 0, 0, 0, 0, + 0, 183, 184, 0, 185, 0, 186, 187, 188, 0, + 189, 0, 190, 191, 0, 192, 193, 194, 195, 196, + 0, 0, 197, 198, 199, 200, 0, 201, 202, 203, + 204, 205, 0, 0, 206, 207, 208, 209, 210, 211, + 0, 212, 213, 214, 215, 216, 0, 217, 218, 219, + 0, 220, 221, 0, 0, 0, 0, 0, 222, 223, + 224, 225, 226, 227, 228, 229, 1473, 230, 0, 231, + 232, 233, 234, 235, 0, 236, 237, 238, 0, 0, + 239, 240, 241, 242, 243, 0, 244, 245, 246, 0, + 247, 248, 0, 249, 250, 251, 252, 253, 254, 255, + 1474, 256, 257, 258, 259, 0, 260, 0, 261, 0, + 0, 0, 262, 263, 0, 264, 265, 0, 266, 0, + 267, 268, 269, 270, 0, 271, 272, 273, 0, 274, + 275, 276, 277, 278, 279, 0, 0, 280, 281, 282, + 283, 284, 285, 286, 0, 287, 0, 288, 0, 0, + 289, 0, 290, 291, 292, 293, 294, 0, 295, 0, + 296, 0, 0, 297, 298, 299, 0, 0, 300, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 313, 0, 314, 0, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 0, 324, 325, 0, 326, 0, + 327, 328, 329, 330, 331, 1475, 0, 332, 0, 1476, + 0, 333, 334, 0, 0, 335, 0, 0, 336, 337, + 338, 339, 340, 341, 0, 342, 343, 344, 345, 346, + 347, 0, 348, 349, 350, 351, 352, 353, 354, 355, + 356, 0, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 0, 367, 368, 0, 369, 370, 371, 372, + 373, 374, 375, 376, 377, 378, 379, 0, 380, 381, + 382, 0, 383, 384, 385, 386, 0, 387, 388, 0, + 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, + 399, 400, 0, 401, 402, 0, 403, 404, 405, 406, + 407, 0, 408, 409, 0, 0, 410, 411, 412, 413, + 1477, 414, 415, 416, 417, 418, 0, 0, 419, 420, + 421, 422, 0, 0, 423, 424, 425, 426, 427, 428, + 429, 0, 430, 431, 432, 0, 0, 433, 434, 435, + 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, + 446, 447, 448, 449, 0, 0, 0, 0, 0, 450, + 1460, 942, 0, 0, 0, 542, 0, 0, 0, 0, + 0, 0, 1461, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 1483, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 1474, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 1475, 0, 332, 0, + 1476, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 1477, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 1460, 942, 0, 0, 0, 542, 0, 0, 0, + 0, 0, 0, 1461, 171, 172, 173, 174, 175, 176, + 177, 178, 0, 180, 181, 182, 0, 0, 0, 0, + 0, 0, 0, 183, 184, 0, 185, 0, 186, 187, + 188, 0, 189, 0, 190, 191, 0, 192, 193, 194, + 195, 196, 0, 0, 197, 198, 199, 200, 0, 201, + 202, 203, 204, 205, 0, 0, 206, 207, 208, 209, + 210, 211, 0, 212, 213, 214, 215, 216, 0, 217, + 218, 219, 0, 220, 221, 0, 0, 0, 0, 0, + 222, 223, 224, 225, 226, 227, 228, 229, 0, 230, + 0, 231, 232, 233, 234, 235, 0, 236, 237, 238, + 0, 0, 239, 240, 241, 242, 243, 0, 244, 245, + 246, 0, 247, 248, 0, 249, 250, 251, 252, 253, + 254, 255, 1474, 256, 257, 258, 259, 0, 260, 0, + 261, 0, 0, 0, 262, 263, 0, 264, 265, 0, + 266, 0, 267, 268, 269, 270, 0, 271, 272, 273, + 0, 274, 275, 276, 277, 278, 279, 0, 0, 280, + 281, 282, 283, 284, 285, 286, 0, 287, 0, 288, + 0, 0, 289, 0, 290, 291, 292, 293, 294, 0, + 295, 0, 296, 0, 0, 297, 298, 299, 0, 0, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 0, 314, 0, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 0, 324, 325, 0, + 326, 0, 327, 328, 329, 330, 331, 1475, 0, 332, + 0, 1476, 0, 333, 334, 0, 0, 335, 0, 0, + 336, 337, 338, 339, 340, 341, 0, 342, 343, 344, + 345, 346, 347, 0, 348, 349, 350, 351, 352, 353, + 354, 355, 356, 0, 357, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 0, 367, 368, 0, 369, 370, + 371, 372, 373, 374, 375, 376, 377, 378, 379, 0, + 380, 381, 382, 0, 383, 384, 385, 386, 0, 387, + 388, 0, 389, 390, 391, 392, 393, 394, 395, 396, + 397, 398, 399, 400, 0, 401, 402, 0, 403, 404, + 405, 406, 407, 0, 408, 409, 0, 0, 410, 411, + 412, 413, 1477, 414, 415, 416, 417, 418, 0, 0, + 419, 420, 421, 422, 0, 0, 423, 424, 425, 426, + 427, 428, 429, 0, 430, 431, 432, 0, 0, 433, + 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, + 444, 445, 446, 447, 448, 449, 0, 0, 0, 0, + 0, 450, 1460, 942, 0, 0, 0, 542, 0, 0, + 0, 0, 0, 0, 1461, 171, 533, 173, 174, 175, + 176, 177, 178, 534, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 535, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 536, 259, 0, 260, + 0, 537, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 538, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 539, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 540, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 541, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 1414, 423, 424, 425, + 426, 427, 428, 429, 1416, 430, 431, 432, 0, 1417, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 1414, 0, 0, + 0, 0, 450, 0, 0, 1416, 0, 0, 542, 0, + 1417, 0, 0, 0, 0, 543, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1418, 0, 0, 0, 1419, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1420, 1421, + 0, 0, 0, 0, 0, 1418, 0, 0, 0, 1419, + 0, 1422, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1420, + 1421, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1422, 0, 1423, 0, 0, 1424, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1425, 0, 1426, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1423, 0, 0, 1424, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1425, 0, 1426, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1427, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1427, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1428, 0, 0, 1429, 1430, 1431, + 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, 0, + 0, 3190, 1438, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1428, 0, 0, 1429, 1430, + 1431, 0, 1432, 1433, 1434, 1435, 1436, 1437, 0, 0, + 0, 0, 0, 1438, 171, 172, 173, 174, 175, 176, + 177, 178, 0, 180, 181, 182, 0, 0, 0, 0, + 0, 0, 0, 183, 184, 0, 185, 0, 186, 187, + 188, 0, 189, 0, 190, 191, 0, 192, 193, 194, + 195, 196, 0, 0, 197, 198, 199, 200, 0, 201, + 202, 203, 204, 205, 0, 0, 206, 207, 208, 209, + 210, 211, 0, 212, 213, 214, 215, 216, 0, 217, + 218, 219, 0, 220, 221, 0, 0, 0, 0, 0, + 222, 223, 224, 225, 226, 227, 228, 229, 0, 230, + 0, 231, 232, 233, 234, 235, 0, 236, 237, 238, + 0, 0, 239, 240, 241, 242, 243, 0, 244, 245, + 246, 0, 247, 248, 0, 249, 250, 251, 252, 253, + 254, 255, 0, 256, 257, 258, 259, 0, 260, 0, + 261, 0, 0, 0, 262, 263, 0, 264, 265, 0, + 266, 0, 267, 268, 269, 270, 0, 271, 272, 273, + 0, 274, 275, 276, 277, 278, 279, 0, 0, 280, + 281, 282, 283, 284, 285, 286, 0, 287, 0, 288, + 0, 0, 289, 0, 290, 291, 292, 293, 294, 0, + 295, 0, 296, 0, 0, 297, 298, 299, 0, 0, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 0, 314, 0, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 0, 324, 325, 0, + 326, 0, 327, 328, 329, 330, 331, 0, 0, 332, + 0, 0, 0, 333, 334, 0, 0, 335, 0, 0, + 336, 337, 338, 339, 340, 341, 0, 342, 343, 344, + 345, 346, 347, 0, 348, 349, 350, 351, 352, 353, + 354, 355, 356, 0, 357, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 0, 367, 368, 0, 369, 370, + 371, 372, 373, 374, 375, 376, 377, 378, 379, 0, + 380, 381, 382, 0, 383, 384, 385, 386, 0, 387, + 388, 0, 389, 390, 391, 392, 393, 394, 395, 396, + 397, 398, 399, 400, 0, 401, 402, 0, 403, 404, + 405, 406, 407, 0, 408, 409, 0, 0, 410, 411, + 412, 413, 0, 414, 415, 416, 417, 418, 0, 0, + 419, 420, 421, 422, 0, 0, 423, 424, 425, 426, + 427, 428, 429, 0, 430, 431, 432, 0, 0, 433, + 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, + 444, 445, 446, 447, 448, 449, 0, 0, 0, 0, + 0, 450, 0, 0, 0, 0, 0, 0, 2898, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 3238, 557, 3239, + 3240, 0, 3241, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 1454, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 0, 942, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 0, 942, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 1297, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 0, 942, 171, 172, 173, 174, 175, 176, 177, + 178, 1081, 180, 181, 182, 1082, 1083, 1084, 1085, 1086, + 1087, 1088, 183, 184, 1089, 185, 632, 186, 187, 188, + 633, 189, 634, 190, 191, 1090, 192, 193, 194, 195, + 196, 1091, 1092, 197, 198, 199, 200, 1093, 201, 202, + 203, 204, 205, 1094, 1095, 206, 207, 208, 209, 210, + 211, 1096, 212, 213, 214, 215, 216, 1097, 217, 218, + 219, 635, 220, 221, 1098, 1099, 1100, 1101, 1102, 222, + 223, 224, 225, 226, 227, 228, 229, 1103, 230, 1104, + 231, 232, 233, 234, 235, 1105, 236, 237, 238, 1106, + 1107, 239, 240, 241, 242, 243, 1108, 244, 245, 246, + 1109, 247, 248, 1110, 249, 250, 251, 252, 253, 254, + 255, 1111, 256, 257, 258, 259, 1112, 260, 1113, 261, + 636, 1114, 637, 262, 263, 1115, 264, 265, 1116, 266, + 1117, 267, 268, 269, 270, 638, 271, 272, 273, 1118, + 274, 275, 276, 277, 278, 279, 1119, 639, 280, 281, + 282, 283, 284, 285, 286, 1120, 287, 1121, 288, 640, + 641, 289, 642, 290, 291, 292, 293, 294, 1122, 295, + 643, 296, 644, 1123, 297, 298, 299, 1124, 1125, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 645, 314, 1126, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 1127, 324, 325, 646, 326, + 1128, 327, 328, 329, 330, 331, 1129, 1130, 332, 1131, + 1132, 1133, 333, 334, 1134, 1135, 335, 647, 648, 336, + 337, 338, 339, 340, 341, 1136, 342, 343, 344, 345, + 346, 347, 1137, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 1138, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 1139, 367, 368, 649, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 1140, 380, + 381, 382, 1141, 383, 384, 385, 386, 650, 387, 388, + 1142, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 1143, 401, 402, 1144, 403, 404, 405, + 406, 407, 1145, 408, 409, 1146, 1147, 410, 411, 412, + 413, 1148, 414, 415, 416, 417, 418, 1149, 1150, 419, + 420, 421, 422, 1151, 1152, 423, 424, 425, 426, 427, + 428, 429, 651, 430, 431, 432, 1153, 1154, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 1155, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 189, + 634, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 295, 643, 296, + 644, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 645, 314, 455, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 646, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 456, 0, 0, + 333, 334, 0, 0, 335, 647, 648, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 650, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 652, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 632, 186, 187, 188, 633, 189, 634, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 635, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 636, 0, 637, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 769, 638, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 639, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 640, 641, 289, 642, 290, + 291, 292, 293, 294, 0, 295, 643, 296, 644, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 645, + 314, 455, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 646, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 456, 0, 0, 333, 334, + 0, 0, 335, 647, 648, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 649, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 650, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 651, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 652, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 632, 186, 187, 188, 633, 189, 634, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 635, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 636, 0, 637, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 776, 638, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 639, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 640, 641, 289, 642, 290, 291, 292, + 293, 294, 0, 295, 643, 296, 644, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 645, 314, 455, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 646, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 456, 0, 0, 333, 334, 0, 0, + 335, 647, 648, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 649, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 650, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 651, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 652, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 1536, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 1537, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 1538, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 2195, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 1539, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 1540, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 581, 177, + 178, 547, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 548, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 582, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 549, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 550, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 547, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 548, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 549, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 550, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 3, 4, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 455, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 456, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 270, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 455, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 456, 0, 610, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 934, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 455, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 456, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 1313, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 1314, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 1315, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 455, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 456, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 1316, 376, 377, 378, 379, 0, 1317, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 1318, 1319, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 548, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 549, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 550, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 1939, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 1940, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 455, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 456, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 1941, 403, 1942, 405, 1943, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 270, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 455, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 456, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 2078, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 2079, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 2088, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 2089, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 496, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 497, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 575, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 270, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 0, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 576, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 577, 409, 0, + 0, 578, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 601, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 602, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 603, 409, 0, 0, 604, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 765, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 945, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 946, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 593, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 594, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 937, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 596, 409, 0, 0, 597, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 598, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 2226, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 2239, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 270, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 0, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 2265, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 2828, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 2830, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 2832, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 270, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 0, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 3141, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 270, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 270, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 565, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 573, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 591, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 592, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 593, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 594, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 595, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 596, + 409, 0, 0, 597, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 598, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 774, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 0, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 778, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 786, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 788, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 790, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 793, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 0, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 795, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 798, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 593, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 594, 370, 371, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 937, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 596, 409, 0, 0, 597, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 598, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 961, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 369, 370, 371, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 0, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 408, + 409, 0, 0, 410, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 0, 186, 187, 188, 0, 189, 0, 190, 191, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 198, 199, + 200, 0, 201, 202, 203, 204, 205, 0, 0, 206, + 207, 208, 1256, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 0, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 227, 228, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 241, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 252, 253, 254, 255, 0, 256, 257, 258, 259, + 0, 260, 0, 261, 0, 0, 0, 262, 263, 0, + 264, 265, 0, 266, 0, 267, 268, 269, 270, 0, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 0, 280, 281, 282, 283, 284, 285, 286, 0, + 287, 0, 288, 0, 0, 289, 0, 290, 291, 292, + 293, 294, 0, 295, 0, 296, 0, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 0, 314, 0, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 0, + 324, 325, 0, 326, 0, 327, 328, 329, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 335, 0, 0, 336, 337, 338, 339, 340, 341, 0, + 342, 343, 344, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 384, 385, + 386, 0, 387, 388, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 408, 409, 0, + 0, 410, 411, 412, 413, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 427, 428, 429, 0, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 439, 440, + 441, 442, 443, 444, 445, 446, 447, 448, 449, 0, + 0, 0, 0, 0, 450, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 0, 186, + 187, 188, 0, 189, 0, 190, 191, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 198, 199, 200, 0, + 201, 202, 203, 204, 205, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 0, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 227, 228, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 241, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 252, + 253, 254, 255, 0, 256, 257, 258, 259, 0, 260, + 0, 261, 0, 0, 0, 262, 263, 0, 264, 265, + 0, 266, 0, 267, 268, 269, 1279, 0, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 0, + 280, 281, 282, 283, 284, 285, 286, 0, 287, 0, + 288, 0, 0, 289, 0, 290, 291, 292, 293, 294, + 0, 295, 0, 296, 0, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 313, 0, 314, 0, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 0, 324, 325, + 0, 326, 0, 327, 328, 329, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 335, 0, + 0, 336, 337, 338, 339, 340, 341, 0, 342, 343, + 344, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 0, 369, + 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 384, 385, 386, 0, + 387, 388, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 399, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 408, 409, 0, 0, 410, + 411, 412, 413, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 427, 428, 429, 0, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 0, 0, 0, + 0, 0, 450, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 0, 186, 187, 188, + 0, 189, 0, 190, 191, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 198, 199, 200, 0, 201, 202, + 203, 204, 205, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 0, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 227, 228, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 241, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 252, 253, 254, + 255, 0, 256, 257, 258, 259, 0, 260, 0, 261, + 0, 0, 0, 262, 263, 0, 264, 265, 0, 266, + 0, 267, 268, 269, 1281, 0, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 0, 280, 281, + 282, 283, 284, 285, 286, 0, 287, 0, 288, 0, + 0, 289, 0, 290, 291, 292, 293, 294, 0, 295, + 0, 296, 0, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 0, 314, 0, 315, 316, 317, 318, + 319, 320, 321, 322, 323, 0, 324, 325, 0, 326, + 0, 327, 328, 329, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 335, 0, 0, 336, + 337, 338, 339, 340, 341, 0, 342, 343, 344, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 354, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 0, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 384, 385, 386, 0, 387, 388, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 408, 409, 0, 0, 410, 411, 412, + 413, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 427, + 428, 429, 0, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, + 445, 446, 447, 448, 449, 0, 0, 0, 0, 0, + 450, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 0, 186, 187, 188, 0, 189, + 0, 190, 191, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 198, 199, 200, 0, 201, 202, 203, 204, + 205, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 0, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 227, 228, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 241, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 252, 253, 254, 255, 0, + 256, 257, 258, 259, 0, 260, 0, 261, 0, 0, + 0, 262, 263, 0, 264, 265, 0, 266, 0, 267, + 268, 269, 270, 0, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 0, 280, 281, 282, 283, + 284, 285, 286, 0, 287, 0, 288, 0, 0, 289, + 0, 290, 291, 292, 293, 294, 0, 295, 0, 296, + 0, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 0, 314, 0, 315, 316, 317, 318, 319, 320, + 321, 322, 323, 0, 324, 325, 0, 326, 0, 327, + 328, 329, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 335, 0, 0, 336, 337, 338, + 339, 340, 341, 0, 342, 343, 344, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 354, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 0, 369, 370, 371, 372, 373, + 1346, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 384, 385, 386, 0, 387, 388, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 408, 409, 0, 0, 410, 411, 412, 413, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 427, 428, 429, + 0, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, + 447, 448, 449, 0, 0, 0, 0, 0, 450, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 0, 186, 187, 188, 0, 189, 0, 190, + 191, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 198, 199, 200, 0, 201, 202, 203, 204, 205, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 0, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 227, 228, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 241, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 252, 253, 254, 255, 0, 256, 257, + 258, 259, 0, 260, 0, 261, 0, 0, 0, 262, + 263, 0, 264, 265, 0, 266, 0, 267, 268, 269, + 270, 0, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 0, 280, 281, 282, 283, 284, 285, + 286, 0, 287, 0, 288, 0, 0, 289, 0, 290, + 291, 292, 293, 294, 0, 295, 0, 296, 0, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 593, 313, 0, + 314, 0, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 0, 324, 325, 0, 326, 0, 327, 328, 329, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 335, 0, 0, 336, 337, 338, 339, 340, + 341, 0, 342, 343, 344, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 354, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 0, 594, 370, 371, 372, 373, 374, 1559, + 376, 377, 378, 379, 0, 380, 381, 937, 0, 383, + 384, 385, 386, 0, 387, 388, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 596, + 409, 0, 0, 597, 411, 412, 413, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 427, 428, 429, 0, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 598, + 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, + 449, 0, 0, 0, 0, 0, 450, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 632, 186, 187, 188, 633, 1190, 634, 1191, 1192, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 1193, 1194, + 200, 0, 201, 202, 203, 204, 0, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 635, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 1195, 1196, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 857, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 0, 253, 254, 0, 0, 256, 257, 258, 1197, + 0, 260, 0, 261, 636, 0, 637, 262, 263, 0, + 264, 0, 0, 266, 0, 267, 268, 269, 270, 638, + 271, 272, 273, 1563, 274, 275, 276, 277, 278, 279, + 0, 639, 1564, 281, 282, 283, 284, 1198, 1199, 0, + 1200, 0, 288, 640, 641, 289, 642, 290, 291, 292, + 293, 294, 0, 0, 643, 296, 644, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 1201, 645, 1202, 0, + 315, 316, 317, 318, 319, 320, 321, 0, 323, 0, + 324, 325, 646, 326, 0, 0, 328, 1203, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 1565, 647, 648, 0, 337, 338, 339, 340, 341, 0, + 342, 0, 0, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 1204, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 649, 369, 370, 0, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 1566, 385, + 386, 650, 387, 1206, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 0, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 1207, 1208, 0, + 0, 410, 0, 412, 0, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 0, 1209, 429, 651, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 0, 0, + 0, 0, 0, 0, 0, 0, 447, 448, 449, 0, + 0, 0, 0, 0, 1210, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 632, 186, + 187, 188, 633, 1190, 634, 1191, 1192, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 1193, 1194, 200, 0, + 201, 202, 203, 204, 0, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 635, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 1195, 1196, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 857, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 0, + 253, 254, 0, 0, 256, 257, 258, 1197, 0, 260, + 0, 261, 636, 0, 637, 262, 263, 0, 264, 0, + 0, 266, 0, 267, 268, 269, 270, 638, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 639, + 0, 281, 282, 283, 284, 1198, 1199, 0, 1200, 0, + 288, 640, 641, 289, 642, 290, 291, 292, 293, 294, + 0, 0, 643, 296, 644, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 1201, 645, 1202, 0, 315, 316, + 317, 318, 319, 320, 321, 1585, 323, 0, 324, 325, + 646, 326, 0, 0, 328, 1203, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 0, 647, + 648, 0, 337, 338, 339, 340, 341, 0, 342, 0, + 0, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 1204, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 649, 369, + 370, 0, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 1205, 385, 386, 650, + 387, 1206, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 0, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 1207, 1208, 0, 0, 410, + 0, 412, 0, 0, 414, 415, 416, 417, 418, 0, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 0, 1209, 429, 651, 430, 431, 432, 0, 0, + 433, 434, 435, 436, 437, 438, 0, 0, 0, 0, + 0, 0, 0, 0, 447, 448, 449, 0, 0, 0, + 0, 0, 1210, 171, 172, 173, 174, 175, 176, 177, + 178, 0, 180, 181, 182, 0, 0, 0, 0, 0, + 0, 0, 183, 184, 0, 185, 632, 186, 187, 188, + 633, 1190, 634, 1191, 1192, 0, 192, 193, 194, 195, + 196, 0, 0, 197, 1193, 1194, 200, 0, 201, 202, + 203, 204, 0, 0, 0, 206, 207, 208, 209, 210, + 211, 0, 212, 213, 214, 215, 216, 0, 217, 218, + 219, 635, 220, 221, 0, 0, 0, 0, 0, 222, + 223, 224, 225, 226, 1195, 1196, 229, 0, 230, 0, + 231, 232, 233, 234, 235, 0, 236, 237, 238, 0, + 0, 239, 240, 857, 242, 243, 0, 244, 245, 246, + 0, 247, 248, 0, 249, 250, 251, 0, 253, 254, + 0, 0, 256, 257, 258, 1197, 0, 260, 0, 261, + 636, 0, 637, 262, 263, 0, 264, 0, 0, 266, + 0, 267, 268, 269, 270, 638, 271, 272, 273, 0, + 274, 275, 276, 277, 278, 279, 0, 639, 0, 281, + 282, 283, 284, 1198, 1199, 0, 1200, 0, 288, 640, + 641, 289, 642, 290, 291, 292, 293, 294, 0, 0, + 643, 296, 644, 0, 297, 298, 299, 0, 0, 300, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 1201, 645, 1202, 0, 315, 316, 317, 318, + 319, 320, 321, 2451, 323, 0, 324, 325, 646, 326, + 0, 0, 328, 1203, 330, 331, 0, 0, 332, 0, + 0, 0, 333, 334, 0, 0, 0, 647, 648, 0, + 337, 338, 339, 340, 341, 0, 342, 0, 0, 345, + 346, 347, 0, 348, 349, 350, 351, 352, 353, 1204, + 355, 356, 0, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 0, 367, 368, 649, 369, 370, 0, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 380, + 381, 382, 0, 383, 1205, 385, 386, 650, 387, 1206, + 0, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 0, 400, 0, 401, 402, 0, 403, 404, 405, + 406, 407, 0, 1207, 1208, 0, 0, 410, 0, 412, + 0, 0, 414, 415, 416, 417, 418, 0, 0, 419, + 420, 421, 422, 0, 0, 423, 424, 425, 426, 0, + 1209, 429, 651, 430, 431, 432, 0, 0, 433, 434, + 435, 436, 437, 438, 0, 0, 0, 0, 0, 0, + 0, 0, 447, 448, 449, 0, 0, 0, 0, 0, + 1210, 171, 172, 173, 174, 175, 176, 177, 178, 0, + 180, 181, 182, 0, 0, 0, 0, 0, 0, 0, + 183, 184, 0, 185, 632, 186, 187, 188, 633, 1190, + 634, 1191, 1192, 0, 192, 193, 194, 195, 196, 0, + 0, 197, 1193, 1194, 200, 0, 201, 202, 203, 204, + 0, 0, 0, 206, 207, 208, 209, 210, 211, 0, + 212, 213, 214, 215, 216, 0, 217, 218, 219, 635, + 220, 221, 0, 0, 0, 0, 0, 222, 223, 224, + 225, 226, 1195, 1196, 229, 0, 230, 0, 231, 232, + 233, 234, 235, 0, 236, 237, 238, 0, 0, 239, + 240, 857, 242, 243, 0, 244, 245, 246, 0, 247, + 248, 0, 249, 250, 251, 0, 253, 254, 0, 0, + 256, 257, 258, 1197, 0, 260, 0, 261, 636, 0, + 637, 262, 263, 0, 264, 0, 0, 266, 0, 267, + 268, 269, 270, 638, 271, 272, 273, 0, 274, 275, + 276, 277, 278, 279, 0, 639, 0, 281, 282, 283, + 284, 1198, 1199, 0, 1200, 0, 288, 640, 641, 289, + 642, 290, 291, 292, 293, 294, 0, 0, 643, 296, + 644, 0, 297, 298, 299, 0, 0, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 1201, 645, 1202, 0, 315, 316, 317, 318, 319, 320, + 321, 0, 323, 0, 324, 325, 646, 326, 1555, 0, + 328, 1203, 330, 331, 0, 0, 332, 0, 0, 0, + 333, 334, 0, 0, 0, 647, 648, 0, 337, 338, + 339, 340, 341, 0, 342, 0, 0, 345, 346, 347, + 0, 348, 349, 350, 351, 352, 353, 1204, 355, 356, + 0, 357, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 0, 367, 368, 649, 369, 370, 0, 372, 373, + 374, 375, 376, 377, 378, 379, 0, 380, 381, 382, + 0, 383, 1566, 385, 386, 650, 387, 1206, 0, 389, + 390, 391, 392, 393, 394, 395, 396, 397, 398, 0, + 400, 0, 401, 402, 0, 403, 404, 405, 406, 407, + 0, 1207, 1208, 0, 0, 410, 0, 412, 0, 0, + 414, 415, 416, 417, 418, 0, 0, 419, 420, 421, + 422, 0, 0, 423, 424, 425, 426, 0, 1209, 429, + 651, 430, 431, 432, 0, 0, 433, 434, 435, 436, + 437, 438, 0, 0, 0, 0, 0, 0, 0, 0, + 447, 448, 449, 0, 0, 0, 0, 0, 1210, 171, + 172, 173, 174, 175, 176, 177, 178, 0, 180, 181, + 182, 0, 0, 0, 0, 0, 0, 0, 183, 184, + 0, 185, 632, 186, 187, 188, 633, 1190, 634, 1191, + 1192, 0, 192, 193, 194, 195, 196, 0, 0, 197, + 1193, 1194, 200, 0, 201, 202, 203, 204, 0, 0, + 0, 206, 207, 208, 209, 210, 211, 0, 212, 213, + 214, 215, 216, 0, 217, 218, 219, 635, 220, 221, + 0, 0, 0, 0, 0, 222, 223, 224, 225, 226, + 1195, 1196, 229, 0, 230, 0, 231, 232, 233, 234, + 235, 0, 236, 237, 238, 0, 0, 239, 240, 857, + 242, 243, 0, 244, 245, 246, 0, 247, 248, 0, + 249, 250, 251, 0, 253, 254, 0, 0, 256, 257, + 258, 1197, 0, 260, 0, 261, 636, 0, 637, 262, + 263, 0, 264, 0, 0, 266, 0, 267, 268, 269, + 270, 638, 271, 272, 273, 0, 274, 275, 276, 277, + 278, 279, 0, 639, 0, 281, 282, 283, 284, 1198, + 1199, 0, 1200, 0, 288, 640, 641, 289, 642, 290, + 291, 292, 293, 294, 0, 0, 643, 296, 644, 0, + 297, 298, 299, 0, 0, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 1201, 645, + 1202, 0, 315, 316, 317, 318, 319, 320, 321, 0, + 323, 0, 324, 325, 646, 326, 0, 0, 328, 1203, + 330, 331, 0, 0, 332, 0, 0, 0, 333, 334, + 0, 0, 0, 647, 648, 0, 337, 338, 339, 340, + 341, 0, 342, 0, 0, 345, 346, 347, 0, 348, + 349, 350, 351, 352, 353, 1204, 355, 356, 0, 357, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 0, + 367, 368, 649, 369, 370, 0, 372, 373, 374, 375, + 376, 377, 378, 379, 0, 380, 381, 382, 0, 383, + 1205, 385, 386, 650, 387, 1206, 0, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 0, 400, 0, + 401, 402, 0, 403, 404, 405, 406, 407, 0, 1207, + 1208, 0, 0, 410, 0, 412, 0, 0, 414, 415, + 416, 417, 418, 0, 0, 419, 420, 421, 422, 0, + 0, 423, 424, 425, 426, 0, 1209, 429, 651, 430, + 431, 432, 0, 0, 433, 434, 435, 436, 437, 438, + 0, 0, 0, 0, 0, 0, 0, 0, 447, 448, + 449, 0, 0, 0, 0, 0, 1210, 171, 172, 173, + 174, 175, 176, 177, 178, 0, 180, 181, 182, 0, + 0, 0, 0, 0, 0, 0, 183, 184, 0, 185, + 632, 186, 187, 188, 633, 1190, 634, 1191, 1192, 0, + 192, 193, 194, 195, 196, 0, 0, 197, 1193, 1194, + 200, 0, 201, 202, 203, 204, 0, 0, 0, 206, + 207, 208, 209, 210, 211, 0, 212, 213, 214, 215, + 216, 0, 217, 218, 219, 635, 220, 221, 0, 0, + 0, 0, 0, 222, 223, 224, 225, 226, 1195, 1196, + 229, 0, 230, 0, 231, 232, 233, 234, 235, 0, + 236, 237, 238, 0, 0, 239, 240, 857, 242, 243, + 0, 244, 245, 246, 0, 247, 248, 0, 249, 250, + 251, 0, 253, 254, 0, 0, 256, 257, 258, 1197, + 0, 260, 0, 261, 636, 0, 637, 262, 263, 0, + 264, 0, 0, 266, 0, 267, 268, 269, 270, 638, + 271, 272, 273, 0, 274, 275, 276, 277, 278, 279, + 0, 639, 0, 281, 282, 283, 284, 1198, 1199, 0, + 1200, 0, 288, 640, 641, 289, 642, 290, 291, 292, + 293, 294, 0, 0, 643, 296, 644, 0, 297, 298, + 299, 0, 0, 300, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 1201, 645, 1202, 0, + 315, 316, 317, 318, 319, 320, 321, 0, 323, 0, + 324, 325, 646, 326, 0, 0, 328, 1203, 330, 331, + 0, 0, 332, 0, 0, 0, 333, 334, 0, 0, + 0, 647, 648, 0, 337, 338, 339, 340, 341, 0, + 342, 0, 0, 345, 346, 347, 0, 348, 349, 350, + 351, 352, 353, 1204, 355, 356, 0, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 0, 367, 368, + 649, 369, 370, 0, 372, 373, 374, 375, 376, 377, + 378, 379, 0, 380, 381, 382, 0, 383, 1566, 385, + 386, 650, 387, 1206, 0, 389, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 0, 400, 0, 401, 402, + 0, 403, 404, 405, 406, 407, 0, 1207, 1208, 0, + 0, 410, 0, 412, 0, 0, 414, 415, 416, 417, + 418, 0, 0, 419, 420, 421, 422, 0, 0, 423, + 424, 425, 426, 0, 1209, 429, 651, 430, 431, 432, + 0, 0, 433, 434, 435, 436, 437, 438, 0, 0, + 0, 0, 0, 0, 0, 0, 447, 448, 449, 0, + 0, 0, 0, 0, 1210, 171, 172, 173, 174, 175, + 176, 177, 178, 0, 180, 181, 182, 0, 0, 0, + 0, 0, 0, 0, 183, 184, 0, 185, 632, 186, + 187, 188, 633, 1190, 634, 1191, 1192, 0, 192, 193, + 194, 195, 196, 0, 0, 197, 1193, 1194, 200, 0, + 201, 202, 203, 204, 0, 0, 0, 206, 207, 208, + 209, 210, 211, 0, 212, 213, 214, 215, 216, 0, + 217, 218, 219, 635, 220, 221, 0, 0, 0, 0, + 0, 222, 223, 224, 225, 226, 1195, 1196, 229, 0, + 230, 0, 231, 232, 233, 234, 235, 0, 236, 237, + 238, 0, 0, 239, 240, 857, 242, 243, 0, 244, + 245, 246, 0, 247, 248, 0, 249, 250, 251, 0, + 253, 254, 0, 0, 256, 257, 258, 1197, 0, 260, + 0, 261, 636, 0, 637, 262, 263, 0, 264, 0, + 0, 266, 0, 267, 268, 269, 270, 638, 271, 272, + 273, 0, 274, 275, 276, 277, 278, 279, 0, 639, + 0, 281, 282, 283, 284, 1198, 1199, 0, 1200, 0, + 288, 640, 641, 289, 642, 290, 291, 292, 293, 294, + 0, 0, 643, 296, 644, 0, 297, 298, 299, 0, + 0, 300, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, 1201, 645, 1202, 0, 315, 316, + 317, 318, 319, 320, 321, 0, 323, 0, 324, 325, + 646, 326, 0, 0, 328, 1203, 330, 331, 0, 0, + 332, 0, 0, 0, 333, 334, 0, 0, 0, 647, + 648, 0, 337, 338, 339, 340, 341, 0, 342, 0, + 0, 345, 346, 347, 0, 348, 349, 350, 351, 352, + 353, 1204, 355, 356, 0, 357, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 0, 367, 368, 649, 369, + 370, 0, 372, 373, 374, 375, 376, 377, 378, 379, + 0, 380, 381, 382, 0, 383, 0, 385, 386, 650, + 387, 1206, 0, 389, 390, 391, 392, 393, 394, 395, + 396, 397, 398, 0, 400, 0, 401, 402, 0, 403, + 404, 405, 406, 407, 0, 1207, 1208, 505, 0, 410, + 0, 412, 0, 0, 414, 415, 416, 417, 418, 506, + 0, 419, 420, 421, 422, 0, 0, 423, 424, 425, + 426, 0, 1209, 429, 651, 430, 431, 432, 0, 507, + 433, 434, 435, 436, 437, 438, 0, 0, 0, 0, + 0, 0, 0, 0, 447, 448, 449, 0, 0, 0, + 0, 508, 1210, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 509, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 510, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 511, 0, 0, 0, 0, 512, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 513, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, + 0, 0, 0, 0, 0, 0, 0, 515, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 158, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 516, 0, 0, 0, 517, 0, + 518, 0, 0, 0, 0, 0, 519, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 520, 521, 0, 0, 0, 522, 0, + 0, 0, 0, 0, 0, 0, 523, 0, 0, 0, + 0, 524, 0, 0, 0, 0, 0, 0, 0, 0, + 525, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 526 +}; + +static const short int yycheck[] = +{ + 0, 46, 157, 41, 0, 631, 777, 1299, 561, 699, + 1314, 11, 1253, 21, 1205, 12, 478, 823, 884, 27, + 659, 801, 597, 150, 702, 594, 0, 154, 1284, 836, + 1816, 34, 22, 0, 0, 702, 653, 1489, 591, 684, + 734, 1998, 1265, 1584, 34, 1237, 46, 1739, 693, 1413, + 472, 1232, 514, 1349, 607, 667, 43, 7, 8, 1237, + 1237, 1790, 2216, 13, 14, 747, 1237, 1237, 1237, 19, + 2187, 21, 22, 755, 24, 1750, 770, 27, 28, 29, + 705, 704, 32, 33, 34, 0, 36, 509, 38, 39, + 1744, 1745, 42, 738, 0, 155, 994, 742, 2416, 159, + 2562, 17, 0, 948, 749, 38, 0, 167, 1498, 855, + 856, 756, 0, 11, 532, 0, 0, 11, 0, 847, + 848, 20, 1495, 25, 1570, 1571, 663, 907, 874, 32, + 512, 2336, 25, 45, 516, 45, 87, 762, 2166, 2167, + 2168, 2169, 870, 525, 45, 5, 87, 39, 87, 87, + 82, 131, 1693, 131, 131, 136, 14, 47, 11, 106, + 47, 8, 1382, 92, 1009, 18, 111, 39, 57, 156, + 1015, 11, 11, 25, 161, 162, 47, 171, 18, 24, + 131, 168, 39, 54, 227, 39, 47, 30, 71, 24, + 61, 11, 3006, 7, 207, 225, 43, 87, 18, 7, + 61, 151, 152, 153, 131, 155, 134, 157, 87, 159, + 160, 143, 19, 163, 228, 165, 166, 167, 82, 1760, + 225, 1762, 1442, 2621, 231, 2623, 241, 149, 797, 2857, + 32, 7, 161, 261, 1415, 54, 133, 171, 25, 279, + 67, 128, 195, 94, 92, 3145, 3028, 62, 258, 132, + 2960, 266, 115, 306, 307, 115, 718, 128, 186, 949, + 126, 87, 62, 195, 258, 241, 198, 128, 91, 21, + 116, 359, 360, 88, 157, 2313, 39, 79, 266, 143, + 386, 279, 230, 289, 2746, 295, 381, 393, 88, 172, + 104, 386, 15, 16, 270, 90, 104, 180, 393, 2337, + 59, 3011, 145, 150, 382, 293, 149, 154, 135, 156, + 316, 1382, 929, 401, 161, 162, 994, 293, 167, 25, + 203, 168, 3222, 478, 258, 215, 1171, 994, 104, 382, + 220, 195, 342, 286, 198, 232, 215, 96, 153, 182, + 3122, 468, 1208, 95, 342, 168, 3246, 230, 354, 288, + 1032, 146, 59, 153, 286, 362, 1360, 1361, 160, 514, + 373, 401, 252, 406, 1368, 252, 989, 131, 1372, 1373, + 115, 401, 262, 401, 325, 1566, 945, 3087, 505, 2841, + 272, 252, 169, 1387, 511, 1389, 401, 401, 1078, 96, + 318, 252, 320, 276, 220, 3023, 401, 1653, 325, 1170, + 272, 2429, 268, 785, 283, 207, 1410, 246, 1412, 356, + 349, 269, 406, 342, 2876, 272, 476, 39, 272, 279, + 480, 1794, 286, 281, 104, 406, 406, 241, 406, 406, + 490, 382, 295, 241, 816, 295, 220, 388, 3252, 351, + 372, 382, 288, 825, 382, 386, 335, 300, 338, 1195, + 1196, 338, 266, 404, 297, 837, 401, 1203, 2663, 25, + 300, 344, 401, 169, 170, 1193, 1194, 338, 313, 401, + 382, 329, 382, 1167, 1202, 2432, 2433, 338, 313, 318, + 300, 320, 284, 242, 406, 293, 1023, 1258, 386, 401, + 266, 401, 386, 344, 342, 393, 2894, 2959, 401, 393, + 401, 403, 401, 349, 397, 1187, 325, 405, 372, 272, + 403, 405, 218, 500, 406, 1888, 1739, 405, 2546, 469, + 405, 405, 472, 405, 474, 533, 476, 535, 478, 537, + 480, 481, 482, 541, 406, 242, 486, 2229, 488, 1184, + 490, 2233, 394, 395, 396, 397, 462, 497, 966, 406, + 295, 403, 406, 220, 1232, 401, 506, 406, 81, 509, + 319, 325, 512, 718, 514, 1232, 516, 517, 1348, 1349, + 2016, 521, 2018, 523, 1964, 525, 492, 1039, 528, 1359, + 133, 708, 1362, 92, 1223, 207, 2127, 2128, 715, 51, + 1370, 1371, 399, 1957, 401, 402, 82, 404, 382, 406, + 138, 131, 1662, 1383, 1384, 392, 393, 394, 395, 396, + 397, 3045, 319, 293, 1394, 132, 403, 89, 568, 466, + 570, 468, 622, 573, 388, 92, 622, 1071, 89, 152, + 59, 1256, 169, 1531, 1854, 1855, 763, 104, 327, 1859, + 404, 99, 592, 101, 594, 595, 1374, 1375, 622, 12, + 272, 1003, 161, 500, 334, 622, 622, 143, 505, 592, + 400, 611, 595, 121, 511, 60, 406, 96, 1448, 359, + 360, 293, 361, 92, 266, 281, 133, 3139, 1898, 1899, + 1684, 87, 268, 23, 156, 1254, 392, 393, 394, 395, + 396, 397, 67, 230, 61, 113, 1048, 403, 1879, 59, + 143, 293, 2148, 1884, 7, 92, 87, 622, 555, 195, + 13, 86, 198, 108, 561, 382, 622, 92, 668, 669, + 87, 92, 2876, 329, 1947, 572, 243, 3189, 281, 99, + 2176, 101, 2849, 91, 325, 2410, 96, 1415, 11, 277, + 167, 116, 161, 215, 591, 695, 87, 165, 1415, 316, + 1595, 121, 195, 1598, 1599, 705, 3190, 215, 317, 220, + 607, 711, 220, 610, 1317, 1318, 228, 225, 718, 2215, + 720, 240, 89, 359, 161, 232, 726, 624, 1401, 288, + 730, 298, 249, 1854, 1855, 1229, 161, 737, 1859, 80, + 161, 1235, 315, 316, 189, 745, 746, 216, 217, 162, + 286, 104, 394, 803, 151, 1249, 153, 803, 148, 215, + 168, 761, 762, 242, 764, 406, 90, 235, 818, 166, + 406, 1283, 818, 283, 1447, 166, 99, 1898, 1899, 803, + 217, 781, 782, 342, 215, 785, 803, 803, 359, 251, + 349, 841, 401, 286, 114, 186, 241, 797, 215, 2806, + 220, 308, 1274, 1531, 11, 225, 327, 317, 858, 169, + 707, 708, 907, 813, 1531, 37, 816, 817, 715, 288, + 325, 821, 146, 331, 134, 825, 3194, 3195, 288, 90, + 150, 339, 242, 833, 1039, 406, 372, 837, 888, 839, + 319, 99, 401, 101, 380, 1277, 382, 463, 215, 305, + 360, 288, 308, 194, 1286, 196, 295, 907, 80, 401, + 757, 758, 759, 288, 1296, 327, 763, 288, 1380, 337, + 2612, 2650, 317, 342, 319, 2617, 186, 25, 2620, 3247, + 349, 1313, 30, 1315, 1316, 146, 2177, 1319, 241, 349, + 1686, 401, 99, 183, 251, 241, 1628, 38, 131, 361, + 47, 406, 1956, 342, 2608, 342, 2408, 1602, 1603, 319, + 2264, 331, 349, 266, 61, 2148, 149, 342, 815, 339, + 1582, 342, 3143, 3144, 349, 66, 359, 977, 978, 151, + 980, 132, 401, 215, 1755, 26, 2178, 227, 289, 836, + 87, 401, 89, 2176, 2175, 945, 2292, 293, 2254, 565, + 2178, 2178, 952, 953, 61, 46, 2229, 2178, 2178, 2178, + 2233, 961, 241, 963, 401, 316, 99, 225, 101, 585, + 327, 113, 194, 406, 196, 257, 401, 593, 119, 1711, + 1712, 1713, 1714, 281, 126, 207, 2993, 266, 63, 380, + 381, 382, 399, 169, 1824, 386, 0, 404, 998, 2053, + 3221, 149, 393, 354, 361, 2596, 147, 1751, 318, 156, + 320, 281, 2122, 400, 293, 2125, 2126, 1017, 240, 406, + 396, 169, 170, 165, 405, 401, 101, 134, 404, 2139, + 1067, 329, 392, 393, 394, 395, 396, 397, 2629, 1039, + 2631, 183, 1872, 403, 354, 152, 126, 2317, 359, 271, + 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 329, + 2330, 1533, 959, 1063, 1064, 1065, 1066, 1499, 215, 317, + 218, 1901, 266, 220, 352, 2911, 270, 474, 1283, 186, + 1747, 303, 215, 126, 232, 227, 359, 360, 1265, 3130, + 1267, 488, 225, 235, 318, 406, 320, 241, 1275, 293, + 241, 2155, 2156, 183, 406, 252, 241, 1937, 660, 2379, + 2380, 351, 360, 359, 360, 262, 318, 733, 320, 1949, + 1950, 2352, 266, 132, 386, 266, 1236, 234, 401, 270, + 2544, 266, 684, 274, 258, 270, 382, 1314, 400, 280, + 183, 693, 382, 267, 1576, 3186, 287, 227, 157, 2891, + 3191, 1879, 293, 401, 1773, 401, 1884, 1054, 293, 285, + 301, 401, 1879, 172, 241, 359, 290, 1884, 309, 2064, + 1067, 180, 1172, 1173, 382, 1380, 2071, 2072, 1178, 3220, + 1180, 54, 175, 266, 227, 381, 397, 270, 61, 266, + 386, 338, 403, 401, 126, 337, 2317, 325, 279, 2320, + 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 241, 2330, + 293, 318, 144, 320, 355, 1265, 392, 393, 394, 395, + 396, 397, 329, 304, 359, 2021, 241, 403, 2513, 2514, + 1325, 338, 2517, 266, 2519, 344, 1236, 385, 1238, 241, + 1240, 1241, 1242, 1243, 392, 393, 394, 395, 396, 397, + 382, 266, 230, 2148, 1254, 403, 1256, 1304, 2379, 2380, + 402, 399, 7, 401, 266, 230, 404, 276, 13, 401, + 71, 668, 669, 329, 1274, 1325, 359, 1277, 1278, 9, + 32, 2176, 241, 1283, 1334, 2555, 1286, 1287, 1334, 1289, + 1343, 2705, 1965, 909, 1294, 33, 1296, 401, 28, 1299, + 1300, 39, 1342, 919, 382, 268, 51, 266, 382, 382, + 1334, 270, 285, 1313, 930, 1315, 1316, 1334, 1334, 1319, + 72, 399, 255, 401, 2013, 1325, 404, 401, 401, 1954, + 64, 132, 948, 730, 293, 359, 360, 977, 978, 2612, + 980, 93, 1342, 1343, 2617, 152, 1346, 2620, 745, 746, + 375, 376, 97, 382, 382, 382, 157, 17, 382, 104, + 112, 402, 107, 382, 761, 406, 44, 45, 1265, 1419, + 1267, 172, 401, 401, 401, 127, 144, 401, 1275, 180, + 1380, 399, 401, 401, 781, 782, 2496, 359, 360, 141, + 113, 1288, 2502, 2503, 2504, 2505, 2506, 2507, 1295, 5, + 396, 36, 203, 126, 10, 401, 1918, 402, 404, 154, + 402, 406, 18, 2243, 406, 285, 1049, 1314, 1528, 1052, + 1317, 1318, 1532, 1056, 3015, 2341, 2342, 402, 2285, 35, + 401, 406, 1329, 404, 2555, 402, 1546, 2707, 2708, 406, + 402, 113, 165, 1553, 406, 827, 828, 2175, 394, 395, + 396, 397, 402, 175, 126, 402, 406, 403, 2175, 406, + 183, 2702, 207, 1977, 1978, 1575, 402, 1577, 220, 386, + 406, 977, 978, 2205, 980, 276, 228, 401, 2532, 1589, + 402, 1591, 402, 402, 406, 254, 406, 406, 402, 1489, + 230, 402, 406, 165, 2548, 406, 241, 402, 402, 1499, + 401, 406, 406, 402, 227, 257, 402, 406, 36, 169, + 406, 183, 235, 402, 26, 1625, 402, 406, 2348, 402, + 406, 2377, 1632, 406, 1634, 270, 402, 402, 1528, 1529, + 406, 406, 1532, 1533, 402, 402, 374, 1537, 406, 406, + 2954, 402, 171, 1543, 1976, 406, 1546, 1444, 293, 1549, + 404, 2842, 402, 1553, 1554, 227, 406, 402, 233, 1559, + 402, 406, 1739, 235, 406, 230, 402, 402, 799, 2242, + 406, 406, 232, 359, 360, 1575, 1576, 1577, 1578, 401, + 1580, 402, 404, 1583, 1584, 406, 2707, 2708, 626, 1589, + 628, 1591, 1592, 1593, 1594, 2214, 1979, 1980, 169, 1496, + 2273, 2874, 17, 2035, 377, 378, 379, 1607, 1608, 1609, + 1610, 1611, 1612, 1613, 337, 233, 1616, 1617, 2891, 2051, + 1620, 1621, 1622, 2055, 2352, 1625, 1626, 402, 2234, 232, + 2236, 406, 1632, 1633, 1634, 2352, 1636, 402, 318, 402, + 320, 406, 2438, 406, 1739, 230, 2916, 402, 1648, 3003, + 318, 406, 320, 1700, 325, 1655, 1656, 1657, 1658, 1659, + 1660, 232, 26, 2403, 233, 337, 1063, 1064, 1065, 1066, + 2940, 2941, 374, 402, 1724, 402, 402, 406, 1724, 406, + 406, 2791, 2792, 2793, 402, 374, 2359, 402, 406, 1739, + 402, 406, 402, 1693, 406, 171, 406, 402, 2752, 2753, + 405, 1701, 402, 2757, 2758, 402, 406, 402, 394, 406, + 402, 406, 402, 1918, 406, 402, 406, 402, 293, 406, + 405, 1721, 1619, 130, 17, 385, 1726, 958, 388, 389, + 390, 36, 392, 393, 394, 395, 396, 397, 402, 402, + 1740, 402, 406, 403, 1744, 1745, 402, 402, 402, 402, + 406, 406, 406, 406, 169, 3097, 401, 3099, 404, 1759, + 1760, 1761, 1762, 7, 359, 360, 404, 3040, 1973, 13, + 1947, 401, 230, 1773, 402, 1172, 1173, 1871, 406, 1873, + 1874, 1178, 385, 266, 401, 388, 389, 390, 1788, 392, + 393, 394, 395, 396, 397, 2916, 3066, 181, 1397, 401, + 1697, 1400, 224, 285, 175, 401, 1901, 51, 401, 47, + 359, 20, 1812, 401, 385, 26, 1816, 232, 26, 2940, + 2941, 392, 393, 394, 395, 396, 397, 241, 1725, 175, + 344, 117, 403, 117, 401, 1732, 117, 117, 117, 117, + 406, 401, 1739, 1240, 1241, 1242, 1243, 117, 117, 230, + 1466, 1901, 2284, 97, 1942, 1943, 3162, 2713, 117, 117, + 104, 230, 2692, 107, 117, 1915, 3157, 3140, 117, 20, + 127, 2603, 181, 382, 1984, 2985, 169, 401, 126, 126, + 382, 401, 401, 401, 20, 1935, 401, 248, 401, 382, + 1890, 401, 382, 401, 401, 401, 401, 1947, 401, 238, + 401, 401, 38, 1300, 2593, 401, 401, 382, 382, 401, + 154, 20, 401, 401, 20, 7, 401, 401, 1918, 406, + 401, 13, 14, 401, 401, 73, 181, 19, 401, 21, + 66, 401, 38, 401, 126, 27, 126, 29, 325, 232, + 325, 404, 325, 2148, 287, 3066, 325, 325, 230, 325, + 325, 325, 220, 343, 406, 325, 344, 325, 1958, 325, + 66, 283, 1962, 207, 344, 325, 325, 325, 54, 230, + 385, 2176, 154, 388, 389, 390, 1976, 392, 393, 394, + 395, 396, 397, 119, 1984, 1985, 1986, 406, 403, 325, + 325, 325, 283, 325, 325, 230, 401, 241, 1998, 230, + 169, 401, 359, 351, 401, 401, 2116, 17, 20, 9, + 19, 147, 87, 119, 344, 189, 354, 20, 126, 20, + 230, 284, 266, 117, 2456, 2457, 270, 344, 357, 117, + 344, 325, 117, 349, 273, 2035, 219, 1268, 1654, 175, + 131, 147, 736, 356, 1941, 1276, 1662, 401, 323, 293, + 1947, 2051, 2229, 386, 1285, 2055, 2233, 323, 200, 200, + 293, 2737, 403, 323, 2920, 131, 406, 1298, 160, 175, + 2070, 163, 165, 165, 401, 401, 327, 402, 406, 325, + 388, 231, 406, 2083, 2084, 2085, 2086, 2264, 225, 325, + 402, 325, 385, 183, 1710, 388, 389, 390, 283, 392, + 393, 394, 395, 396, 397, 60, 2801, 220, 173, 401, + 403, 173, 401, 220, 1730, 220, 2116, 2117, 230, 236, + 36, 2951, 36, 406, 325, 402, 266, 2127, 2128, 325, + 406, 266, 266, 258, 270, 169, 20, 169, 274, 169, + 344, 344, 2142, 169, 280, 228, 388, 19, 325, 399, + 325, 287, 325, 325, 399, 2265, 126, 293, 2208, 169, + 388, 230, 2208, 234, 270, 301, 20, 139, 274, 401, + 230, 142, 2222, 309, 280, 142, 2222, 2287, 126, 2229, + 406, 287, 401, 2233, 20, 401, 230, 293, 402, 230, + 316, 406, 2192, 8, 136, 301, 36, 230, 197, 406, + 402, 131, 402, 309, 402, 402, 374, 402, 402, 2209, + 374, 3067, 131, 402, 2214, 402, 402, 374, 406, 355, + 401, 2271, 232, 2223, 402, 2271, 2226, 325, 2740, 357, + 183, 402, 402, 3089, 159, 402, 402, 3093, 3094, 2239, + 402, 3071, 401, 220, 402, 401, 401, 241, 183, 355, + 402, 1648, 244, 359, 244, 325, 192, 341, 1655, 1656, + 1657, 1658, 1659, 1660, 192, 2265, 192, 325, 325, 3090, + 325, 325, 2272, 325, 325, 325, 169, 169, 169, 169, + 169, 169, 169, 380, 2284, 399, 402, 2287, 286, 2186, + 198, 402, 2387, 230, 334, 268, 406, 183, 2195, 388, + 401, 2389, 2390, 2391, 2392, 228, 402, 325, 230, 344, + 230, 172, 172, 237, 2211, 402, 225, 344, 233, 401, + 401, 344, 25, 115, 115, 399, 406, 30, 110, 131, + 1024, 403, 2229, 126, 402, 402, 2233, 2387, 402, 353, + 45, 131, 401, 138, 1038, 2777, 2778, 159, 2780, 402, + 388, 334, 126, 402, 401, 169, 325, 325, 169, 2256, + 325, 2258, 1759, 325, 1761, 325, 2263, 2264, 169, 173, + 359, 402, 400, 20, 2484, 385, 2486, 469, 388, 389, + 390, 400, 392, 393, 394, 395, 396, 397, 2285, 126, + 482, 234, 155, 403, 486, 401, 2454, 56, 347, 317, + 172, 406, 20, 8, 401, 497, 3227, 402, 2408, 402, + 401, 135, 131, 401, 506, 401, 131, 402, 402, 401, + 358, 402, 36, 140, 3027, 517, 358, 406, 334, 521, + 406, 523, 2432, 2433, 2050, 2612, 220, 220, 117, 344, + 2617, 169, 145, 2620, 94, 406, 149, 220, 89, 1854, + 1855, 133, 2884, 2965, 1859, 156, 2456, 2457, 133, 400, + 131, 344, 2894, 149, 344, 105, 169, 170, 116, 402, + 401, 47, 47, 233, 1168, 174, 568, 131, 570, 182, + 2480, 325, 116, 169, 2484, 2485, 2486, 2487, 2488, 2489, + 2490, 401, 233, 1898, 1899, 131, 348, 2394, 2395, 401, + 401, 401, 302, 402, 402, 402, 2122, 262, 359, 2125, + 2126, 169, 215, 126, 20, 218, 401, 193, 220, 401, + 152, 256, 280, 2139, 280, 406, 233, 233, 126, 232, + 2146, 317, 2148, 230, 1228, 2740, 122, 1768, 348, 406, + 1771, 359, 105, 20, 1775, 230, 232, 230, 20, 100, + 2550, 2551, 2552, 401, 2554, 402, 161, 279, 92, 116, + 2176, 38, 2612, 342, 6, 261, 256, 2617, 401, 1699, + 2620, 953, 2188, 1958, 232, 1624, 622, 2577, 2075, 1273, + 2580, 2146, 2989, 2583, 2580, 2585, 1607, 1818, 2469, 66, + 1284, 2583, 2835, 1995, 297, 2142, 2596, 2213, 3202, 3226, + 3181, 3180, 3210, 695, 2263, 2585, 1250, 2773, 2608, 2868, + 2610, 3283, 1688, 3260, 2814, 2813, 2176, 2175, 2150, 711, + 3052, 2621, 3217, 2623, 2967, 2625, 1230, 3228, 720, 2629, + 2970, 2631, 27, 562, 726, 2643, 2595, 817, 3140, 3040, + 2750, 2015, 119, 2643, 1571, 737, 2601, 1570, 2545, 3106, + 3282, 2761, 3251, 2763, 606, 3016, 1496, 20, 803, 2579, + 2272, 1962, 1970, 1981, 2561, 803, 985, 1511, 986, 3101, + 147, 1490, 764, 2070, 2571, 1947, 1739, 984, 2235, 2892, + 500, 2362, 385, 1963, 2742, 388, 389, 390, 1674, 392, + 393, 394, 395, 396, 397, 2577, 3069, 2874, 175, 385, + 403, 2354, 388, 389, 390, 1973, 392, 393, 394, 395, + 396, 397, 1915, 38, 2891, 2612, 1826, 403, 1913, -1, + 2617, 813, -1, 2620, 1795, 1445, -1, 385, -1, 821, + 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, + 2740, 66, -1, -1, 1438, 403, -1, 2363, -1, -1, + 2750, 2751, -1, -1, -1, -1, -1, -1, -1, -1, + 2965, 2761, 2762, 2763, 2822, -1, -1, -1, 1999, -1, + -1, -1, -1, -1, 2774, -1, -1, 2777, 2778, 2779, + 2780, -1, -1, -1, -1, -1, 2402, 2964, -1, -1, + -1, -1, -1, 270, 119, 2845, -1, 274, -1, 2845, + -1, 150, -1, 280, -1, 154, 2806, -1, -1, -1, + 287, -1, -1, -1, -1, -1, 293, -1, -1, -1, + -1, -1, 147, -1, 301, -1, 3003, 2724, 2725, 2726, + 2727, -1, 309, -1, -1, -1, -1, -1, -1, 2455, + -1, 2891, -1, -1, -1, -1, 2462, -1, 2464, -1, + 2081, 2082, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 466, 2862, 3040, -1, -1, -1, -1, 2868, -1, + -1, -1, -1, -1, 2874, -1, 1570, 1571, 355, -1, + 2496, -1, -1, -1, 2884, -1, 2502, 2503, 2504, 2505, + 2506, 2507, -1, -1, 2894, -1, -1, -1, -1, -1, + -1, 169, -1, -1, -1, -1, -1, 2907, -1, -1, + -1, 2911, 2317, -1, -1, 2320, 2321, 2322, 2323, 2324, + 2325, 2326, 2327, 2328, -1, 2330, -1, -1, -1, -1, + 0, -1, 2548, 2549, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 3121, 270, -1, 272, -1, 274, + 555, -1, -1, -1, -1, 280, 561, -1, -1, 1653, + -1, -1, 287, 3140, 232, 2965, -1, 572, 293, -1, + -1, -1, -1, -1, 2379, 2380, 301, 2874, 2594, -1, + -1, 1675, -1, -1, 309, -1, 591, -1, -1, -1, + -1, -1, -1, 2993, 2891, -1, -1, 67, -1, -1, + -1, -1, 607, -1, -1, 610, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 3015, 2247, 3017, 2249, 624, + 2251, -1, 2253, -1, 2255, -1, 3203, -1, -1, 2260, + 355, -1, -1, -1, -1, -1, -1, -1, -1, 3039, + 3040, -1, -1, 113, 3044, 3045, -1, -1, -1, -1, + -1, -1, 3052, -1, -1, 2286, 126, -1, -1, -1, + -1, 131, -1, -1, -1, 135, -1, 2964, 138, -1, + 140, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 165, 3273, 3097, 3098, 3099, + 3100, 3101, 707, -1, -1, -1, 3003, -1, 3005, -1, + -1, -1, 1806, 183, -1, -1, -1, 385, -1, 468, + 2736, 389, 390, -1, 392, 393, 394, 395, 396, 397, + 3027, -1, -1, -1, -1, 403, -1, -1, -1, -1, + 3140, 3141, -1, 3040, -1, -1, 1238, -1, -1, -1, + 2555, 3048, 757, 758, 759, -1, 505, 227, -1, -1, + -1, -1, 511, -1, -1, 235, -1, -1, -1, 3264, + -1, -1, -1, -1, -1, 2791, 2792, 2793, -1, -1, + -1, -1, 3182, 3183, -1, -1, 1278, 2803, 2804, 3086, + 3190, 2807, 2808, -1, -1, 1287, -1, 1289, -1, -1, + -1, 3251, 1294, 273, -1, -1, -1, 3207, -1, -1, + 815, -1, -1, -1, 3264, -1, -1, -1, 3218, -1, + -1, -1, -1, -1, 3121, -1, -1, -1, -1, -1, + -1, 836, 3282, -1, -1, 2851, -1, -1, -1, -1, + -1, 590, -1, 3140, -1, -1, 316, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 2875, + 3260, -1, -1, -1, -1, -1, -1, 337, 617, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 3283, -1, -1, -1, 357, -1, -1, + -1, -1, -1, -1, 10, -1, -1, -1, -1, -1, + -1, -1, 2707, 2708, -1, -1, 3203, 377, 378, 379, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 2015, 2016, -1, 2018, -1, 42, -1, -1, 399, + -1, -1, 402, -1, 404, 405, -1, 2031, 54, 2033, + -1, -1, -1, -1, -1, 61, -1, -1, 64, -1, + -1, -1, 701, 702, 959, -1, -1, -1, -1, 708, + -1, -1, -1, -1, -1, 81, 715, -1, -1, 2985, + -1, -1, -1, -1, 2990, -1, 3273, -1, -1, -1, + 2074, -1, 2779, -1, -1, -1, 102, 736, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2635, 2636, -1, -1, -1, -1, + -1, -1, -1, -1, 763, -1, -1, 133, -1, -1, + -1, 3037, -1, -1, -1, -1, -1, -1, -1, 2123, + -1, -1, -1, -1, -1, -1, 152, 1529, -1, -1, + -1, -1, -1, -1, -1, 1537, 0, -1, -1, 1054, + -1, 1543, 801, -1, 2148, -1, -1, 1549, -1, -1, + 176, -1, 1554, -1, -1, -1, -1, 1559, -1, -1, + -1, -1, -1, -1, 823, -1, -1, -1, -1, -1, + -1, -1, 2176, -1, -1, -1, 1578, -1, 1580, -1, + -1, -1, -1, -1, -1, -1, 845, 2191, -1, -1, + 1592, 1593, 1594, -1, -1, -1, -1, -1, -1, -1, + 2204, 2916, -1, 67, -1, -1, 232, 1609, 1610, 1611, + 1612, 2215, 871, -1, 1616, 1617, -1, -1, 1620, 1621, + 1622, -1, -1, -1, 1626, 2940, 2941, -1, -1, 255, + -1, 1633, -1, -1, 1636, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 2248, 904, 905, -1, 907, 113, + 2254, 277, -1, -1, -1, 281, -1, 283, -1, -1, + -1, -1, 126, 289, -1, 924, -1, 131, -1, -1, + -1, 135, -1, 17, 138, -1, 140, -1, -1, -1, + -1, 25, -1, -1, -1, -1, 30, -1, -1, -1, + 316, 317, 3218, -1, 2298, 321, -1, -1, -1, -1, + -1, 165, -1, 329, -1, -1, -1, -1, 334, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 183, + 979, -1, -1, 982, 983, 2329, -1, -1, 354, -1, + -1, 990, 3039, -1, 3260, 994, -1, 3044, 3045, 2343, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 3066, -1, -1, -1, -1, -1, 3283, -1, 2900, + 2901, 2902, 2903, 227, -1, 1024, -1, -1, -1, 2910, + -1, 235, -1, 1288, -1, -1, -1, -1, -1, 1038, + 1295, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 3098, -1, 3100, -1, -1, -1, -1, -1, -1, + -1, 145, 1317, 1318, -1, 149, -1, -1, -1, 273, + 1812, -1, -1, -1, 1329, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 169, 170, -1, -1, -1, + -1, -1, -1, -1, 3141, -1, -1, -1, 182, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 316, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 2472, -1, + -1, 215, -1, 337, 218, -1, 3183, -1, -1, -1, + -1, -1, -1, 3190, -1, -1, -1, -1, 232, -1, + 234, -1, -1, 357, -1, -1, -1, -1, -1, -1, + 3207, -1, -1, -1, -1, -1, -1, -1, -1, 1168, + -1, -1, -1, 377, 378, 379, -1, -1, -1, -1, + -1, -1, -1, 3064, -1, -1, -1, 1186, -1, 1444, + -1, -1, -1, -1, -1, 399, -1, -1, 402, -1, + 404, 405, -1, -1, -1, -1, 1205, -1, -1, -1, + -1, -1, -1, 297, -1, -1, -1, -1, -1, -1, + -1, -1, 2566, -1, -1, -1, -1, -1, -1, 1228, + -1, -1, -1, 1232, -1, -1, -1, -1, -1, -1, + -1, 1496, -1, 1985, 1986, -1, 17, -1, -1, -1, + -1, -1, -1, -1, 25, -1, -1, -1, -1, 30, + -1, -1, -1, -1, -1, -1, 1265, -1, 1267, -1, + -1, -1, -1, -1, 1273, -1, 1275, -1, -1, -1, + -1, -1, -1, -1, -1, 1284, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 385, -1, 736, 388, 389, 390, -1, 392, 393, + 394, 395, 396, 397, -1, 1314, 400, -1, -1, 403, + -1, -1, -1, 407, -1, -1, 17, -1, -1, -1, + -1, -1, -1, -1, 25, -1, -1, -1, -1, 30, + -1, 2083, 2084, 2085, 2086, -1, -1, -1, 17, 1348, + 1349, -1, 21, -1, -1, -1, 25, 1356, -1, -1, + 1359, 30, -1, 1362, 1619, -1, -1, -1, -1, -1, + -1, 1370, 1371, -1, 145, 2117, -1, -1, 149, 1378, + -1, -1, 1381, 1382, 1383, 1384, -1, -1, -1, -1, + 823, -1, 1391, 1392, -1, 1394, -1, 1396, 169, 170, + 1399, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2754, 182, -1, -1, -1, 1414, 1415, -1, -1, 1418, + -1, -1, -1, 1422, -1, -1, 95, 1426, -1, -1, + 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, + -1, 1440, 1697, -1, 215, -1, 1445, 218, -1, 1448, + 2192, -1, -1, -1, 145, -1, -1, -1, 149, -1, + -1, 232, -1, 234, -1, -1, -1, 2209, -1, -1, + 1725, -1, -1, -1, -1, -1, 145, 1732, 169, 170, + 149, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 182, -1, -1, -1, -1, -1, -1, -1, 1498, + 169, 170, -1, -1, -1, -1, -1, -1, -1, -1, + 10, -1, -1, 182, -1, 948, -1, -1, -1, -1, + -1, -1, -1, -1, 215, -1, 297, 218, -1, -1, + -1, -1, 1531, -1, -1, -1, -1, -1, -1, -1, + -1, 232, -1, 234, -1, -1, 215, -1, 1547, 218, + -1, -1, 2896, -1, -1, -1, -1, 990, -1, -1, + -1, -1, -1, 232, 64, 234, -1, 1566, -1, -1, + -1, 1570, 1571, -1, -1, -1, -1, -1, -1, -1, + -1, 81, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1024, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 102, -1, -1, 1038, 297, -1, -1, -1, + -1, -1, -1, -1, 385, -1, -1, 388, 389, 390, + -1, 392, 393, 394, 395, 396, 397, -1, 297, -1, + -1, -1, 403, 133, -1, 406, -1, -1, 138, -1, + -1, -1, -1, -1, -1, -1, 1645, -1, -1, -1, + -1, -1, 152, -1, 1653, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 590, 1673, 344, 1675, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 1941, -1, -1, -1, + -1, -1, -1, -1, 385, -1, -1, 388, 389, 390, + 617, 392, 393, 394, 395, 396, 397, -1, -1, -1, + -1, -1, 403, -1, -1, 406, 385, -1, -1, 388, + 389, 390, -1, 392, 393, 394, 395, 396, 397, -1, + -1, -1, 232, -1, 403, 1168, -1, -1, 2480, -1, + 1739, -1, -1, 2485, -1, 2487, 2488, 2489, 2490, -1, + 1749, -1, -1, 1186, -1, 255, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 1205, -1, -1, -1, -1, 277, -1, 1778, + -1, -1, -1, 283, 701, -1, -1, -1, -1, 289, + 10, -1, 25, -1, -1, 1228, 1795, 30, -1, -1, + -1, -1, 22, -1, -1, -1, -1, 1806, 2550, 2551, + 2552, -1, 2554, -1, -1, -1, 316, 317, 3162, -1, + -1, 321, 42, -1, -1, 1824, 1825, -1, -1, 329, + -1, -1, -1, -1, 334, -1, -1, -1, -1, -1, + 1273, 61, -1, 343, 64, -1, -1, -1, -1, -1, + -1, 1284, -1, -1, 354, 1854, 1855, -1, -1, -1, + 1859, 81, -1, -1, -1, -1, -1, 87, -1, -1, + -1, -1, 1871, 1872, 1873, 1874, -1, -1, -1, -1, + 1879, -1, 102, 2625, 1883, 1884, -1, 1886, -1, -1, + 1889, -1, -1, -1, -1, -1, -1, -1, -1, 1898, + 1899, -1, 1901, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 145, 133, 134, 1914, 149, 1916, 138, -1, + -1, 1920, -1, -1, -1, -1, -1, -1, 845, -1, + -1, 2186, 152, -1, -1, -1, 169, 170, 1937, -1, + 2195, -1, -1, -1, -1, -1, -1, -1, 1947, 182, + 1949, 1950, -1, -1, 871, 175, 2211, -1, -1, -1, + -1, -1, -1, -1, -1, 1964, 186, -1, -1, -1, + -1, 1970, -1, -1, -1, -1, -1, -1, -1, -1, + 1979, 1980, 1981, -1, -1, 218, -1, 904, 905, -1, + 907, -1, -1, -1, -1, 1994, -1, -1, -1, 232, + -1, 2256, -1, 2258, -1, 1438, -1, 924, 2263, 2751, + -1, -1, 232, -1, 234, -1, 2015, 2016, -1, 2018, + 2762, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2285, -1, 2031, -1, 2033, 255, -1, 17, -1, -1, + -1, -1, -1, -1, -1, 25, -1, -1, -1, -1, + 30, -1, -1, -1, -1, -1, -1, 277, -1, -1, + -1, 281, 979, 283, 297, 982, 983, -1, -1, -1, + -1, -1, -1, -1, -1, 2074, 17, -1, -1, -1, + -1, -1, -1, -1, 25, -1, -1, -1, -1, 30, + -1, -1, -1, -1, -1, -1, -1, 317, 318, -1, + 320, 321, -1, -1, -1, -1, -1, -1, -1, 329, + -1, -1, -1, 333, 334, -1, -1, -1, 338, -1, + 2862, -1, -1, 343, 2123, -1, 2868, -1, -1, -1, + -1, -1, -1, 1566, -1, -1, -1, 1570, 1571, 2394, + 2395, -1, -1, -1, -1, -1, 126, -1, -1, 2148, + -1, 131, 385, -1, -1, 388, 389, 390, -1, 392, + 393, 394, 395, 396, 397, 145, -1, -1, -1, 149, + 403, -1, -1, -1, -1, -1, 2175, 2176, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 169, + 170, -1, 2191, -1, -1, -1, 736, -1, -1, -1, + -1, -1, 182, -1, 145, 2204, -1, -1, 149, -1, + -1, -1, -1, -1, -1, -1, 2215, -1, -1, -1, + 1653, -1, -1, -1, -1, -1, -1, -1, 169, 170, + 2229, -1, -1, -1, 2233, 215, -1, -1, 218, -1, + -1, 182, 1675, -1, 2243, -1, -1, -1, -1, 2248, + -1, -1, 232, -1, 234, 2254, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2264, -1, -1, -1, -1, + -1, -1, 736, -1, 215, -1, -1, 218, -1, -1, + -1, -1, -1, 823, -1, -1, -1, -1, -1, -1, + 2545, 232, -1, 234, -1, -1, 2295, -1, -1, 2298, + -1, -1, -1, -1, -1, 2304, 2561, -1, 249, -1, + -1, 2310, -1, 2312, -1, -1, 2571, 297, 2317, -1, + -1, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, + 2329, 2330, -1, -1, -1, 2334, 2335, -1, -1, -1, + -1, -1, -1, -1, 2343, -1, -1, -1, -1, 2348, + -1, -1, -1, 2352, -1, 2354, 297, -1, -1, 823, + -1, -1, -1, -1, -1, 2364, -1, -1, 2367, 310, + 2369, -1, -1, 1806, -1, -1, -1, -1, 2377, 2378, + 2379, 2380, -1, -1, -1, 2384, -1, -1, 2387, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 2397, -1, + -1, -1, -1, -1, -1, 385, -1, -1, 388, 389, + 390, -1, 392, 393, 394, 395, 396, 397, -1, -1, + -1, -1, -1, 403, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 1356, + 3182, -1, -1, -1, 385, -1, -1, 388, 389, 390, + 990, 392, 393, 394, 395, 396, 397, -1, -1, -1, + -1, 1378, 403, -1, 1381, -1, -1, 1384, -1, 2724, + 2725, 2726, 2727, 2472, 1391, 1392, -1, -1, -1, 1396, + -1, -1, 1399, -1, 1024, -1, -1, -1, 25, -1, + -1, -1, -1, 30, -1, -1, -1, 1414, 1038, -1, + -1, 1418, -1, -1, -1, 1422, -1, -1, -1, 1426, + -1, -1, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, + 1437, -1, -1, 1440, -1, -1, 990, -1, 1445, -1, + -1, -1, -1, -1, 8, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 736, -1, -1, -1, -1, 2555, -1, -1, -1, + 1024, -1, -1, -1, -1, -1, -1, 2566, -1, -1, + -1, -1, -1, -1, 1038, 112, -1, -1, -1, -1, + -1, 1498, 2015, 2016, -1, 2018, 60, -1, -1, -1, + -1, -1, -1, -1, 68, 69, 70, -1, 2031, -1, + 2033, -1, -1, -1, -1, -1, -1, -1, 145, -1, + -1, -1, 149, 2612, -1, -1, -1, -1, 2617, -1, + -1, 2620, -1, -1, -1, -1, -1, -1, 1168, -1, + 1547, -1, 169, 170, -1, 109, -1, -1, 823, -1, + -1, 2074, -1, -1, -1, 182, 1186, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 2656, -1, -1, + -1, -1, -1, -1, -1, 1205, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 149, -1, -1, -1, -1, + 154, 218, -1, -1, -1, -1, -1, -1, 1228, -1, + 2123, -1, -1, 2692, -1, 232, -1, -1, -1, -1, + 2699, 2700, -1, 2702, 1168, -1, -1, -1, 2707, 2708, + 736, -1, -1, 2712, 2713, 2148, -1, 191, -1, 2718, + 2719, -1, 1186, 2722, -1, -1, -1, -1, 1645, -1, + -1, -1, -1, 1273, 208, 209, 210, 211, 212, -1, + 214, 1205, -1, 2176, 1284, -1, -1, -1, -1, -1, + 3005, -1, -1, -1, -1, 2754, 1673, -1, 2191, -1, + 297, -1, -1, -1, 1228, -1, -1, -1, -1, -1, + 244, 2204, 3027, -1, -1, 17, -1, -1, 20, -1, + -1, -1, 2215, 25, -1, -1, -1, -1, 30, -1, + -1, -1, -1, 3048, -1, -1, 736, 823, -1, -1, + -1, -1, 25, 277, -1, 990, -1, 30, -1, 1273, + -1, -1, -1, -1, -1, 2248, -1, -1, -1, -1, + 1284, 2254, -1, -1, -1, -1, -1, -1, 736, -1, + -1, 3086, 1749, -1, -1, 2834, -1, -1, 312, 1024, + 314, -1, -1, -1, -1, -1, -1, -1, 385, -1, + -1, -1, -1, 1038, -1, 392, 393, 394, 395, 396, + 397, 1778, 336, -1, -1, 2298, 403, -1, -1, 343, + -1, -1, 346, -1, -1, 2874, -1, -1, 1795, -1, + -1, -1, -1, 823, -1, -1, -1, -1, 2887, -1, + -1, -1, 2891, -1, -1, -1, 2329, 2896, 1438, -1, + -1, -1, -1, 145, -1, -1, -1, 149, 1825, -1, + 2343, -1, -1, -1, -1, 823, -1, 2916, -1, -1, + -1, 2920, 145, -1, -1, -1, 149, 169, 170, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 182, 2940, 2941, -1, 2377, 2944, 169, 170, -1, -1, + -1, -1, 2951, 2952, 1871, -1, 1873, 1874, -1, 182, + -1, -1, -1, -1, 990, 2964, 1883, -1, -1, 1886, + -1, -1, 1889, 215, 1438, -1, 218, -1, -1, 2978, + -1, -1, -1, 1168, -1, -1, -1, -1, -1, -1, + 232, -1, 234, -1, -1, 218, -1, 1914, 1024, 1916, + -1, 1186, -1, 1920, 3003, -1, -1, -1, -1, 232, + -1, -1, 1038, -1, -1, -1, -1, -1, -1, -1, + 1205, -1, -1, -1, -1, -1, 1566, -1, -1, -1, + 1570, 1571, -1, -1, -1, -1, -1, -1, -1, 2472, + -1, 3040, 3041, 1228, -1, -1, -1, 1964, -1, -1, + 990, -1, -1, 1970, -1, 297, -1, -1, -1, -1, + -1, -1, 1979, 1980, 1981, -1, -1, 3066, 3067, -1, + 3069, -1, 3071, -1, 297, -1, -1, 1994, -1, -1, + -1, -1, 990, -1, 1024, -1, -1, -1, 1273, -1, + 3089, -1, -1, -1, 3093, 3094, -1, -1, 1038, 1284, + -1, -1, 1566, -1, -1, -1, 1570, 1571, -1, -1, + -1, -1, -1, 1653, -1, -1, 1024, -1, -1, -1, + -1, -1, 3121, -1, -1, -1, -1, -1, -1, -1, + 1038, -1, -1, 2566, -1, 1675, -1, -1, -1, -1, + -1, 3140, 1168, 385, -1, -1, 388, 389, 390, -1, + 392, 393, 394, 395, 396, 397, -1, -1, -1, -1, + 1186, 403, 385, 3162, -1, -1, 389, 390, -1, 392, + 393, 394, 395, 396, 397, -1, -1, -1, -1, 1205, + 403, -1, -1, -1, -1, -1, -1, -1, -1, 1653, + 25, -1, -1, -1, -1, 30, -1, -1, -1, -1, + -1, -1, 1228, -1, 3203, -1, -1, -1, -1, -1, + -1, 1675, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 1168, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 3, -1, -1, -1, 1186, 1273, -1, -1, + -1, 736, 13, 1438, 15, 16, -1, -1, 1284, -1, + 1168, -1, -1, -1, -1, 1205, 1806, -1, 29, 2702, + -1, -1, -1, -1, 3273, -1, -1, 112, 1186, -1, + 2713, -1, -1, -1, -1, -1, -1, 48, 1228, 50, + 51, -1, -1, -1, 55, 56, -1, 1205, -1, -1, + -1, -1, -1, -1, 65, -1, 67, -1, -1, -1, + 145, -1, -1, -1, 149, -1, -1, -1, -1, -1, + 1228, 2754, 83, -1, -1, 86, -1, -1, -1, -1, + -1, 92, -1, 1273, 169, 170, -1, 98, 823, -1, + -1, -1, 1806, 104, 1284, -1, -1, 182, -1, 110, + -1, -1, -1, -1, -1, 116, -1, 118, -1, -1, + -1, -1, 123, -1, -1, 1273, -1, -1, -1, -1, + -1, -1, -1, -1, 135, -1, 1284, -1, 2295, -1, + -1, 1566, -1, 218, -1, 1570, 1571, 2304, -1, -1, + -1, -1, -1, 2310, -1, 2312, -1, 232, -1, -1, + 161, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 1438, -1, -1, -1, -1, 2334, 2335, -1, + -1, -1, -1, 184, 185, -1, -1, -1, -1, 190, + -1, -1, -1, -1, -1, -1, -1, 2354, 199, -1, + -1, -1, -1, -1, -1, -1, -1, 2364, -1, -1, + 2367, -1, 2369, -1, -1, -1, 217, -1, -1, -1, + -1, 2378, 297, 2896, -1, -1, -1, 2384, 1653, -1, + 2387, -1, -1, -1, -1, 2015, 2016, -1, 2018, -1, + 2397, -1, -1, -1, -1, -1, -1, 2920, -1, 250, + 1675, 2031, -1, 2033, -1, -1, -1, -1, 1438, 260, + -1, -1, 263, -1, 265, 990, -1, -1, -1, 270, + -1, -1, -1, -1, 275, -1, -1, 278, -1, -1, + -1, 282, -1, -1, 25, -1, -1, 288, -1, 30, + 1438, -1, 293, -1, 2074, 296, -1, -1, -1, 1024, + 1566, -1, 303, -1, 1570, 1571, -1, -1, -1, -1, + 385, 2015, 2016, 1038, 2018, -1, -1, 392, 393, 394, + 395, 396, 397, -1, -1, -1, -1, 2031, 403, 2033, + -1, 332, -1, -1, -1, -1, -1, -1, -1, 340, + -1, 342, -1, 2123, 345, -1, -1, -1, 349, -1, + -1, -1, -1, -1, -1, -1, 17, -1, -1, -1, + -1, -1, -1, -1, 25, -1, -1, -1, 2148, 30, + 2074, 112, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1806, -1, -1, -1, -1, 1566, 1653, -1, -1, + 1570, 1571, -1, -1, 3067, -1, 2176, -1, -1, -1, + 401, -1, -1, -1, 145, -1, -1, -1, 149, 1675, + -1, 2191, -1, -1, -1, -1, 3089, -1, 1566, 2123, + 3093, 3094, 1570, 1571, 2204, -1, -1, -1, 169, 170, + -1, -1, -1, -1, -1, 2215, -1, -1, -1, -1, + -1, 182, -1, 1168, 2148, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1186, -1, -1, -1, -1, -1, -1, 2248, -1, + -1, -1, 2176, 1653, 2254, -1, -1, 218, -1, -1, + 1205, -1, -1, -1, 145, -1, -1, 2191, 149, 3162, + -1, 232, -1, -1, -1, 1675, -1, -1, -1, 2656, + 2204, -1, -1, 1228, -1, 1653, -1, -1, 169, 170, + -1, 2215, -1, -1, -1, -1, -1, -1, 2298, -1, + -1, 182, -1, -1, -1, -1, -1, 1675, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 1806, -1, 2699, 2700, 2248, -1, -1, -1, 1273, 2329, + 2254, -1, -1, -1, 215, 2712, 297, 218, -1, 1284, + -1, 2718, 2719, 2343, -1, 2722, -1, -1, -1, -1, + -1, 232, -1, 234, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2015, 2016, -1, 2018, 2298, -1, -1, 2377, -1, -1, + -1, -1, -1, -1, -1, -1, 2031, -1, 2033, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2329, 1806, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 297, -1, -1, 2343, + -1, -1, -1, -1, 385, -1, -1, -1, -1, 2074, + -1, 392, 393, 394, 395, 396, 397, -1, 1806, -1, + -1, -1, 403, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 2377, -1, -1, -1, 2834, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2472, -1, -1, -1, -1, -1, 2123, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 1438, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 2148, 385, -1, -1, 388, 389, 390, + 2887, 392, 393, 394, 395, 396, 397, -1, -1, -1, + -1, 402, 403, -1, -1, -1, -1, -1, -1, 2015, + 2016, 2176, 2018, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2031, 2191, 2033, 2472, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 2204, + -1, -1, -1, -1, -1, -1, 2566, 2944, -1, 17, + 2215, -1, 20, -1, -1, 2952, -1, 25, -1, -1, + -1, -1, 30, -1, -1, -1, -1, -1, 2074, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 2978, -1, 2248, -1, -1, -1, -1, -1, 2254, + -1, -1, -1, -1, -1, 2015, 2016, -1, 2018, -1, + -1, 1566, -1, -1, -1, 1570, 1571, -1, -1, -1, + -1, 2031, -1, 2033, -1, -1, -1, 2123, -1, -1, + -1, -1, 2566, -1, -1, -1, -1, 2015, 2016, -1, + 2018, -1, -1, 2298, -1, -1, -1, -1, -1, -1, + -1, -1, 2148, 2031, 3041, 2033, -1, -1, -1, -1, + -1, -1, -1, 17, 2074, -1, -1, -1, -1, -1, + -1, 25, -1, -1, 2329, -1, 30, -1, -1, -1, + 2176, -1, 3069, -1, -1, -1, -1, 145, 2343, -1, + -1, 149, 2702, -1, -1, 2191, 2074, -1, 1653, -1, + -1, -1, -1, 2713, -1, -1, -1, -1, 2204, -1, + -1, 169, 170, 2123, -1, -1, -1, -1, -1, 2215, + 1675, -1, 2377, -1, 182, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 2148, -1, + -1, -1, -1, -1, 2754, 2123, -1, -1, -1, -1, + -1, -1, 2248, -1, -1, -1, -1, 215, 2254, -1, + 218, -1, -1, -1, -1, -1, 2176, -1, 2702, -1, + 2148, -1, -1, -1, 232, -1, 234, -1, -1, 2713, + -1, 2191, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 145, -1, -1, 2204, 149, -1, -1, 2176, -1, + -1, -1, 2298, -1, -1, 2215, -1, -1, -1, -1, + -1, -1, -1, 2191, -1, 169, 170, 2472, -1, -1, + 2754, -1, -1, -1, -1, -1, 2204, 920, 182, -1, + -1, -1, -1, 2329, -1, -1, -1, 2215, 2248, 297, + -1, -1, -1, -1, 2254, -1, -1, 2343, -1, -1, + -1, 1806, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 215, -1, -1, 218, -1, -1, -1, -1, -1, + 2248, -1, -1, -1, -1, 968, 2254, -1, 232, -1, + 234, 2377, -1, -1, -1, -1, 2896, -1, 2298, -1, + -1, 245, -1, -1, -1, -1, -1, -1, -1, -1, + 17, -1, -1, 20, -1, -1, -1, -1, 25, -1, + 2920, 2566, -1, 30, -1, -1, -1, -1, -1, 2329, + 2298, -1, -1, -1, -1, -1, -1, 385, -1, -1, + 388, 389, 390, 2343, 392, 393, 394, 395, 396, 397, + -1, -1, -1, 297, -1, 403, -1, -1, -1, -1, + -1, 2329, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2896, -1, -1, 2343, -1, 2377, -1, -1, + -1, -1, -1, -1, -1, -1, 2472, -1, -1, -1, + -1, -1, -1, -1, 17, -1, 2920, 1080, -1, -1, + -1, -1, 25, -1, -1, -1, -1, 30, -1, 2377, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 145, -1, + -1, 385, 149, -1, 388, 389, 390, -1, 392, 393, + 394, 395, 396, 397, -1, -1, -1, 2702, -1, 403, + -1, -1, 169, 170, -1, -1, -1, 3067, 2713, -1, + 2015, 2016, 2472, 2018, -1, 182, -1, -1, -1, -1, + 2566, -1, -1, -1, -1, -1, 2031, -1, 2033, 3089, + -1, -1, -1, 3093, 3094, -1, -1, 17, -1, -1, + -1, -1, -1, -1, 2472, 25, -1, -1, 215, 2754, + 30, 218, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 145, -1, -1, 232, 149, 234, -1, 2074, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 3067, -1, -1, 169, 170, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 182, + -1, -1, 3162, -1, -1, 3089, 2566, -1, -1, 3093, + 3094, -1, -1, -1, -1, -1, -1, -1, 2123, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 297, -1, 215, -1, -1, 218, -1, -1, 2566, 17, + -1, -1, 20, 2148, -1, -1, -1, 25, -1, 232, + -1, 131, 30, -1, -1, -1, 2702, -1, -1, 1302, + -1, -1, -1, -1, -1, 145, -1, 2713, -1, 149, + -1, 2176, -1, -1, -1, -1, -1, -1, 3162, -1, + -1, -1, -1, -1, -1, -1, 2191, -1, -1, 169, + 170, 2896, -1, -1, -1, -1, -1, -1, -1, 2204, + -1, -1, 182, -1, -1, -1, -1, -1, 2754, -1, + 2215, 1354, -1, -1, 297, 2920, -1, -1, 385, -1, + -1, 388, 389, 390, -1, 392, 393, 394, 395, 396, + 397, -1, -1, -1, 1377, 215, 403, -1, 218, 1382, + -1, -1, 2702, 2248, -1, -1, -1, -1, -1, 2254, + -1, -1, 232, 2713, 234, -1, -1, -1, -1, 1402, + 1403, -1, -1, 1406, -1, -1, -1, 145, -1, -1, + -1, 149, -1, -1, 2702, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2713, -1, -1, -1, -1, + -1, 169, 170, 2298, 2754, -1, -1, -1, -1, -1, + 1443, -1, 385, -1, 182, 388, 389, 390, -1, 392, + 393, 394, 395, 396, 397, -1, -1, 297, -1, -1, + 403, -1, -1, -1, 2329, -1, 2754, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 215, 2343, -1, + 218, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 2896, -1, -1, -1, 232, -1, 234, -1, -1, -1, + -1, -1, 3067, -1, 1507, -1, -1, -1, -1, -1, + -1, 1514, 2377, 1516, 2920, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 3089, -1, -1, -1, 3093, 3094, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 385, -1, -1, 388, 389, + 390, -1, 392, 393, 394, 395, 396, 397, -1, 297, + -1, 17, -1, 403, -1, -1, -1, -1, -1, 25, + -1, -1, -1, -1, 30, -1, 2896, -1, -1, -1, + -1, -1, -1, 17, -1, -1, -1, -1, -1, -1, + -1, 25, -1, -1, -1, -1, 30, 3162, -1, -1, + 2920, -1, -1, -1, -1, -1, -1, 2472, 2896, -1, + -1, -1, 17, -1, -1, -1, -1, -1, -1, -1, + 25, -1, -1, -1, -1, 30, -1, -1, -1, -1, + -1, -1, 2920, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 385, -1, -1, + 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, + -1, 3067, -1, -1, -1, 403, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 3089, -1, -1, -1, 3093, 3094, 145, + -1, -1, -1, 149, -1, -1, -1, -1, -1, -1, + 25, 2566, -1, -1, -1, 30, -1, -1, -1, -1, + -1, 145, -1, 169, 170, 149, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 182, -1, -1, -1, + -1, -1, -1, -1, -1, 169, 170, -1, -1, -1, + 145, -1, -1, -1, 149, -1, -1, 3067, 182, -1, + -1, -1, -1, -1, -1, -1, 3162, -1, -1, 215, + -1, -1, 218, -1, 169, 170, -1, -1, -1, 3089, + -1, -1, -1, 3093, 3094, -1, 232, 182, 234, 3067, + -1, 215, -1, -1, 218, -1, -1, 112, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 232, -1, + 234, 3089, -1, -1, -1, 3093, 3094, -1, -1, -1, + 215, -1, -1, 218, -1, -1, -1, -1, -1, -1, + 145, -1, -1, -1, 149, 1828, -1, 232, -1, 234, + -1, -1, -1, -1, -1, -1, -1, 2702, -1, -1, + -1, 297, 3162, -1, 169, 170, -1, 1850, 2713, 1852, + -1, 1854, 1855, 1856, -1, -1, 1859, 182, -1, -1, + 1863, -1, -1, 297, -1, -1, -1, 1870, -1, -1, + -1, -1, 1875, -1, 3162, 17, -1, 1880, 20, -1, + -1, -1, 1885, 25, -1, -1, -1, -1, 30, 2754, + -1, 1894, 297, 218, -1, 1898, 1899, 1900, 17, -1, + -1, -1, -1, -1, -1, -1, 25, 232, -1, 1912, + -1, 30, -1, -1, -1, -1, 1919, 322, 1921, 1922, + 1923, 1924, 1925, 1926, 1927, 1928, 1929, -1, 1931, 385, + -1, -1, 388, 389, 390, -1, 392, 393, 394, 395, + 396, 397, -1, -1, 400, -1, -1, 403, -1, -1, + -1, 385, -1, -1, 388, 389, 390, -1, 392, 393, + 394, 395, 396, 397, -1, -1, -1, -1, 402, 403, + -1, -1, 297, -1, -1, -1, -1, -1, -1, -1, + 385, -1, -1, 388, 389, 390, -1, 392, 393, 394, + 395, 396, 397, -1, -1, -1, -1, -1, 403, 2002, + -1, -1, -1, 145, -1, -1, -1, 149, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 17, -1, -1, -1, -1, 145, 169, 170, 25, + 149, 2896, -1, -1, 30, -1, -1, -1, -1, -1, + 182, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 169, 170, -1, -1, -1, 2920, -1, -1, -1, -1, + 385, -1, -1, 182, -1, -1, -1, 392, 393, 394, + 395, 396, 397, 215, -1, -1, 218, -1, 403, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 232, -1, 234, -1, -1, -1, 215, -1, -1, 218, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 232, -1, 234, -1, -1, 2121, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 17, -1, + -1, -1, -1, -1, -1, -1, 25, -1, -1, -1, + -1, 30, -1, -1, -1, -1, -1, -1, 2151, 145, + -1, -1, -1, 149, -1, 297, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 169, 170, -1, -1, -1, 297, -1, + -1, -1, -1, -1, -1, -1, 182, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 3067, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 215, + -1, -1, 218, -1, 3089, -1, -1, -1, 3093, 3094, + -1, -1, -1, -1, -1, -1, 232, -1, 234, -1, + -1, -1, 2245, 385, -1, -1, 388, 389, 390, -1, + 392, 393, 394, 395, 396, 397, 145, -1, -1, 2262, + 149, 403, -1, -1, -1, -1, 385, -1, -1, 388, + 389, 390, -1, 392, 393, 394, 395, 396, 397, -1, + 169, 170, -1, 402, 403, -1, -1, -1, -1, -1, + -1, 2294, -1, 182, -1, -1, -1, 3162, -1, -1, + -1, 297, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2315, 2316, 2317, -1, -1, 2320, 2321, 2322, + 2323, 2324, 2325, 2326, 2327, 2328, 215, 2330, 2331, 218, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 232, -1, 234, -1, -1, -1, -1, + -1, -1, 2355, -1, -1, 2358, -1, 2360, 17, -1, + -1, -1, 2365, 2366, -1, -1, 25, -1, -1, -1, + -1, 30, -1, -1, -1, -1, 2379, 2380, 2381, -1, + 2383, -1, -1, 2386, -1, -1, -1, -1, -1, 385, + -1, -1, 388, 389, 390, -1, 392, 393, 394, 395, + 396, 397, 17, -1, -1, -1, 402, 403, 297, -1, + 25, -1, -1, -1, -1, 30, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 2430, -1, 17, + -1, -1, -1, -1, -1, -1, -1, 25, -1, -1, + -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 145, -1, -1, -1, + 149, -1, 25, -1, -1, -1, 385, 30, -1, 388, + 389, 390, -1, 392, 393, 394, 395, 396, 397, -1, + 169, 170, -1, 402, 403, -1, -1, -1, -1, -1, + -1, -1, -1, 182, -1, -1, -1, -1, -1, -1, + 145, -1, -1, -1, 149, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2555, -1, 169, 170, 215, 145, -1, 218, + -1, 149, -1, -1, -1, -1, -1, 182, -1, -1, + -1, -1, -1, 232, -1, 234, -1, -1, -1, 112, + -1, 169, 170, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 182, -1, -1, -1, -1, -1, + 215, -1, -1, 218, -1, -1, -1, -1, -1, -1, + -1, -1, 145, -1, -1, -1, 149, 232, -1, 234, + -1, -1, -1, -1, -1, -1, -1, 215, -1, -1, + 218, -1, -1, -1, -1, -1, 169, 170, 297, -1, + -1, -1, -1, -1, 232, -1, 234, -1, -1, 182, + -1, -1, -1, -1, 2657, -1, -1, 2660, 2661, 2662, + -1, 2664, -1, -1, -1, -1, 2669, 2670, 2671, 2672, + 2673, 2674, 2675, 2676, 2677, 25, 2679, 2680, 2681, -1, + 30, -1, 297, -1, -1, 218, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 232, + -1, -1, -1, 2706, 2707, 2708, 2709, -1, 2711, 297, + -1, -1, 2715, 2716, 2717, -1, -1, 2720, -1, -1, + 2723, -1, -1, -1, -1, -1, 385, 2730, -1, 388, + 389, 390, -1, 392, 393, 394, 395, 396, 397, -1, + -1, -1, -1, 402, 403, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 112, -1, 297, -1, -1, -1, -1, -1, + 385, -1, -1, 388, 389, 390, -1, 392, 393, 394, + 395, 396, 397, -1, -1, -1, -1, 402, 403, -1, + -1, -1, -1, -1, -1, 145, -1, 385, -1, 149, + 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, + -1, -1, -1, -1, 402, 403, -1, -1, -1, 169, + 170, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 182, 2836, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 385, -1, -1, -1, -1, -1, -1, 392, + 393, 394, 395, 396, 397, -1, -1, -1, 218, -1, + 403, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 232, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 2912, + -1, -1, -1, 2916, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 2928, -1, 2930, -1, -1, + -1, -1, 2935, 2936, 2937, -1, -1, 2940, 2941, 2942, + 2943, -1, 2945, -1, -1, -1, -1, 297, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 3008, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 385, -1, -1, -1, -1, + -1, -1, 392, 393, 394, 395, 396, 397, 3051, -1, + -1, -1, -1, 403, -1, -1, -1, -1, -1, -1, + -1, -1, 3065, 3066, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 3079, 3080, 3081, -1, + 3083, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 3096, -1, -1, 3, 4, 5, 6, + 7, 8, 9, 10, -1, 12, 13, 14, -1, -1, + -1, -1, -1, -1, -1, 22, 23, -1, 25, -1, + 27, 28, 29, -1, 31, -1, 33, 34, -1, 36, + 37, 38, 39, 40, -1, 3138, 43, 44, 45, 46, + -1, 48, 49, 50, 51, 52, -1, 3150, 55, 56, + 57, 58, 59, 60, -1, 62, 63, 64, 65, 66, + -1, 68, 69, 70, -1, 72, 73, -1, -1, -1, + -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, + -1, 88, -1, 90, 91, 92, 93, 94, -1, 96, + 97, 98, -1, -1, 101, 102, 103, 104, 105, -1, + 107, 108, 109, -1, 111, 112, -1, 114, 115, 116, + 117, 118, 119, 120, -1, 122, 123, 124, 125, -1, + 127, -1, 129, -1, -1, -1, 133, 134, -1, 136, + 137, -1, 139, -1, 141, 142, 143, 144, -1, 146, + 147, 148, -1, 150, 151, 152, 153, 154, 155, -1, + -1, 158, 159, 160, 161, 162, 163, 164, -1, 166, + -1, 168, -1, -1, 171, -1, 173, 174, 175, 176, + 177, -1, 179, -1, 181, -1, -1, 184, 185, 186, + -1, -1, 189, 190, 191, 192, 193, 194, 195, 196, + 197, 198, 199, 200, 201, 202, -1, 204, -1, 206, + 207, 208, 209, 210, 211, 212, 213, 214, -1, 216, + 217, -1, 219, -1, 221, 222, 223, 224, 225, -1, + -1, 228, -1, -1, -1, 232, 233, -1, -1, 236, + -1, -1, 239, 240, 241, 242, 243, 244, -1, 246, + 247, 248, 249, 250, 251, -1, 253, 254, 255, 256, + 257, 258, 259, 260, 261, -1, 263, 264, 265, 266, + 267, 268, 269, 270, 271, 272, -1, 274, 275, -1, + 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, + 287, -1, 289, 290, 291, -1, 293, 294, 295, 296, + -1, 298, 299, -1, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, -1, 314, 315, -1, + 317, 318, 319, 320, 321, -1, 323, 324, -1, -1, + 327, 328, 329, 330, -1, 332, 333, 334, 335, 336, + -1, -1, 339, 340, 341, 342, -1, 344, 345, 346, + 347, 348, 349, 350, 351, -1, 353, 354, 355, -1, + -1, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 367, 368, 369, 370, 371, 372, 373, 374, -1, -1, + -1, -1, -1, 380, -1, -1, -1, -1, -1, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, -1, 399, -1, -1, 19, -1, 404, 22, 23, + -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, 99, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, -1, 127, -1, 129, 130, -1, 132, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, 145, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, 157, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, -1, 179, 180, 181, 182, -1, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, -1, -1, 228, 229, -1, -1, 232, 233, + -1, -1, 236, 237, 238, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, 292, 293, + 294, 295, 296, 297, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, 331, 332, 333, + 334, 335, 336, -1, 338, 339, 340, 341, 342, 343, + -1, 345, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 381, 382, 383, + 384, 385, 386, 387, -1, -1, -1, -1, 392, 393, + 394, -1, -1, -1, -1, -1, -1, 401, 402, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, 19, -1, -1, 22, 23, + -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, -1, 127, -1, 129, 130, -1, 132, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, 145, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, 157, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, -1, 179, 180, 181, 182, -1, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, -1, -1, 228, 229, -1, -1, 232, 233, + -1, -1, 236, 237, 238, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, 292, 293, + 294, 295, 296, 297, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, 331, 332, 333, + 334, 335, 336, -1, 338, 339, 340, 341, 342, 343, + -1, 345, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 381, 382, 383, + 384, 385, 386, 387, -1, -1, -1, -1, 392, 393, + -1, -1, -1, -1, -1, -1, -1, 401, 402, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, 20, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, 71, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, 132, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, 157, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, 172, 173, + 174, 175, 176, 177, -1, 179, 180, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, 402, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, -1, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, 71, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, -1, 118, 119, -1, -1, 122, 123, 124, 125, + -1, 127, -1, 129, 130, -1, 132, 133, 134, -1, + 136, -1, -1, 139, -1, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, + -1, 157, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, -1, -1, 180, 181, 182, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, -1, + 206, 207, 208, 209, 210, 211, 212, -1, 214, -1, + 216, 217, 218, 219, -1, -1, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, 237, 238, -1, 240, 241, 242, 243, 244, -1, + 246, -1, -1, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + 276, 277, 278, -1, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, 297, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, -1, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, -1, 329, -1, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, -1, 350, 351, 352, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, -1, -1, + -1, -1, -1, -1, -1, -1, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, 19, -1, -1, 22, 23, 402, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, -1, 127, + -1, 129, 130, 131, 132, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, 145, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, 157, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + 178, 179, 180, 181, 182, -1, 184, 185, 186, 187, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, + 218, 219, 220, 221, 222, 223, 224, 225, -1, -1, + 228, 229, -1, -1, 232, 233, -1, -1, 236, 237, + 238, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, 276, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, 292, 293, 294, 295, 296, 297, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, 326, 327, + 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, + 338, 339, 340, 341, 342, 343, -1, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 381, 382, 383, 384, 385, 386, 387, + -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, + -1, -1, -1, 401, 3, 4, 5, 6, 7, 8, + 9, 10, -1, 12, 13, 14, -1, -1, -1, -1, + 19, -1, -1, 22, 23, -1, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, -1, 48, + 49, 50, 51, 52, -1, -1, 55, 56, 57, 58, + 59, 60, -1, 62, 63, 64, 65, 66, -1, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, -1, 88, + -1, 90, 91, 92, 93, 94, -1, 96, 97, 98, + -1, -1, 101, 102, 103, 104, 105, -1, 107, 108, + 109, -1, 111, 112, -1, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 123, 124, 125, -1, 127, -1, + 129, 130, -1, 132, 133, 134, -1, 136, 137, -1, + 139, -1, 141, 142, 143, 144, 145, 146, 147, 148, + -1, 150, 151, 152, 153, 154, 155, -1, 157, 158, + 159, 160, 161, 162, 163, 164, -1, 166, -1, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, -1, + 179, 180, 181, 182, -1, 184, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, + 219, 220, 221, 222, 223, 224, 225, -1, -1, 228, + 229, -1, -1, 232, 233, -1, -1, 236, 237, 238, + 239, 240, 241, 242, 243, 244, -1, 246, 247, 248, + 249, 250, 251, -1, 253, 254, 255, 256, 257, 258, + 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, -1, 274, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, 285, 286, 287, -1, + 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, + 299, -1, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, -1, 314, 315, -1, 317, 318, + 319, 320, 321, -1, 323, 324, -1, -1, 327, 328, + 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, + 339, 340, 341, 342, 343, -1, 345, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, -1, -1, 358, + 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, + 369, 370, 371, 372, 373, 374, -1, -1, -1, -1, + -1, 380, 381, 382, 383, 384, 385, 386, 387, -1, + -1, -1, -1, 392, 393, 394, -1, -1, -1, -1, + -1, -1, 401, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, 19, + -1, -1, 22, 23, -1, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, -1, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, -1, 127, -1, 129, + 130, -1, 132, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, 145, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, 157, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, -1, 179, + 180, 181, 182, -1, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, -1, -1, 228, 229, + -1, -1, 232, 233, -1, -1, 236, 237, 238, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, 331, 332, 333, 334, 335, 336, -1, 338, 339, + 340, 341, 342, 343, -1, 345, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 381, 382, 383, 384, 385, 386, 387, -1, -1, + -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, + -1, 401, 3, 4, 5, 6, 7, 8, 9, 10, + -1, 12, 13, 14, -1, -1, -1, -1, 19, -1, + -1, 22, 23, -1, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, -1, 48, 49, 50, + 51, 52, -1, -1, 55, 56, 57, 58, 59, 60, + -1, 62, 63, 64, 65, 66, -1, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, -1, 88, -1, 90, + 91, 92, 93, 94, -1, 96, 97, 98, -1, -1, + 101, 102, 103, 104, 105, -1, 107, 108, 109, -1, + 111, 112, -1, 114, 115, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, -1, 127, -1, 129, 130, + -1, 132, 133, 134, -1, 136, 137, -1, 139, -1, + 141, 142, 143, 144, 145, 146, 147, 148, -1, 150, + 151, 152, 153, 154, 155, -1, 157, 158, 159, 160, + 161, 162, 163, 164, -1, 166, -1, 168, 169, 170, + 171, 172, 173, 174, 175, 176, 177, -1, 179, 180, + 181, 182, -1, 184, 185, 186, 187, 188, 189, 190, + 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, + 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + 221, 222, 223, 224, 225, -1, -1, 228, 229, -1, + -1, 232, 233, -1, -1, 236, 237, 238, 239, 240, + 241, 242, 243, 244, -1, 246, 247, 248, 249, 250, + 251, -1, 253, 254, 255, 256, 257, 258, 259, 260, + 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, -1, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, + 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, -1, 314, 315, -1, 317, 318, 319, 320, + 321, -1, 323, 324, -1, -1, 327, 328, 329, 330, + 331, 332, 333, 334, 335, 336, -1, 338, 339, 340, + 341, 342, 343, -1, 345, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, -1, -1, 358, 359, 360, + 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, + 371, 372, 373, 374, -1, -1, -1, -1, -1, 380, + 381, 382, 383, 384, 385, 386, 387, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, + 401, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, -1, -1, -1, -1, 19, -1, -1, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, 121, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, 179, 180, 181, + 182, -1, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, -1, + 232, 233, -1, -1, 236, 237, 238, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + 292, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, 331, + 332, 333, 334, 335, 336, -1, 338, 339, 340, 341, + 342, 343, -1, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 381, + 382, 383, 384, 385, 386, 387, -1, -1, -1, -1, + 392, 393, -1, -1, -1, -1, -1, -1, -1, 401, + 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, + 13, 14, -1, -1, -1, -1, 19, -1, -1, 22, + 23, -1, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, -1, 48, 49, 50, 51, 52, + -1, -1, 55, 56, 57, 58, 59, 60, -1, 62, + 63, 64, 65, 66, -1, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, -1, 88, -1, 90, 91, 92, + 93, 94, -1, 96, 97, 98, -1, -1, 101, 102, + 103, 104, 105, -1, 107, 108, 109, -1, 111, 112, + -1, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, -1, 127, -1, 129, 130, -1, 132, + 133, 134, -1, 136, 137, -1, 139, -1, 141, 142, + 143, 144, 145, 146, 147, 148, -1, 150, 151, 152, + 153, 154, 155, -1, 157, 158, 159, 160, 161, 162, + 163, 164, -1, 166, -1, 168, 169, 170, 171, 172, + 173, 174, 175, 176, 177, -1, 179, 180, 181, 182, + -1, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, + 223, 224, 225, -1, -1, 228, 229, -1, -1, 232, + 233, -1, -1, 236, 237, 238, 239, 240, 241, 242, + 243, 244, -1, 246, 247, 248, 249, 250, 251, -1, + 253, 254, 255, 256, 257, 258, 259, 260, 261, -1, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + -1, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, -1, 289, 290, 291, 292, + 293, 294, 295, 296, 297, 298, 299, -1, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + -1, 314, 315, -1, 317, 318, 319, 320, 321, -1, + 323, 324, -1, -1, 327, 328, 329, 330, 331, 332, + 333, 334, 335, 336, -1, 338, 339, 340, 341, 342, + 343, -1, 345, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, -1, -1, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, + 373, 374, -1, -1, -1, -1, -1, 380, 381, 382, + 383, 384, 385, 386, 387, -1, -1, -1, -1, 392, + 393, -1, -1, -1, -1, -1, 399, -1, 401, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, 19, -1, -1, 22, 23, + -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, -1, 127, -1, 129, 130, 131, 132, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, 145, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, 157, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, -1, 179, 180, 181, 182, -1, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, -1, -1, 228, 229, -1, -1, 232, 233, + -1, -1, 236, 237, 238, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, 292, 293, + 294, 295, 296, 297, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, 331, 332, 333, + 334, 335, 336, -1, 338, 339, 340, 341, 342, 343, + -1, 345, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 381, 382, 383, + 384, 385, 386, 387, -1, -1, -1, -1, 392, 393, + -1, -1, -1, -1, -1, -1, -1, 401, 3, 4, + 5, 6, 7, 8, 9, 10, -1, 12, 13, 14, + -1, -1, -1, -1, 19, -1, -1, 22, 23, -1, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, -1, 48, 49, 50, 51, 52, -1, -1, + 55, 56, 57, 58, 59, 60, -1, 62, 63, 64, + 65, 66, -1, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, -1, 88, -1, 90, 91, 92, 93, 94, + -1, 96, 97, 98, -1, -1, 101, 102, 103, 104, + 105, -1, 107, 108, 109, -1, 111, 112, -1, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, -1, 127, -1, 129, 130, -1, 132, 133, 134, + -1, 136, 137, -1, 139, -1, 141, 142, 143, 144, + 145, 146, 147, 148, -1, 150, 151, 152, 153, 154, + 155, -1, 157, 158, 159, 160, 161, 162, 163, 164, + -1, 166, -1, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, -1, 179, 180, 181, 182, -1, 184, + 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 225, -1, -1, 228, 229, -1, -1, 232, 233, -1, + -1, 236, 237, 238, 239, 240, 241, 242, 243, 244, + -1, 246, 247, 248, 249, 250, 251, -1, 253, 254, + 255, 256, 257, 258, 259, 260, 261, -1, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, -1, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, -1, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, -1, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, -1, 314, + 315, -1, 317, 318, 319, 320, 321, -1, 323, 324, + -1, -1, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, -1, 338, 339, 340, 341, 342, 343, -1, + 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, -1, -1, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + -1, -1, -1, -1, -1, 380, 381, 382, 383, 384, + 385, 386, 387, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, -1, 401, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, 19, -1, -1, 22, 23, -1, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, + -1, 127, -1, 129, 130, -1, 132, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, 145, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, 157, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, -1, 179, 180, 181, 182, -1, 184, 185, + 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, + 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, + -1, -1, 228, 229, -1, -1, 232, 233, -1, -1, + 236, 237, 238, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, 292, 293, 294, 295, + 296, 297, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, 331, 332, 333, 334, 335, + 336, -1, 338, 339, 340, 341, 342, 343, -1, 345, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 381, 382, 383, 384, 385, + 386, 387, -1, -1, -1, -1, 392, 393, -1, -1, + -1, -1, -1, -1, -1, 401, 3, 4, 5, 6, + 7, 8, 9, 10, -1, 12, 13, 14, -1, -1, + -1, -1, 19, -1, -1, 22, 23, -1, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + -1, 48, 49, 50, 51, 52, -1, -1, 55, 56, + 57, 58, 59, 60, -1, 62, 63, 64, 65, 66, + -1, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + -1, 88, -1, 90, 91, 92, 93, 94, -1, 96, + 97, 98, -1, -1, 101, 102, 103, 104, 105, -1, + 107, 108, 109, -1, 111, 112, -1, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, -1, + 127, -1, 129, 130, -1, 132, 133, 134, -1, 136, + 137, -1, 139, -1, 141, 142, 143, 144, 145, 146, + 147, 148, -1, 150, 151, 152, 153, 154, 155, -1, + 157, 158, 159, 160, 161, 162, 163, 164, -1, 166, + -1, 168, 169, 170, 171, 172, 173, 174, 175, 176, + 177, -1, 179, 180, 181, 182, -1, 184, 185, 186, + 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, + 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, + 217, 218, 219, 220, 221, 222, 223, 224, 225, -1, + -1, 228, 229, -1, -1, 232, 233, -1, -1, 236, + 237, 238, 239, 240, 241, 242, 243, 244, -1, 246, + 247, 248, 249, 250, 251, -1, 253, 254, 255, 256, + 257, 258, 259, 260, 261, -1, 263, 264, 265, 266, + 267, 268, 269, 270, 271, 272, -1, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, + 287, -1, 289, 290, 291, 292, 293, 294, 295, 296, + 297, 298, 299, -1, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, -1, 314, 315, -1, + 317, 318, 319, 320, 321, -1, 323, 324, -1, -1, + 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, + -1, 338, 339, 340, 341, 342, 343, -1, 345, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, -1, + -1, 358, 359, 360, 361, 362, 363, 364, 365, 366, + 367, 368, 369, 370, 371, 372, 373, 374, -1, -1, + -1, -1, -1, 380, 381, 382, 383, 384, 385, 386, + 387, -1, -1, -1, -1, 392, 393, -1, -1, -1, + -1, -1, -1, -1, 401, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, 19, -1, -1, 22, 23, -1, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, -1, 127, + -1, 129, 130, -1, 132, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, 145, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, 157, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + -1, 179, 180, 181, 182, -1, 184, 185, 186, 187, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, + 218, 219, 220, 221, 222, 223, 224, 225, -1, -1, + 228, 229, -1, -1, 232, 233, -1, -1, 236, 237, + 238, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, 276, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, 292, 293, 294, 295, 296, 297, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, + 338, 339, 340, 341, 342, 343, -1, 345, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 381, 382, 383, 384, 385, 386, 387, + -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, + -1, -1, -1, 401, 3, 4, 5, 6, 7, 8, + 9, 10, -1, 12, 13, 14, -1, -1, -1, -1, + 19, -1, -1, 22, 23, -1, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, -1, 48, + 49, 50, 51, 52, -1, -1, 55, 56, 57, 58, + 59, 60, -1, 62, 63, 64, 65, 66, -1, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, -1, 88, + -1, 90, 91, 92, 93, 94, -1, 96, 97, 98, + -1, -1, 101, 102, 103, 104, 105, -1, 107, 108, + 109, -1, 111, 112, -1, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 123, 124, 125, -1, 127, -1, + 129, 130, -1, 132, 133, 134, -1, 136, 137, -1, + 139, -1, 141, 142, 143, 144, 145, 146, 147, 148, + -1, 150, 151, 152, 153, 154, 155, -1, 157, 158, + 159, 160, 161, 162, 163, 164, -1, 166, -1, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, -1, + 179, 180, 181, 182, -1, 184, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 210, 211, 212, 213, 214, -1, 216, 217, 218, + 219, 220, 221, 222, 223, 224, 225, -1, -1, 228, + 229, -1, -1, 232, 233, -1, -1, 236, 237, 238, + 239, 240, 241, 242, 243, 244, -1, 246, 247, 248, + 249, 250, 251, -1, 253, 254, 255, 256, 257, 258, + 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, -1, 274, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, 285, 286, 287, -1, + 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, + 299, -1, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, -1, 314, 315, -1, 317, 318, + 319, 320, 321, -1, 323, 324, -1, -1, 327, 328, + 329, 330, 331, 332, 333, 334, 335, 336, -1, -1, + 339, 340, 341, 342, 343, -1, 345, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, -1, -1, 358, + 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, + 369, 370, 371, 372, 373, 374, -1, -1, -1, -1, + -1, 380, 381, 382, 383, 384, 385, 386, 387, -1, + -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, + -1, -1, 401, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, 19, + -1, -1, 22, 23, -1, 25, 26, 27, 28, 29, + -1, 31, 32, 33, 34, -1, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, -1, -1, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, -1, 127, -1, 129, + 130, -1, 132, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, 157, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, -1, 179, + 180, 181, -1, -1, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, -1, -1, 228, 229, + -1, -1, 232, 233, -1, -1, 236, 237, 238, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, 292, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, 331, 332, 333, 334, 335, 336, -1, 338, 339, + 340, 341, 342, 343, -1, 345, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 381, 382, 383, 384, 385, 386, 387, -1, -1, + -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, + -1, 401, 3, 4, 5, 6, 7, 8, 9, 10, + -1, 12, 13, 14, -1, -1, -1, -1, 19, -1, + -1, 22, 23, -1, 25, 26, 27, 28, 29, -1, + 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, -1, 48, 49, 50, + 51, 52, -1, -1, 55, 56, 57, 58, 59, 60, + -1, 62, 63, 64, 65, 66, -1, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, -1, 88, -1, 90, + 91, 92, 93, 94, -1, 96, 97, 98, -1, -1, + 101, 102, 103, 104, 105, -1, 107, 108, 109, -1, + 111, -1, -1, 114, 115, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, -1, 127, -1, 129, 130, + -1, 132, 133, 134, -1, 136, 137, -1, 139, -1, + 141, 142, 143, 144, -1, 146, 147, 148, -1, 150, + 151, 152, 153, 154, 155, -1, 157, 158, 159, 160, + 161, 162, 163, 164, -1, 166, -1, 168, 169, 170, + 171, 172, 173, 174, 175, 176, 177, -1, 179, 180, + 181, -1, -1, 184, 185, 186, 187, 188, 189, 190, + 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, + 211, 212, 213, 214, -1, 216, 217, 218, 219, 220, + 221, 222, 223, 224, 225, -1, -1, 228, 229, -1, + -1, 232, 233, -1, -1, 236, 237, 238, 239, 240, + 241, 242, 243, 244, -1, 246, 247, 248, 249, 250, + 251, -1, 253, 254, 255, 256, 257, 258, 259, 260, + 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, -1, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 283, 284, 285, 286, 287, -1, 289, 290, + 291, 292, 293, 294, 295, 296, -1, 298, 299, -1, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, -1, 314, 315, -1, 317, 318, 319, 320, + 321, -1, 323, 324, -1, -1, 327, 328, 329, 330, + 331, 332, 333, 334, 335, 336, -1, -1, 339, 340, + 341, 342, 343, -1, 345, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, -1, -1, 358, 359, 360, + 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, + 371, 372, 373, 374, -1, -1, -1, -1, -1, 380, + 381, 382, 383, 384, 385, 386, 387, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, + 401, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, -1, + 42, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, 179, 180, 181, + 182, -1, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, 218, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, 231, + 232, 233, -1, -1, 236, 237, 238, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, + 292, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, 343, -1, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, -1, + 42, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, 179, 180, 181, + 182, -1, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, 218, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, 231, + 232, 233, -1, -1, 236, 237, 238, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + 292, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, 343, -1, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, -1, + 42, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, 179, 180, 181, + 182, -1, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, 218, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, -1, + 232, 233, -1, -1, 236, 237, 238, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + 292, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, 343, -1, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, 179, 180, 181, + 182, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, 218, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, -1, + 232, 233, -1, -1, 236, 237, 238, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 401, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 401, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, -1, 118, 119, -1, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, -1, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, -1, 159, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, + 173, 174, 175, 176, 177, 178, -1, 180, 181, 182, + 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + -1, 214, 215, 216, 217, 218, 219, 220, -1, 222, + 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, + 233, 234, 235, -1, 237, 238, -1, 240, 241, 242, + 243, 244, 245, 246, -1, -1, 249, 250, 251, 252, + 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 275, 276, 277, 278, -1, 280, 281, 282, + 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, + 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, -1, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 324, 325, 326, 327, -1, 329, -1, 331, 332, + 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, + 343, 344, 345, 346, 347, 348, -1, 350, 351, 352, + 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, + 363, -1, -1, -1, -1, -1, -1, -1, -1, 372, + 373, 374, -1, -1, -1, -1, -1, 380, 381, 382, + -1, -1, 385, 386, -1, 388, 389, 390, -1, 392, + 393, 394, 395, 396, 397, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, -1, -1, -1, -1, 385, -1, -1, + 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, + 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, + 13, 14, -1, -1, -1, -1, -1, -1, -1, 22, + 23, -1, 25, -1, 27, 28, 29, -1, 31, -1, + 33, 34, -1, 36, 37, 38, 39, 40, -1, -1, + 43, 44, 45, 46, -1, 48, 49, 50, 51, 52, + -1, -1, 55, 56, 57, 58, 59, 60, -1, 62, + 63, 64, 65, 66, -1, 68, 69, 70, -1, 72, + 73, -1, -1, -1, -1, -1, 79, 80, 81, 82, + 83, 84, 85, 86, -1, 88, -1, 90, 91, 92, + 93, 94, -1, 96, 97, 98, -1, -1, 101, 102, + 103, 104, 105, -1, 107, 108, 109, -1, 111, 112, + -1, 114, 115, 116, 117, 118, 119, 120, -1, 122, + 123, 124, 125, -1, 127, -1, 129, -1, -1, -1, + 133, 134, -1, 136, 137, -1, 139, -1, 141, 142, + 143, 144, -1, 146, 147, 148, -1, 150, 151, 152, + 153, 154, 155, -1, -1, 158, 159, 160, 161, 162, + 163, 164, -1, 166, -1, 168, -1, -1, 171, -1, + 173, 174, 175, 176, 177, -1, 179, -1, 181, -1, + -1, 184, 185, 186, -1, -1, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + -1, 204, -1, 206, 207, 208, 209, 210, 211, 212, + 213, 214, -1, 216, 217, -1, 219, -1, 221, 222, + 223, 224, 225, -1, -1, 228, -1, -1, -1, 232, + 233, -1, -1, 236, -1, -1, 239, 240, 241, 242, + 243, 244, -1, 246, 247, 248, 249, 250, 251, -1, + 253, 254, 255, 256, 257, 258, 259, 260, 261, -1, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + -1, 274, 275, -1, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, -1, 289, 290, 291, -1, + 293, 294, 295, 296, -1, 298, 299, -1, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + -1, 314, 315, -1, 317, 318, 319, 320, 321, -1, + 323, 324, -1, -1, 327, 328, 329, 330, -1, 332, + 333, 334, 335, 336, -1, -1, 339, 340, 341, 342, + -1, -1, 345, 346, 347, 348, 349, 350, 351, -1, + 353, 354, 355, -1, -1, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, + 373, 374, -1, -1, -1, -1, -1, 380, -1, -1, + -1, -1, 385, -1, -1, 388, 389, 390, -1, 392, + 393, 394, 395, 396, 397, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, -1, -1, -1, -1, 385, -1, -1, + 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, + 3, 4, 5, 6, 7, 8, 9, 10, -1, 12, + 13, 14, -1, -1, -1, -1, -1, -1, -1, 22, + 23, -1, 25, -1, 27, 28, 29, -1, 31, -1, + 33, 34, -1, 36, 37, 38, 39, 40, -1, -1, + 43, 44, 45, 46, -1, 48, 49, 50, 51, 52, + -1, -1, 55, 56, 57, 58, 59, 60, -1, 62, + 63, 64, 65, 66, -1, 68, 69, 70, -1, 72, + 73, -1, -1, -1, -1, -1, 79, 80, 81, 82, + 83, 84, 85, 86, -1, 88, -1, 90, 91, 92, + 93, 94, -1, 96, 97, 98, -1, -1, 101, 102, + 103, 104, 105, -1, 107, 108, 109, -1, 111, 112, + -1, 114, 115, 116, 117, 118, 119, 120, -1, 122, + 123, 124, 125, -1, 127, -1, 129, -1, -1, -1, + 133, 134, -1, 136, 137, -1, 139, -1, 141, 142, + 143, 144, -1, 146, 147, 148, -1, 150, 151, 152, + 153, 154, 155, -1, -1, 158, 159, 160, 161, 162, + 163, 164, -1, 166, -1, 168, -1, -1, 171, -1, + 173, 174, 175, 176, 177, -1, 179, -1, 181, -1, + -1, 184, 185, 186, -1, -1, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + -1, 204, -1, 206, 207, 208, 209, 210, 211, 212, + 213, 214, -1, 216, 217, -1, 219, -1, 221, 222, + 223, 224, 225, -1, -1, 228, -1, -1, -1, 232, + 233, -1, -1, 236, -1, -1, 239, 240, 241, 242, + 243, 244, -1, 246, 247, 248, 249, 250, 251, -1, + 253, 254, 255, 256, 257, 258, 259, 260, 261, -1, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + -1, 274, 275, -1, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, -1, 289, 290, 291, -1, + 293, 294, 295, 296, -1, 298, 299, -1, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + -1, 314, 315, -1, 317, 318, 319, 320, 321, -1, + 323, 324, -1, -1, 327, 328, 329, 330, -1, 332, + 333, 334, 335, 336, -1, -1, 339, 340, 341, 342, + -1, -1, 345, 346, 347, 348, 349, 350, 351, -1, + 353, 354, 355, -1, -1, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, + 373, 374, -1, -1, -1, -1, -1, 380, -1, -1, + -1, -1, 385, -1, -1, 388, 389, 390, -1, 392, + 393, 394, 395, 396, 397, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, -1, -1, -1, -1, 385, -1, -1, + 388, 389, 390, -1, 392, 393, 394, 395, 396, 397, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, + 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, + 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, + 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, + 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, + 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, + 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, + 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, + 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, + 373, 374, -1, -1, -1, -1, -1, 380, 3, 4, + 5, 6, 7, 8, 9, 10, -1, 12, 13, 14, + -1, 394, -1, -1, -1, -1, -1, 22, 23, -1, + 25, -1, 27, 28, 29, -1, 31, -1, 33, 34, + -1, 36, 37, 38, 39, 40, -1, -1, 43, 44, + 45, 46, -1, 48, 49, 50, 51, 52, -1, -1, + 55, 56, 57, 58, 59, 60, -1, 62, 63, 64, + 65, 66, -1, 68, 69, 70, -1, 72, 73, -1, + -1, -1, -1, -1, 79, 80, 81, 82, 83, 84, + 85, 86, -1, 88, -1, 90, 91, 92, 93, 94, + -1, 96, 97, 98, -1, -1, 101, 102, 103, 104, + 105, -1, 107, 108, 109, -1, 111, 112, -1, 114, + 115, 116, 117, 118, 119, 120, -1, 122, 123, 124, + 125, -1, 127, -1, 129, -1, -1, -1, 133, 134, + -1, 136, 137, -1, 139, -1, 141, 142, 143, 144, + -1, 146, 147, 148, -1, 150, 151, 152, 153, 154, + 155, -1, -1, 158, 159, 160, 161, 162, 163, 164, + -1, 166, -1, 168, -1, -1, 171, -1, 173, 174, + 175, 176, 177, -1, 179, -1, 181, -1, -1, 184, + 185, 186, -1, -1, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, -1, 204, + -1, 206, 207, 208, 209, 210, 211, 212, 213, 214, + -1, 216, 217, -1, 219, -1, 221, 222, 223, 224, + 225, -1, -1, 228, -1, -1, -1, 232, 233, -1, + -1, 236, -1, -1, 239, 240, 241, 242, 243, 244, + -1, 246, 247, 248, 249, 250, 251, -1, 253, 254, + 255, 256, 257, 258, 259, 260, 261, -1, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, -1, 274, + 275, -1, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, -1, 289, 290, 291, -1, 293, 294, + 295, 296, -1, 298, 299, -1, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, -1, 314, + 315, -1, 317, 318, 319, 320, 321, -1, 323, 324, + -1, -1, 327, 328, 329, 330, -1, 332, 333, 334, + 335, 336, -1, -1, 339, 340, 341, 342, -1, -1, + 345, 346, 347, 348, 349, 350, 351, -1, 353, 354, + 355, -1, -1, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + -1, -1, -1, -1, -1, 380, 3, 4, 5, 6, + 7, 8, 9, 10, -1, 12, 13, 14, -1, 394, + -1, -1, -1, -1, -1, 22, 23, -1, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -1, 36, + 37, 38, 39, 40, -1, -1, 43, 44, 45, 46, + -1, 48, 49, 50, 51, -1, -1, -1, 55, 56, + 57, 58, 59, 60, -1, 62, 63, 64, 65, 66, + -1, 68, 69, 70, 71, 72, 73, -1, -1, -1, + -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, + -1, 88, -1, 90, 91, 92, 93, 94, -1, 96, + 97, 98, -1, -1, 101, 102, 103, 104, 105, -1, + 107, 108, 109, -1, 111, 112, -1, 114, 115, 116, + -1, 118, 119, -1, -1, 122, 123, 124, 125, -1, + 127, -1, 129, 130, -1, 132, 133, 134, -1, 136, + -1, -1, 139, -1, 141, 142, 143, 144, 145, 146, + 147, 148, -1, 150, 151, 152, 153, 154, 155, -1, + 157, -1, 159, 160, 161, 162, 163, 164, -1, 166, + -1, 168, 169, 170, 171, 172, 173, 174, 175, 176, + 177, -1, -1, 180, 181, 182, -1, 184, 185, 186, + -1, -1, 189, 190, 191, 192, 193, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, -1, 206, + 207, 208, 209, 210, 211, 212, -1, 214, -1, 216, + 217, 218, 219, -1, -1, 222, 223, 224, 225, -1, + -1, 228, -1, -1, -1, 232, 233, -1, -1, -1, + 237, 238, -1, 240, 241, 242, 243, 244, -1, 246, + -1, -1, 249, 250, 251, -1, 253, 254, 255, 256, + 257, 258, 259, 260, 261, -1, 263, 264, 265, 266, + 267, 268, 269, 270, 271, 272, -1, 274, 275, 276, + 277, 278, -1, 280, 281, 282, 283, 284, 285, 286, + 287, -1, 289, 290, 291, -1, 293, 294, 295, 296, + 297, 298, 299, -1, 301, 302, 303, 304, 305, 306, + 307, 308, 309, 310, -1, 312, -1, 314, 315, -1, + 317, 318, 319, 320, 321, -1, 323, 324, -1, -1, + 327, -1, 329, -1, -1, 332, 333, 334, 335, 336, + -1, -1, 339, 340, 341, 342, -1, -1, 345, 346, + 347, 348, -1, 350, 351, 352, 353, 354, 355, -1, + -1, 358, 359, 360, 361, 362, 363, -1, -1, -1, + -1, -1, -1, -1, -1, 372, 373, 374, -1, -1, + -1, -1, -1, 380, 3, 4, 5, 6, 7, 8, + 9, 10, -1, 12, 13, 14, -1, 394, -1, -1, + -1, -1, -1, 22, 23, -1, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, 36, 37, 38, + 39, 40, -1, -1, 43, 44, 45, 46, -1, 48, + 49, 50, 51, -1, -1, -1, 55, 56, 57, 58, + 59, 60, -1, 62, 63, 64, 65, 66, -1, 68, + 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, + 79, 80, 81, 82, 83, 84, 85, 86, -1, 88, + -1, 90, 91, 92, 93, 94, -1, 96, 97, 98, + -1, -1, 101, 102, 103, 104, 105, -1, 107, 108, + 109, -1, 111, 112, -1, 114, 115, 116, -1, 118, + 119, -1, -1, 122, 123, 124, 125, -1, 127, -1, + 129, 130, -1, 132, 133, 134, -1, 136, -1, -1, + 139, -1, 141, 142, 143, 144, 145, 146, 147, 148, + -1, 150, 151, 152, 153, 154, 155, -1, 157, -1, + 159, 160, 161, 162, 163, 164, -1, 166, -1, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, -1, + -1, 180, 181, 182, -1, 184, 185, 186, -1, -1, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, -1, 206, 207, 208, + 209, 210, 211, 212, -1, 214, -1, 216, 217, 218, + 219, -1, -1, 222, 223, 224, 225, -1, -1, 228, + -1, -1, -1, 232, 233, -1, -1, -1, 237, 238, + -1, 240, 241, 242, 243, 244, -1, 246, -1, -1, + 249, 250, 251, -1, 253, 254, 255, 256, 257, 258, + 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, -1, 274, 275, 276, 277, 278, + -1, 280, 281, 282, 283, 284, 285, 286, 287, -1, + 289, 290, 291, -1, 293, 294, 295, 296, 297, 298, + 299, -1, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, -1, 312, -1, 314, 315, -1, 317, 318, + 319, 320, 321, -1, 323, 324, -1, -1, 327, -1, + 329, -1, -1, 332, 333, 334, 335, 336, -1, -1, + 339, 340, 341, 342, -1, -1, 345, 346, 347, 348, + -1, 350, 351, 352, 353, 354, 355, -1, -1, 358, + 359, 360, 361, 362, 363, -1, -1, -1, -1, -1, + -1, -1, -1, 372, 373, 374, -1, -1, -1, -1, + -1, 380, 3, 4, 5, 6, 7, 8, 9, 10, + -1, 12, 13, 14, -1, 394, -1, -1, -1, -1, + -1, 22, 23, -1, 25, -1, 27, 28, 29, -1, + 31, -1, 33, 34, -1, 36, 37, 38, 39, 40, + -1, -1, 43, 44, 45, 46, -1, 48, 49, 50, + 51, 52, -1, -1, 55, 56, 57, 58, 59, 60, + -1, 62, 63, 64, 65, 66, -1, 68, 69, 70, + -1, 72, 73, -1, -1, -1, -1, -1, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, -1, 90, + 91, 92, 93, 94, -1, 96, 97, 98, -1, -1, + 101, 102, 103, 104, 105, -1, 107, 108, 109, -1, + 111, 112, -1, 114, 115, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, -1, 127, -1, 129, -1, + -1, -1, 133, 134, -1, 136, 137, -1, 139, -1, + 141, 142, 143, 144, -1, 146, 147, 148, -1, 150, + 151, 152, 153, 154, 155, -1, -1, 158, 159, 160, + 161, 162, 163, 164, -1, 166, -1, 168, -1, -1, + 171, -1, 173, 174, 175, 176, 177, -1, 179, -1, + 181, -1, -1, 184, 185, 186, -1, -1, 189, 190, + 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + 201, 202, -1, 204, -1, 206, 207, 208, 209, 210, + 211, 212, 213, 214, -1, 216, 217, -1, 219, -1, + 221, 222, 223, 224, 225, 226, -1, 228, -1, 230, + -1, 232, 233, -1, -1, 236, -1, -1, 239, 240, + 241, 242, 243, 244, -1, 246, 247, 248, 249, 250, + 251, -1, 253, 254, 255, 256, 257, 258, 259, 260, + 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, -1, 274, 275, -1, 277, 278, 279, 280, + 281, 282, 283, 284, 285, 286, 287, -1, 289, 290, + 291, -1, 293, 294, 295, 296, -1, 298, 299, -1, + 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, -1, 314, 315, -1, 317, 318, 319, 320, + 321, -1, 323, 324, -1, -1, 327, 328, 329, 330, + 331, 332, 333, 334, 335, 336, -1, -1, 339, 340, + 341, 342, -1, -1, 345, 346, 347, 348, 349, 350, + 351, -1, 353, 354, 355, -1, -1, 358, 359, 360, + 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, + 371, 372, 373, 374, -1, -1, -1, -1, -1, 380, + 381, 382, -1, -1, -1, 386, -1, -1, -1, -1, + -1, -1, 393, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, 226, -1, 228, -1, + 230, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, 331, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 381, 382, -1, -1, -1, 386, -1, -1, -1, + -1, -1, -1, 393, 3, 4, 5, 6, 7, 8, + 9, 10, -1, 12, 13, 14, -1, -1, -1, -1, + -1, -1, -1, 22, 23, -1, 25, -1, 27, 28, + 29, -1, 31, -1, 33, 34, -1, 36, 37, 38, + 39, 40, -1, -1, 43, 44, 45, 46, -1, 48, + 49, 50, 51, 52, -1, -1, 55, 56, 57, 58, + 59, 60, -1, 62, 63, 64, 65, 66, -1, 68, + 69, 70, -1, 72, 73, -1, -1, -1, -1, -1, + 79, 80, 81, 82, 83, 84, 85, 86, -1, 88, + -1, 90, 91, 92, 93, 94, -1, 96, 97, 98, + -1, -1, 101, 102, 103, 104, 105, -1, 107, 108, + 109, -1, 111, 112, -1, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 123, 124, 125, -1, 127, -1, + 129, -1, -1, -1, 133, 134, -1, 136, 137, -1, + 139, -1, 141, 142, 143, 144, -1, 146, 147, 148, + -1, 150, 151, 152, 153, 154, 155, -1, -1, 158, + 159, 160, 161, 162, 163, 164, -1, 166, -1, 168, + -1, -1, 171, -1, 173, 174, 175, 176, 177, -1, + 179, -1, 181, -1, -1, 184, 185, 186, -1, -1, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, -1, 204, -1, 206, 207, 208, + 209, 210, 211, 212, 213, 214, -1, 216, 217, -1, + 219, -1, 221, 222, 223, 224, 225, 226, -1, 228, + -1, 230, -1, 232, 233, -1, -1, 236, -1, -1, + 239, 240, 241, 242, 243, 244, -1, 246, 247, 248, + 249, 250, 251, -1, 253, 254, 255, 256, 257, 258, + 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, -1, 274, 275, -1, 277, 278, + 279, 280, 281, 282, 283, 284, 285, 286, 287, -1, + 289, 290, 291, -1, 293, 294, 295, 296, -1, 298, + 299, -1, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, -1, 314, 315, -1, 317, 318, + 319, 320, 321, -1, 323, 324, -1, -1, 327, 328, + 329, 330, 331, 332, 333, 334, 335, 336, -1, -1, + 339, 340, 341, 342, -1, -1, 345, 346, 347, 348, + 349, 350, 351, -1, 353, 354, 355, -1, -1, 358, + 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, + 369, 370, 371, 372, 373, 374, -1, -1, -1, -1, + -1, 380, 381, 382, -1, -1, -1, 386, -1, -1, + -1, -1, -1, -1, 393, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, 17, 345, 346, 347, + 348, 349, 350, 351, 25, 353, 354, 355, -1, 30, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, 17, -1, -1, + -1, -1, 380, -1, -1, 25, -1, -1, 386, -1, + 30, -1, -1, -1, -1, 393, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 145, -1, -1, -1, 149, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 169, 170, + -1, -1, -1, -1, -1, 145, -1, -1, -1, 149, + -1, 182, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 169, + 170, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 182, -1, 215, -1, -1, 218, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 232, -1, 234, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 215, -1, -1, 218, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 232, -1, 234, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 297, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 297, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 385, -1, -1, 388, 389, 390, + -1, 392, 393, 394, 395, 396, 397, -1, -1, -1, + -1, 402, 403, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 385, -1, -1, 388, 389, + 390, -1, 392, 393, 394, 395, 396, 397, -1, -1, + -1, -1, -1, 403, 3, 4, 5, 6, 7, 8, + 9, 10, -1, 12, 13, 14, -1, -1, -1, -1, + -1, -1, -1, 22, 23, -1, 25, -1, 27, 28, + 29, -1, 31, -1, 33, 34, -1, 36, 37, 38, + 39, 40, -1, -1, 43, 44, 45, 46, -1, 48, + 49, 50, 51, 52, -1, -1, 55, 56, 57, 58, + 59, 60, -1, 62, 63, 64, 65, 66, -1, 68, + 69, 70, -1, 72, 73, -1, -1, -1, -1, -1, + 79, 80, 81, 82, 83, 84, 85, 86, -1, 88, + -1, 90, 91, 92, 93, 94, -1, 96, 97, 98, + -1, -1, 101, 102, 103, 104, 105, -1, 107, 108, + 109, -1, 111, 112, -1, 114, 115, 116, 117, 118, + 119, 120, -1, 122, 123, 124, 125, -1, 127, -1, + 129, -1, -1, -1, 133, 134, -1, 136, 137, -1, + 139, -1, 141, 142, 143, 144, -1, 146, 147, 148, + -1, 150, 151, 152, 153, 154, 155, -1, -1, 158, + 159, 160, 161, 162, 163, 164, -1, 166, -1, 168, + -1, -1, 171, -1, 173, 174, 175, 176, 177, -1, + 179, -1, 181, -1, -1, 184, 185, 186, -1, -1, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, -1, 204, -1, 206, 207, 208, + 209, 210, 211, 212, 213, 214, -1, 216, 217, -1, + 219, -1, 221, 222, 223, 224, 225, -1, -1, 228, + -1, -1, -1, 232, 233, -1, -1, 236, -1, -1, + 239, 240, 241, 242, 243, 244, -1, 246, 247, 248, + 249, 250, 251, -1, 253, 254, 255, 256, 257, 258, + 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, -1, 274, 275, -1, 277, 278, + 279, 280, 281, 282, 283, 284, 285, 286, 287, -1, + 289, 290, 291, -1, 293, 294, 295, 296, -1, 298, + 299, -1, 301, 302, 303, 304, 305, 306, 307, 308, + 309, 310, 311, 312, -1, 314, 315, -1, 317, 318, + 319, 320, 321, -1, 323, 324, -1, -1, 327, 328, + 329, 330, -1, 332, 333, 334, 335, 336, -1, -1, + 339, 340, 341, 342, -1, -1, 345, 346, 347, 348, + 349, 350, 351, -1, 353, 354, 355, -1, -1, 358, + 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, + 369, 370, 371, 372, 373, 374, -1, -1, -1, -1, + -1, 380, -1, -1, -1, -1, -1, -1, 387, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 381, 382, 383, + 384, -1, 386, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, -1, 382, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, -1, 382, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, -1, 382, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, + 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, + 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, 179, 180, 181, + 182, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, 218, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, 229, -1, -1, + 232, 233, -1, -1, 236, 237, 238, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, 71, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, 130, -1, 132, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, 145, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, 157, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, -1, 179, 180, 181, 182, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, 218, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, 229, -1, -1, 232, 233, + -1, -1, 236, 237, 238, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, 297, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, 71, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, 130, -1, 132, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, 145, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, 157, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, -1, 179, 180, 181, 182, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, 218, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, 229, -1, -1, 232, 233, -1, -1, + 236, 237, 238, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, 297, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + 128, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, 182, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + 338, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, 67, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, 135, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, 15, 16, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, 229, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, 229, -1, 231, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, 205, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, 229, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, 229, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, 316, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, 229, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, 316, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, 205, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, 229, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, 343, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, 343, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, -1, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, 26, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, 20, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, 20, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, -1, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + 138, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, -1, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, 344, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, -1, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, -1, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, 20, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, -1, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + -1, 27, 28, 29, -1, 31, -1, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, 52, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, -1, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, 117, 118, 119, 120, -1, 122, 123, 124, 125, + -1, 127, -1, 129, -1, -1, -1, 133, 134, -1, + 136, 137, -1, 139, -1, 141, 142, 143, 144, -1, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, -1, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, -1, -1, 171, -1, 173, 174, 175, + 176, 177, -1, 179, -1, 181, -1, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, -1, 204, -1, + 206, 207, 208, 209, 210, 211, 212, 213, 214, -1, + 216, 217, -1, 219, -1, 221, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, -1, -1, 239, 240, 241, 242, 243, 244, -1, + 246, 247, 248, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + -1, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, 311, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, 328, 329, 330, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, 349, 350, 351, -1, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, -1, 27, + 28, 29, -1, 31, -1, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, 52, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, -1, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, 117, + 118, 119, 120, -1, 122, 123, 124, 125, -1, 127, + -1, 129, -1, -1, -1, 133, 134, -1, 136, 137, + -1, 139, -1, 141, 142, 143, 144, -1, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, -1, + 158, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, -1, -1, 171, -1, 173, 174, 175, 176, 177, + -1, 179, -1, 181, -1, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, -1, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + -1, 219, -1, 221, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, 236, -1, + -1, 239, 240, 241, 242, 243, 244, -1, 246, 247, + 248, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, -1, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, -1, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + 328, 329, 330, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, 349, 350, 351, -1, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, + 368, 369, 370, 371, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, -1, 27, 28, 29, + -1, 31, -1, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, 52, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, -1, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, 117, 118, 119, + 120, -1, 122, 123, 124, 125, -1, 127, -1, 129, + -1, -1, -1, 133, 134, -1, 136, 137, -1, 139, + -1, 141, 142, 143, 144, -1, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, -1, 158, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, -1, + -1, 171, -1, 173, 174, 175, 176, 177, -1, 179, + -1, 181, -1, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, -1, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, -1, 219, + -1, 221, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, 236, -1, -1, 239, + 240, 241, 242, 243, 244, -1, 246, 247, 248, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, -1, 277, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, -1, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, 328, 329, + 330, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, 349, + 350, 351, -1, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, + 370, 371, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, -1, 27, 28, 29, -1, 31, + -1, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + 52, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, -1, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, 117, 118, 119, 120, -1, + 122, 123, 124, 125, -1, 127, -1, 129, -1, -1, + -1, 133, 134, -1, 136, 137, -1, 139, -1, 141, + 142, 143, 144, -1, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, -1, 158, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, -1, -1, 171, + -1, 173, 174, 175, 176, 177, -1, 179, -1, 181, + -1, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, -1, 204, -1, 206, 207, 208, 209, 210, 211, + 212, 213, 214, -1, 216, 217, -1, 219, -1, 221, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, 236, -1, -1, 239, 240, 241, + 242, 243, 244, -1, 246, 247, 248, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, -1, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, -1, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, 328, 329, 330, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, 349, 350, 351, + -1, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, -1, 27, 28, 29, -1, 31, -1, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, 52, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, -1, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, + 124, 125, -1, 127, -1, 129, -1, -1, -1, 133, + 134, -1, 136, 137, -1, 139, -1, 141, 142, 143, + 144, -1, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, -1, 158, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, -1, -1, 171, -1, 173, + 174, 175, 176, 177, -1, 179, -1, 181, -1, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, -1, + 204, -1, 206, 207, 208, 209, 210, 211, 212, 213, + 214, -1, 216, 217, -1, 219, -1, 221, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, 236, -1, -1, 239, 240, 241, 242, 243, + 244, -1, 246, 247, 248, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, -1, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, -1, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, 328, 329, 330, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, 349, 350, 351, -1, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, -1, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, 71, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, -1, 118, 119, -1, -1, 122, 123, 124, 125, + -1, 127, -1, 129, 130, -1, 132, 133, 134, -1, + 136, -1, -1, 139, -1, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, + -1, 157, 158, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, -1, -1, 180, 181, 182, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, -1, + 206, 207, 208, 209, 210, 211, 212, -1, 214, -1, + 216, 217, 218, 219, -1, -1, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + 236, 237, 238, -1, 240, 241, 242, 243, 244, -1, + 246, -1, -1, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + 276, 277, 278, -1, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, 297, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, -1, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, -1, 329, -1, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, -1, 350, 351, 352, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, -1, -1, + -1, -1, -1, -1, -1, -1, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, -1, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, -1, + 118, 119, -1, -1, 122, 123, 124, 125, -1, 127, + -1, 129, 130, -1, 132, 133, 134, -1, 136, -1, + -1, 139, -1, 141, 142, 143, 144, 145, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, 157, + -1, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + -1, -1, 180, 181, 182, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, -1, 206, 207, + 208, 209, 210, 211, 212, 213, 214, -1, 216, 217, + 218, 219, -1, -1, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, -1, 237, + 238, -1, 240, 241, 242, 243, 244, -1, 246, -1, + -1, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, 276, 277, + 278, -1, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, 294, 295, 296, 297, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, -1, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, -1, -1, 327, + -1, 329, -1, -1, 332, 333, 334, 335, 336, -1, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, -1, 350, 351, 352, 353, 354, 355, -1, -1, + 358, 359, 360, 361, 362, 363, -1, -1, -1, -1, + -1, -1, -1, -1, 372, 373, 374, -1, -1, -1, + -1, -1, 380, 3, 4, 5, 6, 7, 8, 9, + 10, -1, 12, 13, 14, -1, -1, -1, -1, -1, + -1, -1, 22, 23, -1, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, -1, 36, 37, 38, 39, + 40, -1, -1, 43, 44, 45, 46, -1, 48, 49, + 50, 51, -1, -1, -1, 55, 56, 57, 58, 59, + 60, -1, 62, 63, 64, 65, 66, -1, 68, 69, + 70, 71, 72, 73, -1, -1, -1, -1, -1, 79, + 80, 81, 82, 83, 84, 85, 86, -1, 88, -1, + 90, 91, 92, 93, 94, -1, 96, 97, 98, -1, + -1, 101, 102, 103, 104, 105, -1, 107, 108, 109, + -1, 111, 112, -1, 114, 115, 116, -1, 118, 119, + -1, -1, 122, 123, 124, 125, -1, 127, -1, 129, + 130, -1, 132, 133, 134, -1, 136, -1, -1, 139, + -1, 141, 142, 143, 144, 145, 146, 147, 148, -1, + 150, 151, 152, 153, 154, 155, -1, 157, -1, 159, + 160, 161, 162, 163, 164, -1, 166, -1, 168, 169, + 170, 171, 172, 173, 174, 175, 176, 177, -1, -1, + 180, 181, 182, -1, 184, 185, 186, -1, -1, 189, + 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, -1, 206, 207, 208, 209, + 210, 211, 212, 213, 214, -1, 216, 217, 218, 219, + -1, -1, 222, 223, 224, 225, -1, -1, 228, -1, + -1, -1, 232, 233, -1, -1, -1, 237, 238, -1, + 240, 241, 242, 243, 244, -1, 246, -1, -1, 249, + 250, 251, -1, 253, 254, 255, 256, 257, 258, 259, + 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, -1, 274, 275, 276, 277, 278, -1, + 280, 281, 282, 283, 284, 285, 286, 287, -1, 289, + 290, 291, -1, 293, 294, 295, 296, 297, 298, 299, + -1, 301, 302, 303, 304, 305, 306, 307, 308, 309, + 310, -1, 312, -1, 314, 315, -1, 317, 318, 319, + 320, 321, -1, 323, 324, -1, -1, 327, -1, 329, + -1, -1, 332, 333, 334, 335, 336, -1, -1, 339, + 340, 341, 342, -1, -1, 345, 346, 347, 348, -1, + 350, 351, 352, 353, 354, 355, -1, -1, 358, 359, + 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, + -1, -1, 372, 373, 374, -1, -1, -1, -1, -1, + 380, 3, 4, 5, 6, 7, 8, 9, 10, -1, + 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, + 22, 23, -1, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, 36, 37, 38, 39, 40, -1, + -1, 43, 44, 45, 46, -1, 48, 49, 50, 51, + -1, -1, -1, 55, 56, 57, 58, 59, 60, -1, + 62, 63, 64, 65, 66, -1, 68, 69, 70, 71, + 72, 73, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, -1, 88, -1, 90, 91, + 92, 93, 94, -1, 96, 97, 98, -1, -1, 101, + 102, 103, 104, 105, -1, 107, 108, 109, -1, 111, + 112, -1, 114, 115, 116, -1, 118, 119, -1, -1, + 122, 123, 124, 125, -1, 127, -1, 129, 130, -1, + 132, 133, 134, -1, 136, -1, -1, 139, -1, 141, + 142, 143, 144, 145, 146, 147, 148, -1, 150, 151, + 152, 153, 154, 155, -1, 157, -1, 159, 160, 161, + 162, 163, 164, -1, 166, -1, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, -1, -1, 180, 181, + 182, -1, 184, 185, 186, -1, -1, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, -1, 206, 207, 208, 209, 210, 211, + 212, -1, 214, -1, 216, 217, 218, 219, 220, -1, + 222, 223, 224, 225, -1, -1, 228, -1, -1, -1, + 232, 233, -1, -1, -1, 237, 238, -1, 240, 241, + 242, 243, 244, -1, 246, -1, -1, 249, 250, 251, + -1, 253, 254, 255, 256, 257, 258, 259, 260, 261, + -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, 274, 275, 276, 277, 278, -1, 280, 281, + 282, 283, 284, 285, 286, 287, -1, 289, 290, 291, + -1, 293, 294, 295, 296, 297, 298, 299, -1, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, -1, + 312, -1, 314, 315, -1, 317, 318, 319, 320, 321, + -1, 323, 324, -1, -1, 327, -1, 329, -1, -1, + 332, 333, 334, 335, 336, -1, -1, 339, 340, 341, + 342, -1, -1, 345, 346, 347, 348, -1, 350, 351, + 352, 353, 354, 355, -1, -1, 358, 359, 360, 361, + 362, 363, -1, -1, -1, -1, -1, -1, -1, -1, + 372, 373, 374, -1, -1, -1, -1, -1, 380, 3, + 4, 5, 6, 7, 8, 9, 10, -1, 12, 13, + 14, -1, -1, -1, -1, -1, -1, -1, 22, 23, + -1, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, 36, 37, 38, 39, 40, -1, -1, 43, + 44, 45, 46, -1, 48, 49, 50, 51, -1, -1, + -1, 55, 56, 57, 58, 59, 60, -1, 62, 63, + 64, 65, 66, -1, 68, 69, 70, 71, 72, 73, + -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, + 84, 85, 86, -1, 88, -1, 90, 91, 92, 93, + 94, -1, 96, 97, 98, -1, -1, 101, 102, 103, + 104, 105, -1, 107, 108, 109, -1, 111, 112, -1, + 114, 115, 116, -1, 118, 119, -1, -1, 122, 123, + 124, 125, -1, 127, -1, 129, 130, -1, 132, 133, + 134, -1, 136, -1, -1, 139, -1, 141, 142, 143, + 144, 145, 146, 147, 148, -1, 150, 151, 152, 153, + 154, 155, -1, 157, -1, 159, 160, 161, 162, 163, + 164, -1, 166, -1, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, -1, -1, 180, 181, 182, -1, + 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, -1, 206, 207, 208, 209, 210, 211, 212, -1, + 214, -1, 216, 217, 218, 219, -1, -1, 222, 223, + 224, 225, -1, -1, 228, -1, -1, -1, 232, 233, + -1, -1, -1, 237, 238, -1, 240, 241, 242, 243, + 244, -1, 246, -1, -1, 249, 250, 251, -1, 253, + 254, 255, 256, 257, 258, 259, 260, 261, -1, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + 274, 275, 276, 277, 278, -1, 280, 281, 282, 283, + 284, 285, 286, 287, -1, 289, 290, 291, -1, 293, + 294, 295, 296, 297, 298, 299, -1, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, -1, 312, -1, + 314, 315, -1, 317, 318, 319, 320, 321, -1, 323, + 324, -1, -1, 327, -1, 329, -1, -1, 332, 333, + 334, 335, 336, -1, -1, 339, 340, 341, 342, -1, + -1, 345, 346, 347, 348, -1, 350, 351, 352, 353, + 354, 355, -1, -1, 358, 359, 360, 361, 362, 363, + -1, -1, -1, -1, -1, -1, -1, -1, 372, 373, + 374, -1, -1, -1, -1, -1, 380, 3, 4, 5, + 6, 7, 8, 9, 10, -1, 12, 13, 14, -1, + -1, -1, -1, -1, -1, -1, 22, 23, -1, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, -1, -1, 43, 44, 45, + 46, -1, 48, 49, 50, 51, -1, -1, -1, 55, + 56, 57, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, 68, 69, 70, 71, 72, 73, -1, -1, + -1, -1, -1, 79, 80, 81, 82, 83, 84, 85, + 86, -1, 88, -1, 90, 91, 92, 93, 94, -1, + 96, 97, 98, -1, -1, 101, 102, 103, 104, 105, + -1, 107, 108, 109, -1, 111, 112, -1, 114, 115, + 116, -1, 118, 119, -1, -1, 122, 123, 124, 125, + -1, 127, -1, 129, 130, -1, 132, 133, 134, -1, + 136, -1, -1, 139, -1, 141, 142, 143, 144, 145, + 146, 147, 148, -1, 150, 151, 152, 153, 154, 155, + -1, 157, -1, 159, 160, 161, 162, 163, 164, -1, + 166, -1, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, -1, -1, 180, 181, 182, -1, 184, 185, + 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, -1, + 206, 207, 208, 209, 210, 211, 212, -1, 214, -1, + 216, 217, 218, 219, -1, -1, 222, 223, 224, 225, + -1, -1, 228, -1, -1, -1, 232, 233, -1, -1, + -1, 237, 238, -1, 240, 241, 242, 243, 244, -1, + 246, -1, -1, 249, 250, 251, -1, 253, 254, 255, + 256, 257, 258, 259, 260, 261, -1, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, -1, 274, 275, + 276, 277, 278, -1, 280, 281, 282, 283, 284, 285, + 286, 287, -1, 289, 290, 291, -1, 293, 294, 295, + 296, 297, 298, 299, -1, 301, 302, 303, 304, 305, + 306, 307, 308, 309, 310, -1, 312, -1, 314, 315, + -1, 317, 318, 319, 320, 321, -1, 323, 324, -1, + -1, 327, -1, 329, -1, -1, 332, 333, 334, 335, + 336, -1, -1, 339, 340, 341, 342, -1, -1, 345, + 346, 347, 348, -1, 350, 351, 352, 353, 354, 355, + -1, -1, 358, 359, 360, 361, 362, 363, -1, -1, + -1, -1, -1, -1, -1, -1, 372, 373, 374, -1, + -1, -1, -1, -1, 380, 3, 4, 5, 6, 7, + 8, 9, 10, -1, 12, 13, 14, -1, -1, -1, + -1, -1, -1, -1, 22, 23, -1, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, 36, 37, + 38, 39, 40, -1, -1, 43, 44, 45, 46, -1, + 48, 49, 50, 51, -1, -1, -1, 55, 56, 57, + 58, 59, 60, -1, 62, 63, 64, 65, 66, -1, + 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, + -1, 79, 80, 81, 82, 83, 84, 85, 86, -1, + 88, -1, 90, 91, 92, 93, 94, -1, 96, 97, + 98, -1, -1, 101, 102, 103, 104, 105, -1, 107, + 108, 109, -1, 111, 112, -1, 114, 115, 116, -1, + 118, 119, -1, -1, 122, 123, 124, 125, -1, 127, + -1, 129, 130, -1, 132, 133, 134, -1, 136, -1, + -1, 139, -1, 141, 142, 143, 144, 145, 146, 147, + 148, -1, 150, 151, 152, 153, 154, 155, -1, 157, + -1, 159, 160, 161, 162, 163, 164, -1, 166, -1, + 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, + -1, -1, 180, 181, 182, -1, 184, 185, 186, -1, + -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, -1, 206, 207, + 208, 209, 210, 211, 212, -1, 214, -1, 216, 217, + 218, 219, -1, -1, 222, 223, 224, 225, -1, -1, + 228, -1, -1, -1, 232, 233, -1, -1, -1, 237, + 238, -1, 240, 241, 242, 243, 244, -1, 246, -1, + -1, 249, 250, 251, -1, 253, 254, 255, 256, 257, + 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, 274, 275, 276, 277, + 278, -1, 280, 281, 282, 283, 284, 285, 286, 287, + -1, 289, 290, 291, -1, 293, -1, 295, 296, 297, + 298, 299, -1, 301, 302, 303, 304, 305, 306, 307, + 308, 309, 310, -1, 312, -1, 314, 315, -1, 317, + 318, 319, 320, 321, -1, 323, 324, 10, -1, 327, + -1, 329, -1, -1, 332, 333, 334, 335, 336, 22, + -1, 339, 340, 341, 342, -1, -1, 345, 346, 347, + 348, -1, 350, 351, 352, 353, 354, 355, -1, 42, + 358, 359, 360, 361, 362, 363, -1, -1, -1, -1, + -1, -1, -1, -1, 372, 373, 374, -1, -1, -1, + -1, 64, 380, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 81, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 102, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 133, -1, -1, -1, -1, 138, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 152, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 232, + -1, -1, -1, -1, -1, -1, -1, 240, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 255, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 277, -1, -1, -1, 281, -1, + 283, -1, -1, -1, -1, -1, 289, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 316, 317, -1, -1, -1, 321, -1, + -1, -1, -1, -1, -1, -1, 329, -1, -1, -1, + -1, 334, -1, -1, -1, -1, -1, -1, -1, -1, + 343, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 354 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned short int yystos[] = +{ + 0, 3, 13, 15, 16, 29, 48, 50, 51, 55, + 56, 65, 67, 83, 86, 92, 98, 104, 110, 116, + 118, 123, 135, 161, 184, 185, 190, 199, 217, 250, + 260, 263, 265, 270, 275, 278, 282, 288, 293, 296, + 303, 332, 340, 342, 345, 349, 401, 409, 410, 411, + 412, 416, 417, 418, 419, 420, 421, 422, 423, 424, + 426, 427, 431, 441, 443, 444, 447, 448, 449, 457, + 458, 467, 495, 500, 501, 508, 513, 515, 517, 518, + 531, 532, 533, 534, 544, 550, 551, 554, 555, 556, + 557, 558, 563, 564, 567, 570, 571, 581, 582, 585, + 593, 607, 610, 611, 612, 615, 617, 619, 622, 624, + 625, 626, 634, 635, 636, 637, 638, 643, 645, 646, + 650, 651, 654, 655, 656, 658, 659, 660, 661, 663, + 664, 665, 670, 673, 676, 678, 679, 684, 686, 690, + 697, 700, 701, 702, 703, 704, 725, 327, 361, 639, + 10, 64, 81, 102, 133, 138, 152, 232, 255, 277, + 283, 289, 316, 317, 321, 329, 334, 343, 354, 514, + 639, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 22, 23, 25, 27, 28, 29, 31, + 33, 34, 36, 37, 38, 39, 40, 43, 44, 45, + 46, 48, 49, 50, 51, 52, 55, 56, 57, 58, + 59, 60, 62, 63, 64, 65, 66, 68, 69, 70, + 72, 73, 79, 80, 81, 82, 83, 84, 85, 86, + 88, 90, 91, 92, 93, 94, 96, 97, 98, 101, + 102, 103, 104, 105, 107, 108, 109, 111, 112, 114, + 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, + 127, 129, 133, 134, 136, 137, 139, 141, 142, 143, + 144, 146, 147, 148, 150, 151, 152, 153, 154, 155, + 158, 159, 160, 161, 162, 163, 164, 166, 168, 171, + 173, 174, 175, 176, 177, 179, 181, 184, 185, 186, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 204, 206, 207, 208, 209, 210, + 211, 212, 213, 214, 216, 217, 219, 221, 222, 223, + 224, 225, 228, 232, 233, 236, 239, 240, 241, 242, + 243, 244, 246, 247, 248, 249, 250, 251, 253, 254, + 255, 256, 257, 258, 259, 260, 261, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, 274, 275, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + 289, 290, 291, 293, 294, 295, 296, 298, 299, 301, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 314, 315, 317, 318, 319, 320, 321, 323, 324, + 327, 328, 329, 330, 332, 333, 334, 335, 336, 339, + 340, 341, 342, 345, 346, 347, 348, 349, 350, 351, + 353, 354, 355, 358, 359, 360, 361, 362, 363, 364, + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 380, 815, 827, 830, 831, 205, 229, 811, 813, 819, + 827, 834, 230, 251, 639, 32, 463, 701, 10, 22, + 42, 61, 81, 87, 102, 134, 138, 186, 232, 234, + 277, 283, 317, 318, 320, 321, 329, 333, 334, 338, + 343, 468, 509, 547, 586, 594, 11, 250, 815, 815, + 131, 11, 246, 318, 320, 10, 22, 42, 64, 81, + 102, 133, 138, 152, 232, 240, 277, 281, 283, 289, + 316, 317, 321, 329, 334, 343, 354, 514, 559, 639, + 815, 665, 672, 4, 11, 27, 124, 129, 177, 206, + 253, 264, 386, 393, 568, 815, 826, 11, 67, 262, + 288, 572, 573, 574, 827, 167, 827, 382, 820, 824, + 316, 707, 568, 815, 827, 327, 815, 240, 81, 152, + 315, 316, 620, 282, 827, 11, 291, 323, 327, 433, + 827, 8, 135, 572, 573, 251, 639, 827, 11, 99, + 709, 62, 186, 201, 277, 291, 323, 327, 363, 432, + 433, 11, 291, 323, 327, 433, 327, 707, 394, 827, + 231, 734, 735, 813, 827, 132, 667, 401, 808, 701, + 702, 0, 405, 352, 666, 113, 165, 235, 337, 710, + 711, 406, 26, 30, 32, 71, 130, 132, 145, 157, + 169, 170, 172, 180, 182, 203, 218, 237, 238, 276, + 297, 352, 380, 811, 821, 828, 830, 832, 561, 827, + 816, 827, 561, 580, 821, 825, 827, 734, 49, 122, + 385, 388, 389, 390, 392, 393, 394, 395, 396, 397, + 614, 777, 778, 827, 825, 815, 734, 813, 734, 815, + 285, 815, 561, 825, 734, 175, 171, 258, 640, 641, + 642, 399, 404, 802, 803, 344, 662, 230, 10, 42, + 54, 61, 64, 81, 102, 133, 152, 176, 232, 277, + 281, 283, 289, 316, 317, 321, 329, 334, 354, 514, + 565, 824, 813, 325, 821, 815, 401, 329, 816, 561, + 318, 320, 825, 318, 320, 49, 122, 614, 268, 825, + 428, 827, 815, 285, 815, 561, 825, 289, 316, 354, + 514, 64, 152, 133, 281, 11, 815, 698, 735, 144, + 821, 815, 144, 618, 144, 816, 144, 821, 144, 814, + 815, 49, 122, 144, 614, 36, 144, 814, 144, 815, + 144, 815, 285, 144, 815, 144, 814, 175, 144, 560, + 561, 401, 677, 666, 826, 11, 826, 11, 826, 826, + 386, 131, 149, 569, 254, 230, 325, 406, 813, 812, + 813, 569, 824, 401, 674, 36, 815, 815, 813, 827, + 26, 374, 171, 404, 233, 233, 230, 131, 824, 325, + 230, 19, 31, 33, 34, 41, 42, 44, 45, 52, + 74, 75, 76, 77, 78, 84, 85, 103, 117, 120, + 121, 125, 137, 163, 164, 166, 179, 187, 188, 202, + 204, 215, 220, 221, 223, 232, 239, 247, 259, 279, + 292, 299, 311, 323, 324, 328, 330, 331, 338, 343, + 350, 365, 366, 367, 368, 369, 370, 371, 381, 383, + 384, 385, 386, 387, 392, 393, 394, 401, 701, 744, + 747, 750, 751, 752, 754, 755, 756, 757, 760, 761, + 764, 766, 767, 775, 779, 796, 801, 809, 810, 811, + 821, 822, 823, 824, 11, 445, 812, 291, 432, 87, + 439, 824, 382, 440, 827, 26, 46, 432, 374, 641, + 233, 131, 325, 388, 26, 374, 171, 642, 812, 401, + 813, 20, 827, 293, 394, 130, 668, 87, 764, 806, + 807, 402, 402, 411, 813, 11, 99, 708, 708, 36, + 708, 126, 183, 227, 714, 720, 722, 723, 808, 803, + 401, 539, 241, 266, 404, 562, 241, 266, 293, 359, + 413, 441, 442, 7, 104, 241, 293, 454, 38, 66, + 119, 147, 241, 266, 274, 280, 287, 293, 301, 309, + 355, 442, 603, 608, 401, 595, 7, 104, 266, 425, + 241, 266, 270, 293, 452, 453, 561, 561, 401, 404, + 266, 413, 442, 241, 266, 266, 293, 502, 7, 13, + 51, 97, 104, 107, 154, 207, 266, 293, 450, 451, + 453, 241, 266, 59, 96, 242, 319, 230, 241, 293, + 266, 413, 442, 266, 815, 181, 231, 362, 406, 640, + 764, 11, 15, 16, 17, 18, 19, 20, 21, 24, + 35, 41, 42, 47, 53, 54, 61, 67, 74, 75, + 76, 77, 78, 87, 89, 95, 99, 100, 106, 110, + 113, 121, 126, 128, 131, 135, 138, 140, 149, 156, + 165, 167, 178, 183, 187, 188, 205, 215, 220, 226, + 227, 229, 230, 231, 234, 235, 245, 252, 262, 273, + 288, 292, 300, 313, 316, 322, 325, 326, 331, 337, + 338, 343, 344, 356, 357, 380, 394, 818, 829, 830, + 831, 832, 833, 802, 819, 827, 813, 821, 401, 815, + 821, 224, 49, 122, 614, 815, 285, 815, 175, 561, + 401, 482, 306, 307, 460, 824, 401, 539, 540, 47, + 31, 33, 34, 44, 45, 84, 85, 125, 163, 164, + 166, 202, 204, 223, 259, 294, 299, 323, 324, 350, + 380, 741, 743, 745, 747, 749, 751, 752, 753, 755, + 756, 760, 761, 828, 830, 815, 413, 20, 657, 413, + 561, 561, 401, 535, 468, 413, 26, 429, 241, 516, + 59, 96, 242, 319, 9, 28, 519, 20, 535, 413, + 813, 496, 813, 813, 175, 561, 58, 819, 821, 815, + 32, 79, 160, 207, 284, 344, 685, 117, 539, 39, + 272, 455, 117, 401, 117, 117, 595, 117, 406, 144, + 561, 144, 561, 117, 401, 814, 117, 117, 230, 117, + 59, 96, 242, 319, 117, 230, 117, 144, 440, 117, + 406, 455, 764, 782, 67, 671, 676, 679, 684, 690, + 697, 700, 815, 81, 133, 175, 283, 289, 316, 317, + 575, 812, 814, 574, 87, 401, 680, 700, 149, 406, + 687, 815, 741, 784, 20, 814, 127, 621, 621, 621, + 181, 827, 126, 126, 575, 814, 282, 827, 401, 399, + 701, 786, 351, 758, 764, 800, 401, 758, 758, 401, + 401, 401, 401, 746, 746, 248, 701, 401, 401, 748, + 401, 401, 401, 401, 44, 45, 758, 764, 401, 746, + 401, 401, 401, 401, 401, 359, 360, 401, 762, 401, + 762, 401, 401, 701, 401, 401, 401, 401, 401, 401, + 401, 804, 764, 764, 349, 701, 764, 782, 824, 45, + 401, 759, 401, 824, 17, 20, 25, 30, 145, 149, + 169, 170, 182, 215, 218, 232, 234, 297, 385, 388, + 389, 390, 392, 393, 394, 395, 396, 397, 403, 777, + 779, 781, 238, 764, 167, 406, 705, 803, 401, 824, + 90, 146, 446, 46, 87, 440, 20, 87, 186, 380, + 381, 393, 438, 505, 506, 507, 761, 824, 826, 63, + 101, 773, 73, 87, 121, 226, 230, 331, 434, 435, + 437, 440, 505, 87, 434, 181, 455, 813, 827, 401, + 691, 692, 693, 694, 695, 827, 666, 402, 406, 401, + 669, 701, 703, 704, 703, 712, 713, 764, 703, 258, + 295, 342, 11, 716, 764, 717, 764, 720, 721, 714, + 715, 126, 723, 394, 784, 241, 266, 293, 325, 325, + 818, 404, 325, 325, 432, 652, 47, 61, 128, 252, + 338, 480, 481, 61, 87, 215, 325, 87, 215, 283, + 230, 505, 287, 325, 325, 220, 505, 91, 168, 283, + 272, 603, 609, 149, 158, 236, 294, 402, 596, 597, + 598, 599, 601, 741, 828, 325, 343, 325, 325, 535, + 317, 535, 406, 344, 344, 213, 613, 741, 614, 325, + 414, 325, 325, 325, 283, 37, 80, 151, 194, 196, + 207, 240, 271, 303, 503, 54, 480, 623, 623, 230, + 281, 329, 61, 623, 14, 269, 281, 329, 813, 154, + 325, 623, 283, 360, 406, 325, 325, 561, 561, 561, + 561, 734, 325, 283, 325, 414, 325, 241, 266, 258, + 267, 290, 436, 640, 400, 407, 539, 741, 230, 595, + 505, 561, 561, 401, 169, 230, 59, 96, 242, 319, + 230, 561, 169, 483, 484, 827, 359, 464, 413, 380, + 541, 542, 535, 401, 743, 20, 19, 742, 82, 143, + 195, 198, 286, 372, 401, 763, 562, 746, 9, 647, + 741, 414, 547, 344, 536, 537, 829, 354, 414, 825, + 67, 135, 430, 467, 500, 518, 570, 585, 643, 815, + 189, 561, 561, 561, 561, 92, 161, 342, 520, 521, + 111, 401, 414, 502, 20, 225, 401, 497, 482, 440, + 126, 819, 230, 595, 20, 359, 360, 699, 284, 401, + 701, 727, 728, 729, 734, 736, 767, 811, 821, 357, + 738, 821, 455, 741, 816, 821, 455, 814, 815, 117, + 344, 117, 344, 614, 613, 455, 814, 815, 813, 815, + 815, 813, 814, 117, 455, 560, 561, 402, 406, 468, + 814, 579, 580, 814, 814, 812, 812, 814, 325, 359, + 583, 349, 681, 682, 827, 273, 683, 5, 115, 279, + 295, 688, 813, 219, 689, 402, 406, 675, 679, 684, + 690, 700, 325, 573, 572, 573, 131, 136, 584, 827, + 782, 782, 785, 786, 401, 356, 797, 798, 764, 782, + 823, 823, 782, 82, 143, 195, 198, 286, 372, 380, + 382, 783, 787, 823, 782, 782, 823, 823, 758, 758, + 764, 614, 764, 788, 392, 393, 765, 766, 775, 779, + 790, 402, 782, 764, 782, 791, 323, 323, 823, 823, + 764, 35, 131, 178, 326, 764, 782, 794, 782, 200, + 764, 771, 772, 773, 200, 764, 773, 802, 402, 406, + 293, 823, 823, 763, 764, 829, 323, 24, 313, 805, + 764, 401, 701, 795, 99, 101, 121, 215, 220, 225, + 331, 339, 764, 30, 145, 149, 182, 297, 401, 764, + 325, 764, 764, 764, 764, 764, 764, 764, 764, 764, + 741, 764, 11, 18, 300, 776, 279, 401, 775, 134, + 186, 316, 318, 320, 706, 813, 810, 131, 726, 11, + 99, 394, 402, 782, 327, 381, 401, 824, 406, 402, + 695, 696, 406, 726, 388, 804, 664, 813, 806, 814, + 406, 21, 95, 344, 591, 231, 225, 724, 724, 227, + 406, 183, 402, 402, 325, 325, 283, 825, 815, 818, + 825, 816, 60, 653, 401, 815, 173, 173, 401, 815, + 220, 825, 764, 220, 815, 220, 91, 168, 825, 815, + 230, 815, 236, 828, 402, 406, 599, 601, 598, 601, + 828, 562, 825, 814, 825, 815, 815, 453, 817, 827, + 817, 406, 402, 406, 825, 8, 60, 68, 69, 70, + 109, 149, 154, 191, 208, 209, 210, 211, 212, 214, + 244, 277, 312, 314, 336, 343, 346, 415, 825, 815, + 815, 815, 505, 36, 504, 505, 505, 80, 194, 196, + 36, 413, 413, 472, 827, 827, 815, 815, 11, 343, + 815, 815, 827, 281, 329, 281, 329, 815, 11, 343, + 815, 813, 815, 815, 815, 51, 228, 293, 451, 825, + 815, 7, 13, 104, 241, 266, 241, 266, 535, 266, + 266, 266, 825, 815, 825, 815, 325, 325, 57, 335, + 258, 764, 169, 20, 561, 169, 169, 344, 344, 613, + 220, 566, 824, 561, 561, 561, 561, 561, 561, 169, + 566, 402, 406, 228, 131, 325, 459, 461, 388, 402, + 406, 764, 19, 742, 741, 399, 399, 325, 325, 325, + 325, 823, 746, 520, 60, 108, 189, 241, 317, 319, + 648, 473, 126, 817, 402, 406, 388, 813, 429, 234, + 468, 824, 535, 535, 535, 535, 230, 234, 401, 739, + 740, 827, 116, 700, 813, 182, 469, 470, 471, 472, + 477, 480, 498, 499, 827, 359, 360, 491, 20, 139, + 824, 230, 813, 20, 175, 274, 602, 603, 604, 627, + 142, 142, 126, 701, 728, 729, 20, 730, 827, 406, + 71, 132, 157, 172, 180, 203, 276, 731, 730, 20, + 730, 827, 803, 401, 73, 764, 683, 539, 20, 595, + 561, 817, 561, 817, 401, 402, 230, 455, 230, 455, + 440, 455, 764, 316, 406, 138, 576, 577, 825, 8, + 584, 402, 406, 804, 809, 115, 295, 115, 295, 279, + 342, 197, 741, 815, 131, 230, 576, 36, 455, 402, + 400, 400, 406, 782, 764, 106, 798, 799, 20, 402, + 402, 402, 402, 402, 131, 402, 402, 402, 402, 402, + 406, 402, 245, 789, 402, 765, 765, 149, 169, 232, + 388, 389, 390, 392, 393, 394, 395, 396, 397, 403, + 779, 765, 402, 402, 126, 131, 792, 793, 402, 374, + 374, 402, 402, 20, 794, 782, 794, 794, 131, 402, + 402, 829, 20, 402, 406, 764, 829, 406, 764, 804, + 764, 827, 402, 402, 374, 765, 765, 112, 782, 131, + 99, 101, 121, 220, 225, 331, 339, 401, 112, 313, + 805, 764, 795, 764, 325, 614, 764, 401, 701, 318, + 320, 318, 320, 813, 707, 707, 727, 357, 737, 782, + 782, 402, 402, 641, 823, 763, 435, 402, 406, 692, + 738, 806, 402, 713, 232, 777, 780, 375, 376, 592, + 814, 689, 689, 717, 717, 716, 825, 815, 815, 183, + 764, 481, 401, 401, 483, 455, 159, 220, 562, 597, + 601, 601, 396, 241, 266, 7, 104, 241, 266, 741, + 241, 213, 741, 814, 183, 244, 138, 277, 220, 824, + 814, 823, 244, 814, 341, 505, 561, 505, 505, 741, + 104, 293, 334, 454, 455, 455, 815, 815, 815, 815, + 325, 192, 192, 192, 325, 325, 325, 325, 325, 325, + 325, 825, 815, 400, 566, 741, 169, 566, 566, 817, + 817, 402, 169, 169, 169, 169, 169, 169, 566, 484, + 460, 32, 72, 93, 112, 127, 141, 220, 228, 257, + 462, 232, 393, 505, 538, 601, 780, 824, 833, 380, + 542, 402, 399, 402, 823, 400, 823, 143, 195, 286, + 195, 286, 286, 198, 402, 230, 183, 388, 649, 649, + 649, 649, 649, 47, 61, 87, 89, 156, 215, 220, + 252, 262, 338, 474, 475, 476, 334, 537, 538, 482, + 268, 316, 813, 521, 543, 824, 402, 406, 741, 815, + 401, 813, 402, 406, 402, 406, 228, 535, 228, 230, + 492, 700, 510, 815, 325, 813, 344, 587, 605, 824, + 440, 600, 601, 359, 604, 606, 230, 700, 402, 827, + 401, 728, 172, 237, 732, 728, 732, 172, 731, 732, + 172, 401, 827, 401, 782, 225, 455, 741, 455, 344, + 455, 344, 455, 613, 455, 813, 813, 455, 496, 813, + 580, 825, 359, 406, 578, 233, 700, 682, 115, 115, + 814, 575, 455, 825, 786, 402, 322, 764, 110, 741, + 764, 764, 764, 792, 765, 99, 101, 215, 225, 765, + 765, 765, 765, 765, 765, 765, 765, 765, 741, 765, + 764, 764, 793, 792, 762, 762, 741, 402, 402, 402, + 782, 402, 406, 829, 772, 249, 310, 774, 402, 406, + 353, 768, 20, 402, 759, 824, 764, 17, 17, 764, + 402, 764, 131, 401, 784, 764, 765, 765, 112, 112, + 764, 402, 112, 764, 707, 707, 707, 707, 813, 813, + 764, 138, 718, 402, 402, 824, 402, 388, 695, 683, + 401, 592, 649, 402, 483, 483, 402, 159, 396, 334, + 325, 325, 133, 232, 308, 545, 546, 133, 232, 552, + 553, 325, 325, 325, 826, 824, 814, 814, 824, 824, + 473, 215, 215, 305, 308, 741, 815, 126, 126, 268, + 126, 144, 825, 815, 825, 815, 815, 815, 815, 402, + 566, 169, 169, 169, 566, 566, 566, 566, 566, 566, + 344, 465, 466, 657, 657, 215, 257, 657, 657, 89, + 156, 215, 528, 529, 530, 823, 359, 360, 400, 400, + 763, 813, 649, 87, 823, 824, 87, 824, 87, 815, + 87, 815, 87, 815, 401, 815, 765, 90, 146, 89, + 220, 173, 813, 606, 741, 20, 813, 126, 522, 234, + 402, 406, 740, 677, 469, 478, 155, 490, 471, 499, + 827, 56, 317, 493, 377, 378, 379, 644, 347, 511, + 562, 824, 587, 817, 401, 406, 602, 535, 92, 161, + 288, 342, 632, 730, 401, 814, 728, 230, 344, 733, + 728, 172, 728, 739, 401, 739, 827, 402, 387, 815, + 402, 817, 817, 402, 455, 455, 20, 401, 135, 577, + 584, 131, 764, 402, 402, 793, 131, 99, 101, 225, + 401, 402, 364, 770, 782, 358, 358, 402, 764, 207, + 764, 406, 769, 743, 763, 765, 765, 764, 784, 402, + 17, 17, 764, 764, 112, 764, 402, 813, 813, 813, + 813, 36, 140, 719, 824, 808, 614, 826, 402, 402, + 606, 334, 825, 815, 823, 823, 741, 406, 823, 823, + 406, 825, 815, 825, 220, 220, 507, 827, 344, 456, + 814, 814, 561, 814, 117, 169, 566, 566, 566, 413, + 94, 824, 824, 220, 483, 824, 824, 90, 146, 89, + 530, 529, 400, 133, 133, 131, 527, 826, 764, 215, + 475, 606, 482, 344, 494, 344, 700, 401, 105, 523, + 116, 521, 824, 402, 114, 150, 479, 401, 491, 92, + 104, 249, 815, 47, 47, 233, 510, 174, 512, 131, + 401, 401, 588, 589, 767, 827, 824, 606, 325, 814, + 402, 764, 401, 728, 733, 402, 739, 402, 455, 455, + 455, 455, 233, 455, 576, 765, 131, 401, 784, 401, + 402, 406, 402, 402, 348, 302, 402, 402, 402, 765, + 765, 764, 782, 764, 763, 402, 262, 606, 494, 401, + 821, 614, 546, 401, 401, 553, 764, 359, 268, 359, + 359, 126, 566, 461, 824, 483, 580, 20, 616, 813, + 528, 402, 494, 193, 485, 152, 817, 644, 279, 304, + 524, 256, 491, 62, 88, 153, 62, 88, 153, 812, + 492, 280, 280, 233, 233, 824, 561, 588, 764, 402, + 406, 344, 561, 590, 590, 813, 402, 814, 402, 455, + 765, 784, 402, 771, 782, 207, 373, 813, 494, 784, + 595, 261, 401, 549, 784, 784, 560, 561, 560, 561, + 814, 616, 23, 148, 126, 132, 243, 298, 230, 486, + 487, 488, 317, 122, 548, 821, 492, 402, 493, 402, + 402, 606, 589, 561, 591, 591, 737, 402, 402, 402, + 402, 348, 482, 402, 613, 402, 402, 359, 105, 92, + 342, 230, 488, 230, 487, 815, 561, 20, 401, 493, + 606, 590, 493, 592, 592, 100, 485, 821, 402, 561, + 279, 39, 207, 272, 293, 489, 489, 545, 381, 383, + 384, 386, 525, 526, 824, 827, 493, 591, 737, 12, + 162, 633, 486, 595, 549, 116, 6, 87, 220, 402, + 406, 737, 592, 216, 401, 628, 630, 635, 679, 684, + 690, 700, 528, 256, 526, 629, 630, 631, 701, 702, + 821, 402, 405, 401, 631, 525, 402 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value, Location); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + size_t yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +#endif /* YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep, yylocationp) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + (void) yylocationp; + + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + (void) yylocationp; + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; +/* Location data for the look-ahead symbol. */ +YYLTYPE yylloc; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + ; +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + short int *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + yylsp = yyls; +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 0; +#endif + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short int *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short int *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + YYSTACK_RELOCATE (yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a look-ahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to look-ahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + *++yylsp = yylloc; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 539 "gram.y" + { parsetree = (yyvsp[0].list); } + break; + + case 3: +#line 544 "gram.y" + { if ((yyvsp[0].node) != NULL) + (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); + else + (yyval.list) = (yyvsp[-2].list); + } + break; + + case 4: +#line 550 "gram.y" + { if ((yyvsp[0].node) != NULL) + (yyval.list) = list_make1((yyvsp[0].node)); + else + (yyval.list) = NIL; + } + break; + + case 96: +#line 650 "gram.y" + { (yyval.node) = NULL; } + break; + + case 97: +#line 661 "gram.y" + { + CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_ROLE; + n->role = (yyvsp[-2].str); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 98: +#line 671 "gram.y" + {} + break; + + case 99: +#line 672 "gram.y" + {} + break; + + case 100: +#line 681 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 101: +#line 682 "gram.y" + { (yyval.list) = NIL; } + break; + + case 102: +#line 687 "gram.y" + { + (yyval.defelt) = makeDefElem("password", + (Node *)makeString((yyvsp[0].str))); + } + break; + + case 103: +#line 692 "gram.y" + { + (yyval.defelt) = makeDefElem("password", NULL); + } + break; + + case 104: +#line 696 "gram.y" + { + (yyval.defelt) = makeDefElem("encryptedPassword", + (Node *)makeString((yyvsp[0].str))); + } + break; + + case 105: +#line 701 "gram.y" + { + (yyval.defelt) = makeDefElem("unencryptedPassword", + (Node *)makeString((yyvsp[0].str))); + } + break; + + case 106: +#line 706 "gram.y" + { + (yyval.defelt) = makeDefElem("superuser", (Node *)makeInteger(TRUE)); + } + break; + + case 107: +#line 710 "gram.y" + { + (yyval.defelt) = makeDefElem("superuser", (Node *)makeInteger(FALSE)); + } + break; + + case 108: +#line 714 "gram.y" + { + (yyval.defelt) = makeDefElem("inherit", (Node *)makeInteger(TRUE)); + } + break; + + case 109: +#line 718 "gram.y" + { + (yyval.defelt) = makeDefElem("inherit", (Node *)makeInteger(FALSE)); + } + break; + + case 110: +#line 722 "gram.y" + { + (yyval.defelt) = makeDefElem("createdb", (Node *)makeInteger(TRUE)); + } + break; + + case 111: +#line 726 "gram.y" + { + (yyval.defelt) = makeDefElem("createdb", (Node *)makeInteger(FALSE)); + } + break; + + case 112: +#line 730 "gram.y" + { + (yyval.defelt) = makeDefElem("createrole", (Node *)makeInteger(TRUE)); + } + break; + + case 113: +#line 734 "gram.y" + { + (yyval.defelt) = makeDefElem("createrole", (Node *)makeInteger(FALSE)); + } + break; + + case 114: +#line 738 "gram.y" + { + /* For backwards compatibility, synonym for SUPERUSER */ + (yyval.defelt) = makeDefElem("superuser", (Node *)makeInteger(TRUE)); + } + break; + + case 115: +#line 743 "gram.y" + { + (yyval.defelt) = makeDefElem("superuser", (Node *)makeInteger(FALSE)); + } + break; + + case 116: +#line 747 "gram.y" + { + (yyval.defelt) = makeDefElem("canlogin", (Node *)makeInteger(TRUE)); + } + break; + + case 117: +#line 751 "gram.y" + { + (yyval.defelt) = makeDefElem("canlogin", (Node *)makeInteger(FALSE)); + } + break; + + case 118: +#line 755 "gram.y" + { + (yyval.defelt) = makeDefElem("connectionlimit", (Node *)makeInteger((yyvsp[0].ival))); + } + break; + + case 119: +#line 759 "gram.y" + { + (yyval.defelt) = makeDefElem("validUntil", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 120: +#line 764 "gram.y" + { + (yyval.defelt) = makeDefElem("rolemembers", (Node *)(yyvsp[0].list)); + } + break; + + case 121: +#line 769 "gram.y" + { + (yyval.defelt) = makeDefElem("sysid", (Node *)makeInteger((yyvsp[0].ival))); + } + break; + + case 122: +#line 773 "gram.y" + { + (yyval.defelt) = makeDefElem("adminmembers", (Node *)(yyvsp[0].list)); + } + break; + + case 123: +#line 777 "gram.y" + { + (yyval.defelt) = makeDefElem("rolemembers", (Node *)(yyvsp[0].list)); + } + break; + + case 124: +#line 781 "gram.y" + { + (yyval.defelt) = makeDefElem("addroleto", (Node *)(yyvsp[0].list)); + } + break; + + case 125: +#line 785 "gram.y" + { + (yyval.defelt) = makeDefElem("addroleto", (Node *)(yyvsp[0].list)); + } + break; + + case 126: +#line 799 "gram.y" + { + CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_USER; + n->role = (yyvsp[-2].str); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 127: +#line 817 "gram.y" + { + AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = (yyvsp[-2].str); + n->action = +1; /* add, if there are members */ + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 128: +#line 828 "gram.y" + { + AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = (yyvsp[-1].str); + n->setstmt = (yyvsp[0].vsetstmt); + (yyval.node) = (Node *)n; + } + break; + + case 129: +#line 845 "gram.y" + { + AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = (yyvsp[-2].str); + n->action = +1; /* add, if there are members */ + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 130: +#line 857 "gram.y" + { + AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = (yyvsp[-1].str); + n->setstmt = (yyvsp[0].vsetstmt); + (yyval.node) = (Node *)n; + } + break; + + case 131: +#line 877 "gram.y" + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = FALSE; + n->roles = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 132: +#line 884 "gram.y" + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = TRUE; + n->roles = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 133: +#line 903 "gram.y" + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = FALSE; + n->roles = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 134: +#line 910 "gram.y" + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->roles = (yyvsp[0].list); + n->missing_ok = TRUE; + (yyval.node) = (Node *)n; + } + break; + + case 135: +#line 927 "gram.y" + { + CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_GROUP; + n->role = (yyvsp[-2].str); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 136: +#line 945 "gram.y" + { + AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = (yyvsp[-3].str); + n->action = (yyvsp[-2].ival); + n->options = list_make1(makeDefElem("rolemembers", + (Node *)(yyvsp[0].list))); + (yyval.node) = (Node *)n; + } + break; + + case 137: +#line 955 "gram.y" + { (yyval.ival) = +1; } + break; + + case 138: +#line 956 "gram.y" + { (yyval.ival) = -1; } + break; + + case 139: +#line 969 "gram.y" + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = FALSE; + n->roles = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 140: +#line 976 "gram.y" + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = TRUE; + n->roles = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 141: +#line 993 "gram.y" + { + CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* One can omit the schema name or the authorization id. */ + if ((yyvsp[-3].str) != NULL) + n->schemaname = (yyvsp[-3].str); + else + n->schemaname = (yyvsp[-1].str); + n->authid = (yyvsp[-1].str); + n->schemaElts = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 142: +#line 1005 "gram.y" + { + CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* ...but not both */ + n->schemaname = (yyvsp[-1].str); + n->authid = NULL; + n->schemaElts = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 143: +#line 1016 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 144: +#line 1017 "gram.y" + { (yyval.str) = NULL; } + break; + + case 145: +#line 1021 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].node)); } + break; + + case 146: +#line 1022 "gram.y" + { (yyval.list) = NIL; } + break; + + case 153: +#line 1050 "gram.y" + { + VariableSetStmt *n = (yyvsp[0].vsetstmt); + n->is_local = false; + (yyval.node) = (Node *) n; + } + break; + + case 154: +#line 1056 "gram.y" + { + VariableSetStmt *n = (yyvsp[0].vsetstmt); + n->is_local = true; + (yyval.node) = (Node *) n; + } + break; + + case 155: +#line 1062 "gram.y" + { + VariableSetStmt *n = (yyvsp[0].vsetstmt); + n->is_local = false; + (yyval.node) = (Node *) n; + } + break; + + case 156: +#line 1071 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = (yyvsp[-2].str); + n->args = (yyvsp[0].list); + (yyval.vsetstmt) = n; + } + break; + + case 157: +#line 1079 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = (yyvsp[-2].str); + n->args = (yyvsp[0].list); + (yyval.vsetstmt) = n; + } + break; + + case 158: +#line 1087 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; + n->name = (yyvsp[-2].str); + (yyval.vsetstmt) = n; + } + break; + + case 159: +#line 1094 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; + n->name = (yyvsp[-2].str); + (yyval.vsetstmt) = n; + } + break; + + case 160: +#line 1101 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_CURRENT; + n->name = (yyvsp[-2].str); + (yyval.vsetstmt) = n; + } + break; + + case 161: +#line 1109 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "timezone"; + if ((yyvsp[0].node) != NULL) + n->args = list_make1((yyvsp[0].node)); + else + n->kind = VAR_SET_DEFAULT; + (yyval.vsetstmt) = n; + } + break; + + case 162: +#line 1120 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; + n->name = "TRANSACTION"; + n->args = (yyvsp[0].list); + (yyval.vsetstmt) = n; + } + break; + + case 163: +#line 1128 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; + n->name = "SESSION CHARACTERISTICS"; + n->args = (yyvsp[0].list); + (yyval.vsetstmt) = n; + } + break; + + case 164: +#line 1136 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "client_encoding"; + if ((yyvsp[0].str) != NULL) + n->args = list_make1(makeStringConst((yyvsp[0].str), NULL)); + else + n->kind = VAR_SET_DEFAULT; + (yyval.vsetstmt) = n; + } + break; + + case 165: +#line 1147 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "role"; + n->args = list_make1(makeStringConst((yyvsp[0].str), NULL)); + (yyval.vsetstmt) = n; + } + break; + + case 166: +#line 1155 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "session_authorization"; + n->args = list_make1(makeStringConst((yyvsp[0].str), NULL)); + (yyval.vsetstmt) = n; + } + break; + + case 167: +#line 1163 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; + n->name = "session_authorization"; + (yyval.vsetstmt) = n; + } + break; + + case 168: +#line 1170 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "xmloption"; + n->args = list_make1(makeStringConst((yyvsp[0].ival) == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT", NULL)); + (yyval.vsetstmt) = n; + } + break; + + case 169: +#line 1179 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 170: +#line 1181 "gram.y" + { + (yyval.str) = palloc(strlen((yyvsp[-2].str)) + strlen((yyvsp[0].str)) + 2); + sprintf((yyval.str), "%s.%s", (yyvsp[-2].str), (yyvsp[0].str)); + } + break; + + case 171: +#line 1187 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 172: +#line 1188 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 173: +#line 1192 "gram.y" + { (yyval.node) = makeStringConst((yyvsp[0].str), NULL); } + break; + + case 174: +#line 1194 "gram.y" + { (yyval.node) = makeStringConst((yyvsp[0].str), NULL); } + break; + + case 175: +#line 1196 "gram.y" + { (yyval.node) = makeAConst((yyvsp[0].value)); } + break; + + case 176: +#line 1199 "gram.y" + { (yyval.str) = "read uncommitted"; } + break; + + case 177: +#line 1200 "gram.y" + { (yyval.str) = "read committed"; } + break; + + case 178: +#line 1201 "gram.y" + { (yyval.str) = "repeatable read"; } + break; + + case 179: +#line 1202 "gram.y" + { (yyval.str) = "serializable"; } + break; + + case 180: +#line 1206 "gram.y" + { (yyval.str) = "true"; } + break; + + case 181: +#line 1207 "gram.y" + { (yyval.str) = "false"; } + break; + + case 182: +#line 1208 "gram.y" + { (yyval.str) = "on"; } + break; + + case 183: +#line 1209 "gram.y" + { (yyval.str) = "off"; } + break; + + case 184: +#line 1222 "gram.y" + { + (yyval.node) = makeStringConst((yyvsp[0].str), NULL); + } + break; + + case 185: +#line 1226 "gram.y" + { + (yyval.node) = makeStringConst((yyvsp[0].str), NULL); + } + break; + + case 186: +#line 1230 "gram.y" + { + A_Const *n = (A_Const *) makeStringConst((yyvsp[-1].str), (yyvsp[-2].typnam)); + if ((yyvsp[0].ival) != INTERVAL_FULL_RANGE) + { + if (((yyvsp[0].ival) & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("time zone interval must be HOUR or HOUR TO MINUTE"))); + n->typename->typmods = list_make1(makeIntConst((yyvsp[0].ival))); + } + (yyval.node) = (Node *)n; + } + break; + + case 187: +#line 1243 "gram.y" + { + A_Const *n = (A_Const *) makeStringConst((yyvsp[-1].str), (yyvsp[-5].typnam)); + if (((yyvsp[0].ival) != INTERVAL_FULL_RANGE) + && (((yyvsp[0].ival) & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("time zone interval must be HOUR or HOUR TO MINUTE"))); + n->typename->typmods = list_make2(makeIntConst((yyvsp[0].ival)), + makeIntConst((yyvsp[-3].ival))); + (yyval.node) = (Node *)n; + } + break; + + case 188: +#line 1254 "gram.y" + { (yyval.node) = makeAConst((yyvsp[0].value)); } + break; + + case 189: +#line 1255 "gram.y" + { (yyval.node) = NULL; } + break; + + case 190: +#line 1256 "gram.y" + { (yyval.node) = NULL; } + break; + + case 191: +#line 1260 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 192: +#line 1261 "gram.y" + { (yyval.str) = NULL; } + break; + + case 193: +#line 1262 "gram.y" + { (yyval.str) = NULL; } + break; + + case 194: +#line 1266 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 195: +#line 1267 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 196: +#line 1272 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 197: +#line 1279 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = "timezone"; + (yyval.node) = (Node *) n; + } + break; + + case 198: +#line 1286 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = "transaction_isolation"; + (yyval.node) = (Node *) n; + } + break; + + case 199: +#line 1293 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = "session_authorization"; + (yyval.node) = (Node *) n; + } + break; + + case 200: +#line 1300 "gram.y" + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET_ALL; + (yyval.node) = (Node *) n; + } + break; + + case 201: +#line 1309 "gram.y" + { (yyval.vsetstmt) = (yyvsp[0].vsetstmt); } + break; + + case 202: +#line 1310 "gram.y" + { (yyval.vsetstmt) = (VariableSetStmt *) (yyvsp[0].node); } + break; + + case 203: +#line 1316 "gram.y" + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 204: +#line 1322 "gram.y" + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "timezone"; + (yyval.node) = (Node *) n; + } + break; + + case 205: +#line 1328 "gram.y" + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "transaction_isolation"; + (yyval.node) = (Node *) n; + } + break; + + case 206: +#line 1334 "gram.y" + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "session_authorization"; + (yyval.node) = (Node *) n; + } + break; + + case 207: +#line 1340 "gram.y" + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "all"; + (yyval.node) = (Node *) n; + } + break; + + case 208: +#line 1350 "gram.y" + { + ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt); + n->constraints = (yyvsp[-1].list); + n->deferred = (yyvsp[0].boolean); + (yyval.node) = (Node *) n; + } + break; + + case 209: +#line 1359 "gram.y" + { (yyval.list) = NIL; } + break; + + case 210: +#line 1360 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 211: +#line 1364 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 212: +#line 1365 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 213: +#line 1374 "gram.y" + { + CheckPointStmt *n = makeNode(CheckPointStmt); + (yyval.node) = (Node *)n; + } + break; + + case 214: +#line 1389 "gram.y" + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_ALL; + (yyval.node) = (Node *) n; + } + break; + + case 215: +#line 1395 "gram.y" + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_TEMP; + (yyval.node) = (Node *) n; + } + break; + + case 216: +#line 1401 "gram.y" + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_TEMP; + (yyval.node) = (Node *) n; + } + break; + + case 217: +#line 1407 "gram.y" + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_PLANS; + (yyval.node) = (Node *) n; + } + break; + + case 218: +#line 1423 "gram.y" + { + AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = (yyvsp[-1].range); + n->cmds = (yyvsp[0].list); + n->relkind = OBJECT_TABLE; + (yyval.node) = (Node *)n; + } + break; + + case 219: +#line 1431 "gram.y" + { + AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = (yyvsp[-1].range); + n->cmds = (yyvsp[0].list); + n->relkind = OBJECT_INDEX; + (yyval.node) = (Node *)n; + } + break; + + case 220: +#line 1441 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 221: +#line 1442 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 222: +#line 1449 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; + n->def = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 223: +#line 1457 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ColumnDefault; + n->name = (yyvsp[-1].str); + n->def = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 224: +#line 1466 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropNotNull; + n->name = (yyvsp[-3].str); + (yyval.node) = (Node *)n; + } + break; + + case 225: +#line 1474 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetNotNull; + n->name = (yyvsp[-3].str); + (yyval.node) = (Node *)n; + } + break; + + case 226: +#line 1482 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetStatistics; + n->name = (yyvsp[-3].str); + n->def = (Node *) (yyvsp[0].value); + (yyval.node) = (Node *)n; + } + break; + + case 227: +#line 1491 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetStorage; + n->name = (yyvsp[-3].str); + n->def = (Node *) makeString((yyvsp[0].str)); + (yyval.node) = (Node *)n; + } + break; + + case 228: +#line 1500 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropColumn; + n->name = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 229: +#line 1512 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AlterColumnType; + n->name = (yyvsp[-3].str); + n->def = (Node *) (yyvsp[-1].typnam); + n->transform = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 230: +#line 1522 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddConstraint; + n->def = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 231: +#line 1530 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropConstraint; + n->name = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 232: +#line 1539 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropOids; + (yyval.node) = (Node *)n; + } + break; + + case 233: +#line 1546 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ClusterOn; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 234: +#line 1554 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropCluster; + n->name = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 235: +#line 1562 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrig; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 236: +#line 1570 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableAlwaysTrig; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 237: +#line 1578 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableReplicaTrig; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 238: +#line 1586 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrigAll; + (yyval.node) = (Node *)n; + } + break; + + case 239: +#line 1593 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrigUser; + (yyval.node) = (Node *)n; + } + break; + + case 240: +#line 1600 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrig; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 241: +#line 1608 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrigAll; + (yyval.node) = (Node *)n; + } + break; + + case 242: +#line 1615 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrigUser; + (yyval.node) = (Node *)n; + } + break; + + case 243: +#line 1622 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableRule; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 244: +#line 1630 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableAlwaysRule; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 245: +#line 1638 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableReplicaRule; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 246: +#line 1646 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableRule; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 247: +#line 1654 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddInherit; + n->def = (Node *) (yyvsp[0].range); + (yyval.node) = (Node *)n; + } + break; + + case 248: +#line 1662 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropInherit; + n->def = (Node *) (yyvsp[0].range); + (yyval.node) = (Node *)n; + } + break; + + case 249: +#line 1669 "gram.y" + { + (yyval.node) = (yyvsp[0].node); + } + break; + + case 250: +#line 1675 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 251: +#line 1676 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 252: +#line 1683 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ChangeOwner; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 253: +#line 1691 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetTableSpace; + n->name = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 254: +#line 1699 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetRelOptions; + n->def = (Node *)(yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 255: +#line 1707 "gram.y" + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ResetRelOptions; + n->def = (Node *)(yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 256: +#line 1717 "gram.y" + { + /* Treat SET DEFAULT NULL the same as DROP DEFAULT */ + if (exprIsNullConstant((yyvsp[0].node))) + (yyval.node) = NULL; + else + (yyval.node) = (yyvsp[0].node); + } + break; + + case 257: +#line 1724 "gram.y" + { (yyval.node) = NULL; } + break; + + case 258: +#line 1728 "gram.y" + { (yyval.dbehavior) = DROP_CASCADE; } + break; + + case 259: +#line 1729 "gram.y" + { (yyval.dbehavior) = DROP_RESTRICT; } + break; + + case 260: +#line 1730 "gram.y" + { (yyval.dbehavior) = DROP_RESTRICT; /* default */ } + break; + + case 261: +#line 1734 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 262: +#line 1735 "gram.y" + { (yyval.node) = NULL; } + break; + + case 263: +#line 1749 "gram.y" + { + ClosePortalStmt *n = makeNode(ClosePortalStmt); + n->portalname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 264: +#line 1755 "gram.y" + { + ClosePortalStmt *n = makeNode(ClosePortalStmt); + n->portalname = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 265: +#line 1779 "gram.y" + { + CopyStmt *n = makeNode(CopyStmt); + n->relation = (yyvsp[-7].range); + n->query = NULL; + n->attlist = (yyvsp[-6].list); + n->is_from = (yyvsp[-4].boolean); + n->filename = (yyvsp[-3].str); + + n->options = NIL; + /* Concatenate user-supplied flags */ + if ((yyvsp[-8].defelt)) + n->options = lappend(n->options, (yyvsp[-8].defelt)); + if ((yyvsp[-5].defelt)) + n->options = lappend(n->options, (yyvsp[-5].defelt)); + if ((yyvsp[-2].defelt)) + n->options = lappend(n->options, (yyvsp[-2].defelt)); + if ((yyvsp[0].list)) + n->options = list_concat(n->options, (yyvsp[0].list)); + (yyval.node) = (Node *)n; + } + break; + + case 266: +#line 1801 "gram.y" + { + CopyStmt *n = makeNode(CopyStmt); + n->relation = NULL; + n->query = (yyvsp[-4].node); + n->attlist = NIL; + n->is_from = false; + n->filename = (yyvsp[-2].str); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 267: +#line 1814 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 268: +#line 1815 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 269: +#line 1824 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 270: +#line 1825 "gram.y" + { (yyval.str) = NULL; } + break; + + case 271: +#line 1826 "gram.y" + { (yyval.str) = NULL; } + break; + + case 272: +#line 1832 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 273: +#line 1833 "gram.y" + { (yyval.list) = NIL; } + break; + + case 274: +#line 1839 "gram.y" + { + (yyval.defelt) = makeDefElem("binary", (Node *)makeInteger(TRUE)); + } + break; + + case 275: +#line 1843 "gram.y" + { + (yyval.defelt) = makeDefElem("oids", (Node *)makeInteger(TRUE)); + } + break; + + case 276: +#line 1847 "gram.y" + { + (yyval.defelt) = makeDefElem("delimiter", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 277: +#line 1851 "gram.y" + { + (yyval.defelt) = makeDefElem("null", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 278: +#line 1855 "gram.y" + { + (yyval.defelt) = makeDefElem("csv", (Node *)makeInteger(TRUE)); + } + break; + + case 279: +#line 1859 "gram.y" + { + (yyval.defelt) = makeDefElem("header", (Node *)makeInteger(TRUE)); + } + break; + + case 280: +#line 1863 "gram.y" + { + (yyval.defelt) = makeDefElem("quote", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 281: +#line 1867 "gram.y" + { + (yyval.defelt) = makeDefElem("escape", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 282: +#line 1871 "gram.y" + { + (yyval.defelt) = makeDefElem("force_quote", (Node *)(yyvsp[0].list)); + } + break; + + case 283: +#line 1875 "gram.y" + { + (yyval.defelt) = makeDefElem("force_notnull", (Node *)(yyvsp[0].list)); + } + break; + + case 284: +#line 1884 "gram.y" + { + (yyval.defelt) = makeDefElem("binary", (Node *)makeInteger(TRUE)); + } + break; + + case 285: +#line 1887 "gram.y" + { (yyval.defelt) = NULL; } + break; + + case 286: +#line 1892 "gram.y" + { + (yyval.defelt) = makeDefElem("oids", (Node *)makeInteger(TRUE)); + } + break; + + case 287: +#line 1895 "gram.y" + { (yyval.defelt) = NULL; } + break; + + case 288: +#line 1901 "gram.y" + { + (yyval.defelt) = makeDefElem("delimiter", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 289: +#line 1904 "gram.y" + { (yyval.defelt) = NULL; } + break; + + case 290: +#line 1908 "gram.y" + {} + break; + + case 291: +#line 1909 "gram.y" + {} + break; + + case 292: +#line 1922 "gram.y" + { + CreateStmt *n = makeNode(CreateStmt); + (yyvsp[-7].range)->istemp = (yyvsp[-9].boolean); + n->relation = (yyvsp[-7].range); + n->tableElts = (yyvsp[-5].list); + n->inhRelations = (yyvsp[-3].list); + n->constraints = NIL; + n->options = (yyvsp[-2].list); + n->oncommit = (yyvsp[-1].oncommit); + n->tablespacename = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 293: +#line 1936 "gram.y" + { + /* SQL99 CREATE TABLE OF (cols) seems to be satisfied + * by our inheritance capabilities. Let's try it... + */ + CreateStmt *n = makeNode(CreateStmt); + (yyvsp[-8].range)->istemp = (yyvsp[-10].boolean); + n->relation = (yyvsp[-8].range); + n->tableElts = (yyvsp[-4].list); + n->inhRelations = list_make1((yyvsp[-6].range)); + n->constraints = NIL; + n->options = (yyvsp[-2].list); + n->oncommit = (yyvsp[-1].oncommit); + n->tablespacename = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 294: +#line 1960 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 295: +#line 1961 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 296: +#line 1962 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 297: +#line 1963 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 298: +#line 1964 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 299: +#line 1965 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 300: +#line 1966 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 301: +#line 1970 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 302: +#line 1971 "gram.y" + { (yyval.list) = NIL; } + break; + + case 303: +#line 1976 "gram.y" + { + (yyval.list) = list_make1((yyvsp[0].node)); + } + break; + + case 304: +#line 1980 "gram.y" + { + (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); + } + break; + + case 305: +#line 1986 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 306: +#line 1987 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 307: +#line 1988 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 308: +#line 1992 "gram.y" + { + ColumnDef *n = makeNode(ColumnDef); + n->colname = (yyvsp[-2].str); + n->typename = (yyvsp[-1].typnam); + n->constraints = (yyvsp[0].list); + n->is_local = true; + (yyval.node) = (Node *)n; + } + break; + + case 309: +#line 2003 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].node)); } + break; + + case 310: +#line 2004 "gram.y" + { (yyval.list) = NIL; } + break; + + case 311: +#line 2009 "gram.y" + { + switch (nodeTag((yyvsp[0].node))) + { + case T_Constraint: + { + Constraint *n = (Constraint *)(yyvsp[0].node); + n->name = (yyvsp[-1].str); + } + break; + case T_FkConstraint: + { + FkConstraint *n = (FkConstraint *)(yyvsp[0].node); + n->constr_name = (yyvsp[-1].str); + } + break; + default: + break; + } + (yyval.node) = (yyvsp[0].node); + } + break; + + case 312: +#line 2029 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 313: +#line 2030 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 314: +#line 2050 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_NOTNULL; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 315: +#line 2061 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_NULL; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 316: +#line 2072 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->options = (yyvsp[-1].list); + n->indexspace = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 317: +#line 2084 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->options = (yyvsp[-1].list); + n->indexspace = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 318: +#line 2096 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_CHECK; + n->name = NULL; + n->raw_expr = (yyvsp[-1].node); + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 319: +#line 2107 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_DEFAULT; + n->name = NULL; + if (exprIsNullConstant((yyvsp[0].node))) + { + /* DEFAULT NULL should be reported as empty expr */ + n->raw_expr = NULL; + } + else + { + n->raw_expr = (yyvsp[0].node); + } + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 320: +#line 2126 "gram.y" + { + FkConstraint *n = makeNode(FkConstraint); + n->constr_name = NULL; + n->pktable = (yyvsp[-3].range); + n->fk_attrs = NIL; + n->pk_attrs = (yyvsp[-2].list); + n->fk_matchtype = (yyvsp[-1].ival); + n->fk_upd_action = (char) ((yyvsp[0].ival) >> 8); + n->fk_del_action = (char) ((yyvsp[0].ival) & 0xFF); + n->deferrable = FALSE; + n->initdeferred = FALSE; + (yyval.node) = (Node *)n; + } + break; + + case 321: +#line 2155 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_DEFERRABLE; + (yyval.node) = (Node *)n; + } + break; + + case 322: +#line 2161 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_NOT_DEFERRABLE; + (yyval.node) = (Node *)n; + } + break; + + case 323: +#line 2167 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_DEFERRED; + (yyval.node) = (Node *)n; + } + break; + + case 324: +#line 2173 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_IMMEDIATE; + (yyval.node) = (Node *)n; + } + break; + + case 325: +#line 2191 "gram.y" + { + InhRelation *n = makeNode(InhRelation); + n->relation = (yyvsp[-1].range); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 326: +#line 2200 "gram.y" + { (yyval.list) = lappend_int((yyvsp[-1].list), (yyvsp[0].ival)); } + break; + + case 327: +#line 2201 "gram.y" + { (yyval.list) = NIL; } + break; + + case 328: +#line 2205 "gram.y" + { (yyval.ival) = CREATE_TABLE_LIKE_INCLUDING_DEFAULTS; } + break; + + case 329: +#line 2206 "gram.y" + { (yyval.ival) = CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS; } + break; + + case 330: +#line 2207 "gram.y" + { (yyval.ival) = CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS; } + break; + + case 331: +#line 2208 "gram.y" + { (yyval.ival) = CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS; } + break; + + case 332: +#line 2209 "gram.y" + { (yyval.ival) = CREATE_TABLE_LIKE_INCLUDING_INDEXES; } + break; + + case 333: +#line 2210 "gram.y" + { (yyval.ival) = CREATE_TABLE_LIKE_EXCLUDING_INDEXES; } + break; + + case 334: +#line 2220 "gram.y" + { + switch (nodeTag((yyvsp[0].node))) + { + case T_Constraint: + { + Constraint *n = (Constraint *)(yyvsp[0].node); + n->name = (yyvsp[-1].str); + } + break; + case T_FkConstraint: + { + FkConstraint *n = (FkConstraint *)(yyvsp[0].node); + n->constr_name = (yyvsp[-1].str); + } + break; + default: + break; + } + (yyval.node) = (yyvsp[0].node); + } + break; + + case 335: +#line 2240 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 336: +#line 2245 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_CHECK; + n->name = NULL; + n->raw_expr = (yyvsp[-1].node); + n->cooked_expr = NULL; + n->indexspace = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 337: +#line 2255 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = (yyvsp[-3].list); + n->options = (yyvsp[-1].list); + n->indexspace = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 338: +#line 2267 "gram.y" + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = (yyvsp[-3].list); + n->options = (yyvsp[-1].list); + n->indexspace = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 339: +#line 2280 "gram.y" + { + FkConstraint *n = makeNode(FkConstraint); + n->constr_name = NULL; + n->pktable = (yyvsp[-4].range); + n->fk_attrs = (yyvsp[-7].list); + n->pk_attrs = (yyvsp[-3].list); + n->fk_matchtype = (yyvsp[-2].ival); + n->fk_upd_action = (char) ((yyvsp[-1].ival) >> 8); + n->fk_del_action = (char) ((yyvsp[-1].ival) & 0xFF); + n->deferrable = ((yyvsp[0].ival) & 1) != 0; + n->initdeferred = ((yyvsp[0].ival) & 2) != 0; + (yyval.node) = (Node *)n; + } + break; + + case 340: +#line 2296 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 341: +#line 2297 "gram.y" + { (yyval.list) = NIL; } + break; + + case 342: +#line 2301 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 343: +#line 2302 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 344: +#line 2306 "gram.y" + { + (yyval.node) = (Node *) makeString((yyvsp[0].str)); + } + break; + + case 345: +#line 2312 "gram.y" + { + (yyval.ival) = FKCONSTR_MATCH_FULL; + } + break; + + case 346: +#line 2316 "gram.y" + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("MATCH PARTIAL not yet implemented"))); + (yyval.ival) = FKCONSTR_MATCH_PARTIAL; + } + break; + + case 347: +#line 2323 "gram.y" + { + (yyval.ival) = FKCONSTR_MATCH_UNSPECIFIED; + } + break; + + case 348: +#line 2327 "gram.y" + { + (yyval.ival) = FKCONSTR_MATCH_UNSPECIFIED; + } + break; + + case 349: +#line 2340 "gram.y" + { (yyval.ival) = ((yyvsp[0].ival) << 8) | (FKCONSTR_ACTION_NOACTION & 0xFF); } + break; + + case 350: +#line 2342 "gram.y" + { (yyval.ival) = (FKCONSTR_ACTION_NOACTION << 8) | ((yyvsp[0].ival) & 0xFF); } + break; + + case 351: +#line 2344 "gram.y" + { (yyval.ival) = ((yyvsp[-1].ival) << 8) | ((yyvsp[0].ival) & 0xFF); } + break; + + case 352: +#line 2346 "gram.y" + { (yyval.ival) = ((yyvsp[0].ival) << 8) | ((yyvsp[-1].ival) & 0xFF); } + break; + + case 353: +#line 2348 "gram.y" + { (yyval.ival) = (FKCONSTR_ACTION_NOACTION << 8) | (FKCONSTR_ACTION_NOACTION & 0xFF); } + break; + + case 354: +#line 2351 "gram.y" + { (yyval.ival) = (yyvsp[0].ival); } + break; + + case 355: +#line 2354 "gram.y" + { (yyval.ival) = (yyvsp[0].ival); } + break; + + case 356: +#line 2358 "gram.y" + { (yyval.ival) = FKCONSTR_ACTION_NOACTION; } + break; + + case 357: +#line 2359 "gram.y" + { (yyval.ival) = FKCONSTR_ACTION_RESTRICT; } + break; + + case 358: +#line 2360 "gram.y" + { (yyval.ival) = FKCONSTR_ACTION_CASCADE; } + break; + + case 359: +#line 2361 "gram.y" + { (yyval.ival) = FKCONSTR_ACTION_SETNULL; } + break; + + case 360: +#line 2362 "gram.y" + { (yyval.ival) = FKCONSTR_ACTION_SETDEFAULT; } + break; + + case 361: +#line 2365 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 362: +#line 2366 "gram.y" + { (yyval.list) = NIL; } + break; + + case 363: +#line 2371 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 364: +#line 2372 "gram.y" + { (yyval.list) = list_make1(defWithOids(true)); } + break; + + case 365: +#line 2373 "gram.y" + { (yyval.list) = list_make1(defWithOids(false)); } + break; + + case 366: +#line 2374 "gram.y" + { (yyval.list) = NIL; } + break; + + case 367: +#line 2377 "gram.y" + { (yyval.oncommit) = ONCOMMIT_DROP; } + break; + + case 368: +#line 2378 "gram.y" + { (yyval.oncommit) = ONCOMMIT_DELETE_ROWS; } + break; + + case 369: +#line 2379 "gram.y" + { (yyval.oncommit) = ONCOMMIT_PRESERVE_ROWS; } + break; + + case 370: +#line 2380 "gram.y" + { (yyval.oncommit) = ONCOMMIT_NOOP; } + break; + + case 371: +#line 2383 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 372: +#line 2384 "gram.y" + { (yyval.str) = NULL; } + break; + + case 373: +#line 2387 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 374: +#line 2388 "gram.y" + { (yyval.str) = NULL; } + break; + + case 375: +#line 2399 "gram.y" + { + /* + * When the SelectStmt is a set-operation tree, we must + * stuff the INTO information into the leftmost component + * Select, because that's where analyze.c will expect + * to find it. Similarly, the output column names must + * be attached to that Select's target list. + */ + SelectStmt *n = findLeftmostSelect((SelectStmt *) (yyvsp[0].node)); + if (n->intoClause != NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("CREATE TABLE AS cannot specify INTO"))); + (yyvsp[-2].into)->rel->istemp = (yyvsp[-4].boolean); + n->intoClause = (yyvsp[-2].into); + (yyval.node) = (yyvsp[0].node); + } + break; + + case 376: +#line 2420 "gram.y" + { + (yyval.into) = makeNode(IntoClause); + (yyval.into)->rel = (yyvsp[-4].range); + (yyval.into)->colNames = (yyvsp[-3].list); + (yyval.into)->options = (yyvsp[-2].list); + (yyval.into)->onCommit = (yyvsp[-1].oncommit); + (yyval.into)->tableSpaceName = (yyvsp[0].str); + } + break; + + case 377: +#line 2431 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 378: +#line 2432 "gram.y" + { (yyval.list) = NIL; } + break; + + case 379: +#line 2436 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 380: +#line 2437 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 381: +#line 2442 "gram.y" + { + ColumnDef *n = makeNode(ColumnDef); + n->colname = (yyvsp[0].str); + n->typename = NULL; + n->inhcount = 0; + n->is_local = true; + n->is_not_null = false; + n->raw_default = NULL; + n->cooked_default = NULL; + n->constraints = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 382: +#line 2467 "gram.y" + { + CreateSeqStmt *n = makeNode(CreateSeqStmt); + (yyvsp[-1].range)->istemp = (yyvsp[-3].boolean); + n->sequence = (yyvsp[-1].range); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 383: +#line 2478 "gram.y" + { + AlterSeqStmt *n = makeNode(AlterSeqStmt); + n->sequence = (yyvsp[-1].range); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 384: +#line 2486 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 385: +#line 2487 "gram.y" + { (yyval.list) = NIL; } + break; + + case 386: +#line 2491 "gram.y" + { + (yyval.defelt) = makeDefElem("cache", (Node *)(yyvsp[0].value)); + } + break; + + case 387: +#line 2495 "gram.y" + { + (yyval.defelt) = makeDefElem("cycle", (Node *)makeInteger(TRUE)); + } + break; + + case 388: +#line 2499 "gram.y" + { + (yyval.defelt) = makeDefElem("cycle", (Node *)makeInteger(FALSE)); + } + break; + + case 389: +#line 2503 "gram.y" + { + (yyval.defelt) = makeDefElem("increment", (Node *)(yyvsp[0].value)); + } + break; + + case 390: +#line 2507 "gram.y" + { + (yyval.defelt) = makeDefElem("maxvalue", (Node *)(yyvsp[0].value)); + } + break; + + case 391: +#line 2511 "gram.y" + { + (yyval.defelt) = makeDefElem("minvalue", (Node *)(yyvsp[0].value)); + } + break; + + case 392: +#line 2515 "gram.y" + { + (yyval.defelt) = makeDefElem("maxvalue", NULL); + } + break; + + case 393: +#line 2519 "gram.y" + { + (yyval.defelt) = makeDefElem("minvalue", NULL); + } + break; + + case 394: +#line 2523 "gram.y" + { + (yyval.defelt) = makeDefElem("owned_by", (Node *)(yyvsp[0].list)); + } + break; + + case 395: +#line 2527 "gram.y" + { + (yyval.defelt) = makeDefElem("start", (Node *)(yyvsp[0].value)); + } + break; + + case 396: +#line 2531 "gram.y" + { + (yyval.defelt) = makeDefElem("restart", (Node *)(yyvsp[0].value)); + } + break; + + case 397: +#line 2536 "gram.y" + {} + break; + + case 398: +#line 2537 "gram.y" + {} + break; + + case 399: +#line 2541 "gram.y" + { (yyval.value) = (yyvsp[0].value); } + break; + + case 400: +#line 2542 "gram.y" + { (yyval.value) = (yyvsp[0].value); } + break; + + case 401: +#line 2545 "gram.y" + { (yyval.value) = makeFloat((yyvsp[0].str)); } + break; + + case 402: +#line 2547 "gram.y" + { + (yyval.value) = makeFloat((yyvsp[0].str)); + doNegateFloat((yyval.value)); + } + break; + + case 403: +#line 2553 "gram.y" + { (yyval.value) = makeInteger((yyvsp[0].ival)); } + break; + + case 404: +#line 2566 "gram.y" + { + CreatePLangStmt *n = makeNode(CreatePLangStmt); + n->plname = (yyvsp[0].str); + /* parameters are all to be supplied by system */ + n->plhandler = NIL; + n->plvalidator = NIL; + n->pltrusted = false; + (yyval.node) = (Node *)n; + } + break; + + case 405: +#line 2577 "gram.y" + { + CreatePLangStmt *n = makeNode(CreatePLangStmt); + n->plname = (yyvsp[-4].str); + n->plhandler = (yyvsp[-2].list); + n->plvalidator = (yyvsp[-1].list); + n->pltrusted = (yyvsp[-7].boolean); + /* LANCOMPILER is now ignored entirely */ + (yyval.node) = (Node *)n; + } + break; + + case 406: +#line 2589 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 407: +#line 2590 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 408: +#line 2598 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 409: +#line 2599 "gram.y" + { (yyval.list) = lcons(makeString((yyvsp[-1].str)), (yyvsp[0].list)); } + break; + + case 410: +#line 2603 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 411: +#line 2604 "gram.y" + { (yyval.list) = NIL; } + break; + + case 412: +#line 2608 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 413: +#line 2609 "gram.y" + { (yyval.str) = NULL; } + break; + + case 414: +#line 2614 "gram.y" + { + DropPLangStmt *n = makeNode(DropPLangStmt); + n->plname = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = false; + (yyval.node) = (Node *)n; + } + break; + + case 415: +#line 2622 "gram.y" + { + DropPLangStmt *n = makeNode(DropPLangStmt); + n->plname = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = true; + (yyval.node) = (Node *)n; + } + break; + + case 416: +#line 2632 "gram.y" + {} + break; + + case 417: +#line 2633 "gram.y" + {} + break; + + case 418: +#line 2644 "gram.y" + { + CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt); + n->tablespacename = (yyvsp[-3].str); + n->owner = (yyvsp[-2].str); + n->location = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 419: +#line 2653 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 420: +#line 2654 "gram.y" + { (yyval.str) = NULL; } + break; + + case 421: +#line 2668 "gram.y" + { + DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); + n->tablespacename = (yyvsp[0].str); + n->missing_ok = false; + (yyval.node) = (Node *) n; + } + break; + + case 422: +#line 2675 "gram.y" + { + DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); + n->tablespacename = (yyvsp[0].str); + n->missing_ok = true; + (yyval.node) = (Node *) n; + } + break; + + case 423: +#line 2695 "gram.y" + { + CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->trigname = (yyvsp[-11].str); + n->relation = (yyvsp[-7].range); + n->funcname = (yyvsp[-3].list); + n->args = (yyvsp[-1].list); + n->before = (yyvsp[-10].boolean); + n->row = (yyvsp[-6].boolean); + memcpy(n->actions, (yyvsp[-9].str), 4); + n->isconstraint = FALSE; + n->deferrable = FALSE; + n->initdeferred = FALSE; + n->constrrel = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 424: +#line 2715 "gram.y" + { + CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->trigname = (yyvsp[-15].str); + n->relation = (yyvsp[-11].range); + n->funcname = (yyvsp[-3].list); + n->args = (yyvsp[-1].list); + n->before = FALSE; + n->row = TRUE; + memcpy(n->actions, (yyvsp[-13].str), 4); + n->isconstraint = TRUE; + n->deferrable = ((yyvsp[-9].ival) & 1) != 0; + n->initdeferred = ((yyvsp[-9].ival) & 2) != 0; + + n->constrrel = (yyvsp[-10].range); + (yyval.node) = (Node *)n; + } + break; + + case 425: +#line 2734 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 426: +#line 2735 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 427: +#line 2740 "gram.y" + { + char *e = palloc(4); + e[0] = (yyvsp[0].chr); e[1] = '\0'; + (yyval.str) = e; + } + break; + + case 428: +#line 2746 "gram.y" + { + char *e = palloc(4); + e[0] = (yyvsp[-2].chr); e[1] = (yyvsp[0].chr); e[2] = '\0'; + (yyval.str) = e; + } + break; + + case 429: +#line 2752 "gram.y" + { + char *e = palloc(4); + e[0] = (yyvsp[-4].chr); e[1] = (yyvsp[-2].chr); e[2] = (yyvsp[0].chr); e[3] = '\0'; + (yyval.str) = e; + } + break; + + case 430: +#line 2760 "gram.y" + { (yyval.chr) = 'i'; } + break; + + case 431: +#line 2761 "gram.y" + { (yyval.chr) = 'd'; } + break; + + case 432: +#line 2762 "gram.y" + { (yyval.chr) = 'u'; } + break; + + case 433: +#line 2767 "gram.y" + { + (yyval.boolean) = (yyvsp[0].boolean); + } + break; + + case 434: +#line 2771 "gram.y" + { + /* + * If ROW/STATEMENT not specified, default to + * STATEMENT, per SQL + */ + (yyval.boolean) = FALSE; + } + break; + + case 435: +#line 2781 "gram.y" + {} + break; + + case 436: +#line 2782 "gram.y" + {} + break; + + case 437: +#line 2786 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 438: +#line 2787 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 439: +#line 2791 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].value)); } + break; + + case 440: +#line 2792 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].value)); } + break; + + case 441: +#line 2793 "gram.y" + { (yyval.list) = NIL; } + break; + + case 442: +#line 2798 "gram.y" + { + char buf[64]; + snprintf(buf, sizeof(buf), "%d", (yyvsp[0].ival)); + (yyval.value) = makeString(pstrdup(buf)); + } + break; + + case 443: +#line 2803 "gram.y" + { (yyval.value) = makeString((yyvsp[0].str)); } + break; + + case 444: +#line 2804 "gram.y" + { (yyval.value) = makeString((yyvsp[0].str)); } + break; + + case 445: +#line 2805 "gram.y" + { (yyval.value) = makeString((yyvsp[0].str)); } + break; + + case 446: +#line 2806 "gram.y" + { (yyval.value) = makeString((yyvsp[0].str)); } + break; + + case 447: +#line 2807 "gram.y" + { (yyval.value) = makeString((yyvsp[0].str)); } + break; + + case 448: +#line 2811 "gram.y" + { (yyval.range) = (yyvsp[0].range); } + break; + + case 449: +#line 2812 "gram.y" + { (yyval.range) = NULL; } + break; + + case 450: +#line 2817 "gram.y" + { (yyval.ival) = (yyvsp[0].ival); } + break; + + case 451: +#line 2819 "gram.y" + { + if ((yyvsp[-1].ival) == 0 && (yyvsp[0].ival) != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("constraint declared INITIALLY DEFERRED must be DEFERRABLE"))); + (yyval.ival) = (yyvsp[-1].ival) | (yyvsp[0].ival); + } + break; + + case 452: +#line 2827 "gram.y" + { + if ((yyvsp[0].ival) != 0) + (yyval.ival) = 3; + else + (yyval.ival) = 0; + } + break; + + case 453: +#line 2834 "gram.y" + { + if ((yyvsp[0].ival) == 0 && (yyvsp[-1].ival) != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("constraint declared INITIALLY DEFERRED must be DEFERRABLE"))); + (yyval.ival) = (yyvsp[-1].ival) | (yyvsp[0].ival); + } + break; + + case 454: +#line 2842 "gram.y" + { (yyval.ival) = 0; } + break; + + case 455: +#line 2846 "gram.y" + { (yyval.ival) = 0; } + break; + + case 456: +#line 2847 "gram.y" + { (yyval.ival) = 1; } + break; + + case 457: +#line 2851 "gram.y" + { (yyval.ival) = 0; } + break; + + case 458: +#line 2852 "gram.y" + { (yyval.ival) = 2; } + break; + + case 459: +#line 2858 "gram.y" + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = (yyvsp[-1].range); + n->property = (yyvsp[-3].str); + n->behavior = (yyvsp[0].dbehavior); + n->removeType = OBJECT_TRIGGER; + n->missing_ok = false; + (yyval.node) = (Node *) n; + } + break; + + case 460: +#line 2868 "gram.y" + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = (yyvsp[-1].range); + n->property = (yyvsp[-3].str); + n->behavior = (yyvsp[0].dbehavior); + n->removeType = OBJECT_TRIGGER; + n->missing_ok = true; + (yyval.node) = (Node *) n; + } + break; + + case 461: +#line 2891 "gram.y" + { + CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->trigname = (yyvsp[-5].str); + n->args = list_make1((yyvsp[-2].node)); + n->isconstraint = TRUE; + n->deferrable = ((yyvsp[0].ival) & 1) != 0; + n->initdeferred = ((yyvsp[0].ival) & 2) != 0; + + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("CREATE ASSERTION is not yet implemented"))); + + (yyval.node) = (Node *)n; + } + break; + + case 462: +#line 2909 "gram.y" + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = NULL; + n->property = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->removeType = OBJECT_TRIGGER; /* XXX */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("DROP ASSERTION is not yet implemented"))); + (yyval.node) = (Node *) n; + } + break; + + case 463: +#line 2932 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_AGGREGATE; + n->oldstyle = false; + n->defnames = (yyvsp[-2].list); + n->args = (yyvsp[-1].list); + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 464: +#line 2942 "gram.y" + { + /* old-style (pre-8.2) syntax for CREATE AGGREGATE */ + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_AGGREGATE; + n->oldstyle = true; + n->defnames = (yyvsp[-1].list); + n->args = NIL; + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 465: +#line 2953 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_OPERATOR; + n->oldstyle = false; + n->defnames = (yyvsp[-1].list); + n->args = NIL; + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 466: +#line 2963 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TYPE; + n->oldstyle = false; + n->defnames = (yyvsp[-1].list); + n->args = NIL; + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 467: +#line 2973 "gram.y" + { + /* Shell type (identified by lack of definition) */ + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TYPE; + n->oldstyle = false; + n->defnames = (yyvsp[0].list); + n->args = NIL; + n->definition = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 468: +#line 2984 "gram.y" + { + CompositeTypeStmt *n = makeNode(CompositeTypeStmt); + RangeVar *r = makeNode(RangeVar); + + /* can't use qualified_name, sigh */ + switch (list_length((yyvsp[-4].list))) + { + case 1: + r->catalogname = NULL; + r->schemaname = NULL; + r->relname = strVal(linitial((yyvsp[-4].list))); + break; + case 2: + r->catalogname = NULL; + r->schemaname = strVal(linitial((yyvsp[-4].list))); + r->relname = strVal(lsecond((yyvsp[-4].list))); + break; + case 3: + r->catalogname = strVal(linitial((yyvsp[-4].list))); + r->schemaname = strVal(lsecond((yyvsp[-4].list))); + r->relname = strVal(lthird((yyvsp[-4].list))); + break; + default: + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("improper qualified name (too many dotted names): %s", + NameListToString((yyvsp[-4].list))))); + break; + } + n->typevar = r; + n->coldeflist = (yyvsp[-1].list); + (yyval.node) = (Node *)n; + } + break; + + case 469: +#line 3018 "gram.y" + { + CreateEnumStmt *n = makeNode(CreateEnumStmt); + n->typename = (yyvsp[-5].list); + n->vals = (yyvsp[-1].list); + (yyval.node) = (Node *)n; + } + break; + + case 470: +#line 3025 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSPARSER; + n->args = NIL; + n->defnames = (yyvsp[-1].list); + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 471: +#line 3034 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSDICTIONARY; + n->args = NIL; + n->defnames = (yyvsp[-1].list); + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 472: +#line 3043 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSTEMPLATE; + n->args = NIL; + n->defnames = (yyvsp[-1].list); + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 473: +#line 3052 "gram.y" + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSCONFIGURATION; + n->args = NIL; + n->defnames = (yyvsp[-1].list); + n->definition = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 474: +#line 3062 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 475: +#line 3065 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].defelt)); } + break; + + case 476: +#line 3066 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].defelt)); } + break; + + case 477: +#line 3070 "gram.y" + { + (yyval.defelt) = makeDefElem((yyvsp[-2].str), (Node *)(yyvsp[0].node)); + } + break; + + case 478: +#line 3074 "gram.y" + { + (yyval.defelt) = makeDefElem((yyvsp[0].str), NULL); + } + break; + + case 479: +#line 3080 "gram.y" + { (yyval.node) = (Node *)(yyvsp[0].typnam); } + break; + + case 480: +#line 3081 "gram.y" + { (yyval.node) = (Node *)makeString(pstrdup((yyvsp[0].keyword))); } + break; + + case 481: +#line 3082 "gram.y" + { (yyval.node) = (Node *)(yyvsp[0].list); } + break; + + case 482: +#line 3083 "gram.y" + { (yyval.node) = (Node *)(yyvsp[0].value); } + break; + + case 483: +#line 3084 "gram.y" + { (yyval.node) = (Node *)makeString((yyvsp[0].str)); } + break; + + case 484: +#line 3087 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 485: +#line 3088 "gram.y" + { (yyval.list) = NIL; } + break; + + case 486: +#line 3091 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 487: +#line 3094 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].defelt)); } + break; + + case 488: +#line 3095 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].defelt)); } + break; + + case 489: +#line 3099 "gram.y" + { + (yyval.defelt) = makeDefElem((yyvsp[-2].str), (Node *)(yyvsp[0].node)); + } + break; + + case 490: +#line 3105 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 491: +#line 3107 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), makeString((yyvsp[0].str))); } + break; + + case 492: +#line 3125 "gram.y" + { + CreateOpClassStmt *n = makeNode(CreateOpClassStmt); + n->opclassname = (yyvsp[-9].list); + n->isDefault = (yyvsp[-8].boolean); + n->datatype = (yyvsp[-5].typnam); + n->amname = (yyvsp[-3].str); + n->opfamilyname = (yyvsp[-2].list); + n->items = (yyvsp[0].list); + (yyval.node) = (Node *) n; + } + break; + + case 493: +#line 3138 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 494: +#line 3139 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 495: +#line 3144 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; + n->name = (yyvsp[-1].list); + n->args = NIL; + n->number = (yyvsp[-2].ival); + n->recheck = (yyvsp[0].boolean); + (yyval.node) = (Node *) n; + } + break; + + case 496: +#line 3154 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; + n->name = (yyvsp[-4].list); + n->args = (yyvsp[-2].list); + n->number = (yyvsp[-5].ival); + n->recheck = (yyvsp[0].boolean); + (yyval.node) = (Node *) n; + } + break; + + case 497: +#line 3164 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; + n->name = (yyvsp[-1].list); + n->args = extractArgTypes((yyvsp[0].list)); + n->number = (yyvsp[-2].ival); + (yyval.node) = (Node *) n; + } + break; + + case 498: +#line 3173 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; + n->name = (yyvsp[-1].list); + n->args = extractArgTypes((yyvsp[0].list)); + n->number = (yyvsp[-5].ival); + n->class_args = (yyvsp[-3].list); + (yyval.node) = (Node *) n; + } + break; + + case 499: +#line 3183 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_STORAGETYPE; + n->storedtype = (yyvsp[0].typnam); + (yyval.node) = (Node *) n; + } + break; + + case 500: +#line 3191 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 501: +#line 3192 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 502: +#line 3195 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 503: +#line 3196 "gram.y" + { (yyval.list) = NIL; } + break; + + case 504: +#line 3199 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 505: +#line 3200 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 506: +#line 3206 "gram.y" + { + CreateOpFamilyStmt *n = makeNode(CreateOpFamilyStmt); + n->opfamilyname = (yyvsp[-2].list); + n->amname = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 507: +#line 3216 "gram.y" + { + AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt); + n->opfamilyname = (yyvsp[-4].list); + n->amname = (yyvsp[-2].str); + n->isDrop = false; + n->items = (yyvsp[0].list); + (yyval.node) = (Node *) n; + } + break; + + case 508: +#line 3225 "gram.y" + { + AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt); + n->opfamilyname = (yyvsp[-4].list); + n->amname = (yyvsp[-2].str); + n->isDrop = true; + n->items = (yyvsp[0].list); + (yyval.node) = (Node *) n; + } + break; + + case 509: +#line 3236 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 510: +#line 3237 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 511: +#line 3242 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; + n->number = (yyvsp[-3].ival); + n->args = (yyvsp[-1].list); + (yyval.node) = (Node *) n; + } + break; + + case 512: +#line 3250 "gram.y" + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; + n->number = (yyvsp[-3].ival); + n->args = (yyvsp[-1].list); + (yyval.node) = (Node *) n; + } + break; + + case 513: +#line 3262 "gram.y" + { + RemoveOpClassStmt *n = makeNode(RemoveOpClassStmt); + n->opclassname = (yyvsp[-3].list); + n->amname = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = false; + (yyval.node) = (Node *) n; + } + break; + + case 514: +#line 3271 "gram.y" + { + RemoveOpClassStmt *n = makeNode(RemoveOpClassStmt); + n->opclassname = (yyvsp[-3].list); + n->amname = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = true; + (yyval.node) = (Node *) n; + } + break; + + case 515: +#line 3283 "gram.y" + { + RemoveOpFamilyStmt *n = makeNode(RemoveOpFamilyStmt); + n->opfamilyname = (yyvsp[-3].list); + n->amname = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = false; + (yyval.node) = (Node *) n; + } + break; + + case 516: +#line 3292 "gram.y" + { + RemoveOpFamilyStmt *n = makeNode(RemoveOpFamilyStmt); + n->opfamilyname = (yyvsp[-3].list); + n->amname = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = true; + (yyval.node) = (Node *) n; + } + break; + + case 517: +#line 3313 "gram.y" + { + DropOwnedStmt *n = makeNode(DropOwnedStmt); + n->roles = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 518: +#line 3323 "gram.y" + { + ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt); + n->roles = (yyvsp[-2].list); + n->newrole = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 519: +#line 3341 "gram.y" + { + DropStmt *n = makeNode(DropStmt); + n->removeType = (yyvsp[-4].objtype); + n->missing_ok = TRUE; + n->objects = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 520: +#line 3350 "gram.y" + { + DropStmt *n = makeNode(DropStmt); + n->removeType = (yyvsp[-2].objtype); + n->missing_ok = FALSE; + n->objects = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 521: +#line 3361 "gram.y" + { (yyval.objtype) = OBJECT_TABLE; } + break; + + case 522: +#line 3362 "gram.y" + { (yyval.objtype) = OBJECT_SEQUENCE; } + break; + + case 523: +#line 3363 "gram.y" + { (yyval.objtype) = OBJECT_VIEW; } + break; + + case 524: +#line 3364 "gram.y" + { (yyval.objtype) = OBJECT_INDEX; } + break; + + case 525: +#line 3365 "gram.y" + { (yyval.objtype) = OBJECT_TYPE; } + break; + + case 526: +#line 3366 "gram.y" + { (yyval.objtype) = OBJECT_DOMAIN; } + break; + + case 527: +#line 3367 "gram.y" + { (yyval.objtype) = OBJECT_CONVERSION; } + break; + + case 528: +#line 3368 "gram.y" + { (yyval.objtype) = OBJECT_SCHEMA; } + break; + + case 529: +#line 3369 "gram.y" + { (yyval.objtype) = OBJECT_TSPARSER; } + break; + + case 530: +#line 3370 "gram.y" + { (yyval.objtype) = OBJECT_TSDICTIONARY; } + break; + + case 531: +#line 3371 "gram.y" + { (yyval.objtype) = OBJECT_TSTEMPLATE; } + break; + + case 532: +#line 3372 "gram.y" + { (yyval.objtype) = OBJECT_TSCONFIGURATION; } + break; + + case 533: +#line 3376 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].list)); } + break; + + case 534: +#line 3377 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].list)); } + break; + + case 535: +#line 3380 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 536: +#line 3381 "gram.y" + { (yyval.list) = lcons(makeString((yyvsp[-1].str)), (yyvsp[0].list)); } + break; + + case 537: +#line 3385 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 538: +#line 3387 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), makeString((yyvsp[0].str))); } + break; + + case 539: +#line 3400 "gram.y" + { + TruncateStmt *n = makeNode(TruncateStmt); + n->relations = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 540: +#line 3431 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = (yyvsp[-3].objtype); + n->objname = (yyvsp[-2].list); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 541: +#line 3440 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_AGGREGATE; + n->objname = (yyvsp[-3].list); + n->objargs = (yyvsp[-2].list); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 542: +#line 3449 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_FUNCTION; + n->objname = (yyvsp[-3].list); + n->objargs = extractArgTypes((yyvsp[-2].list)); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 543: +#line 3459 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPERATOR; + n->objname = (yyvsp[-5].list); + n->objargs = (yyvsp[-3].list); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 544: +#line 3468 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_CONSTRAINT; + n->objname = lappend((yyvsp[-2].list), makeString((yyvsp[-4].str))); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 545: +#line 3477 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_RULE; + n->objname = lappend((yyvsp[-2].list), makeString((yyvsp[-4].str))); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 546: +#line 3486 "gram.y" + { + /* Obsolete syntax supported for awhile for compatibility */ + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_RULE; + n->objname = list_make1(makeString((yyvsp[-2].str))); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 547: +#line 3496 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TRIGGER; + n->objname = lappend((yyvsp[-2].list), makeString((yyvsp[-4].str))); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 548: +#line 3505 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPCLASS; + n->objname = (yyvsp[-4].list); + n->objargs = list_make1(makeString((yyvsp[-2].str))); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 549: +#line 3514 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPFAMILY; + n->objname = (yyvsp[-4].list); + n->objargs = list_make1(makeString((yyvsp[-2].str))); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 550: +#line 3523 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_LARGEOBJECT; + n->objname = list_make1((yyvsp[-2].value)); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 551: +#line 3532 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_CAST; + n->objname = list_make1((yyvsp[-5].typnam)); + n->objargs = list_make1((yyvsp[-3].typnam)); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 552: +#line 3541 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_LANGUAGE; + n->objname = (yyvsp[-2].list); + n->objargs = NIL; + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 553: +#line 3550 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSPARSER; + n->objname = (yyvsp[-2].list); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 554: +#line 3558 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSDICTIONARY; + n->objname = (yyvsp[-2].list); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 555: +#line 3566 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSTEMPLATE; + n->objname = (yyvsp[-2].list); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 556: +#line 3574 "gram.y" + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSCONFIGURATION; + n->objname = (yyvsp[-2].list); + n->comment = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 557: +#line 3584 "gram.y" + { (yyval.objtype) = OBJECT_COLUMN; } + break; + + case 558: +#line 3585 "gram.y" + { (yyval.objtype) = OBJECT_DATABASE; } + break; + + case 559: +#line 3586 "gram.y" + { (yyval.objtype) = OBJECT_SCHEMA; } + break; + + case 560: +#line 3587 "gram.y" + { (yyval.objtype) = OBJECT_INDEX; } + break; + + case 561: +#line 3588 "gram.y" + { (yyval.objtype) = OBJECT_SEQUENCE; } + break; + + case 562: +#line 3589 "gram.y" + { (yyval.objtype) = OBJECT_TABLE; } + break; + + case 563: +#line 3590 "gram.y" + { (yyval.objtype) = OBJECT_TYPE; } + break; + + case 564: +#line 3591 "gram.y" + { (yyval.objtype) = OBJECT_TYPE; } + break; + + case 565: +#line 3592 "gram.y" + { (yyval.objtype) = OBJECT_VIEW; } + break; + + case 566: +#line 3593 "gram.y" + { (yyval.objtype) = OBJECT_CONVERSION; } + break; + + case 567: +#line 3594 "gram.y" + { (yyval.objtype) = OBJECT_TABLESPACE; } + break; + + case 568: +#line 3595 "gram.y" + { (yyval.objtype) = OBJECT_ROLE; } + break; + + case 569: +#line 3599 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 570: +#line 3600 "gram.y" + { (yyval.str) = NULL; } + break; + + case 571: +#line 3611 "gram.y" + { + FetchStmt *n = (FetchStmt *) (yyvsp[-2].node); + n->portalname = (yyvsp[0].str); + n->ismove = FALSE; + (yyval.node) = (Node *)n; + } + break; + + case 572: +#line 3618 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + n->portalname = (yyvsp[0].str); + n->ismove = FALSE; + (yyval.node) = (Node *)n; + } + break; + + case 573: +#line 3627 "gram.y" + { + FetchStmt *n = (FetchStmt *) (yyvsp[-2].node); + n->portalname = (yyvsp[0].str); + n->ismove = TRUE; + (yyval.node) = (Node *)n; + } + break; + + case 574: +#line 3634 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + n->portalname = (yyvsp[0].str); + n->ismove = TRUE; + (yyval.node) = (Node *)n; + } + break; + + case 575: +#line 3646 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + (yyval.node) = (Node *)n; + } + break; + + case 576: +#line 3653 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + (yyval.node) = (Node *)n; + } + break; + + case 577: +#line 3660 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = 1; + (yyval.node) = (Node *)n; + } + break; + + case 578: +#line 3667 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_ABSOLUTE; + n->howMany = 1; + (yyval.node) = (Node *)n; + } + break; + + case 579: +#line 3674 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_ABSOLUTE; + n->howMany = -1; + (yyval.node) = (Node *)n; + } + break; + + case 580: +#line 3681 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_ABSOLUTE; + n->howMany = (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 581: +#line 3688 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_RELATIVE; + n->howMany = (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 582: +#line 3695 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 583: +#line 3702 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = FETCH_ALL; + (yyval.node) = (Node *)n; + } + break; + + case 584: +#line 3709 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + (yyval.node) = (Node *)n; + } + break; + + case 585: +#line 3716 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 586: +#line 3723 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = FETCH_ALL; + (yyval.node) = (Node *)n; + } + break; + + case 587: +#line 3730 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = 1; + (yyval.node) = (Node *)n; + } + break; + + case 588: +#line 3737 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 589: +#line 3744 "gram.y" + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = FETCH_ALL; + (yyval.node) = (Node *)n; + } + break; + + case 590: +#line 3752 "gram.y" + {} + break; + + case 591: +#line 3753 "gram.y" + {} + break; + + case 592: +#line 3765 "gram.y" + { + GrantStmt *n = makeNode(GrantStmt); + n->is_grant = true; + n->privileges = (yyvsp[-5].list); + n->objtype = ((yyvsp[-3].privtarget))->objtype; + n->objects = ((yyvsp[-3].privtarget))->objs; + n->grantees = (yyvsp[-1].list); + n->grant_option = (yyvsp[0].boolean); + (yyval.node) = (Node*)n; + } + break; + + case 593: +#line 3780 "gram.y" + { + GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; + n->grant_option = false; + n->privileges = (yyvsp[-5].list); + n->objtype = ((yyvsp[-3].privtarget))->objtype; + n->objects = ((yyvsp[-3].privtarget))->objs; + n->grantees = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 594: +#line 3793 "gram.y" + { + GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; + n->grant_option = true; + n->privileges = (yyvsp[-5].list); + n->objtype = ((yyvsp[-3].privtarget))->objtype; + n->objects = ((yyvsp[-3].privtarget))->objs; + n->grantees = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 595: +#line 3818 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 596: +#line 3820 "gram.y" + { (yyval.list) = NIL; } + break; + + case 597: +#line 3822 "gram.y" + { (yyval.list) = NIL; } + break; + + case 598: +#line 3826 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 599: +#line 3828 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), makeString((yyvsp[0].str))); } + break; + + case 600: +#line 3831 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 601: +#line 3832 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 602: +#line 3833 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 603: +#line 3834 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 604: +#line 3843 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_RELATION; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 605: +#line 3850 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_RELATION; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 606: +#line 3857 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_SEQUENCE; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 607: +#line 3864 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_FUNCTION; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 608: +#line 3871 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_DATABASE; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 609: +#line 3878 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_LANGUAGE; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 610: +#line 3885 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_NAMESPACE; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 611: +#line 3892 "gram.y" + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_TABLESPACE; + n->objs = (yyvsp[0].list); + (yyval.privtarget) = n; + } + break; + + case 612: +#line 3902 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 613: +#line 3903 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 614: +#line 3907 "gram.y" + { + PrivGrantee *n = makeNode(PrivGrantee); + /* This hack lets us avoid reserving PUBLIC as a keyword*/ + if (strcmp((yyvsp[0].str), "public") == 0) + n->rolname = NULL; + else + n->rolname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 615: +#line 3917 "gram.y" + { + PrivGrantee *n = makeNode(PrivGrantee); + /* Treat GROUP PUBLIC as a synonym for PUBLIC */ + if (strcmp((yyvsp[0].str), "public") == 0) + n->rolname = NULL; + else + n->rolname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 616: +#line 3930 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 617: +#line 3931 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 618: +#line 3935 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].funwithargs)); } + break; + + case 619: +#line 3937 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].funwithargs)); } + break; + + case 620: +#line 3942 "gram.y" + { + FuncWithArgs *n = makeNode(FuncWithArgs); + n->funcname = (yyvsp[-1].list); + n->funcargs = extractArgTypes((yyvsp[0].list)); + (yyval.funwithargs) = n; + } + break; + + case 621: +#line 3958 "gram.y" + { + GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = true; + n->granted_roles = (yyvsp[-4].list); + n->grantee_roles = (yyvsp[-2].list); + n->admin_opt = (yyvsp[-1].boolean); + n->grantor = (yyvsp[0].str); + (yyval.node) = (Node*)n; + } + break; + + case 622: +#line 3971 "gram.y" + { + GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = false; + n->admin_opt = false; + n->granted_roles = (yyvsp[-4].list); + n->grantee_roles = (yyvsp[-2].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node*)n; + } + break; + + case 623: +#line 3981 "gram.y" + { + GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = false; + n->admin_opt = true; + n->granted_roles = (yyvsp[-4].list); + n->grantee_roles = (yyvsp[-2].list); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node*)n; + } + break; + + case 624: +#line 3992 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 625: +#line 3993 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 626: +#line 3996 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 627: +#line 3997 "gram.y" + { (yyval.str) = NULL; } + break; + + case 628: +#line 4015 "gram.y" + { + IndexStmt *n = makeNode(IndexStmt); + n->unique = (yyvsp[-11].boolean); + n->concurrent = false; + n->idxname = (yyvsp[-9].str); + n->relation = (yyvsp[-7].range); + n->accessMethod = (yyvsp[-6].str); + n->indexParams = (yyvsp[-4].list); + n->options = (yyvsp[-2].list); + n->tableSpace = (yyvsp[-1].str); + n->whereClause = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 629: +#line 4031 "gram.y" + { + IndexStmt *n = makeNode(IndexStmt); + n->unique = (yyvsp[-12].boolean); + n->concurrent = true; + n->idxname = (yyvsp[-9].str); + n->relation = (yyvsp[-7].range); + n->accessMethod = (yyvsp[-6].str); + n->indexParams = (yyvsp[-4].list); + n->options = (yyvsp[-2].list); + n->tableSpace = (yyvsp[-1].str); + n->whereClause = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 630: +#line 4047 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 631: +#line 4048 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 632: +#line 4052 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 633: +#line 4053 "gram.y" + { (yyval.str) = DEFAULT_INDEX_TYPE; } + break; + + case 634: +#line 4056 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].ielem)); } + break; + + case 635: +#line 4057 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].ielem)); } + break; + + case 636: +#line 4066 "gram.y" + { + (yyval.ielem) = makeNode(IndexElem); + (yyval.ielem)->name = (yyvsp[-3].str); + (yyval.ielem)->expr = NULL; + (yyval.ielem)->opclass = (yyvsp[-2].list); + (yyval.ielem)->ordering = (yyvsp[-1].ival); + (yyval.ielem)->nulls_ordering = (yyvsp[0].ival); + } + break; + + case 637: +#line 4075 "gram.y" + { + (yyval.ielem) = makeNode(IndexElem); + (yyval.ielem)->name = NULL; + (yyval.ielem)->expr = (yyvsp[-3].node); + (yyval.ielem)->opclass = (yyvsp[-2].list); + (yyval.ielem)->ordering = (yyvsp[-1].ival); + (yyval.ielem)->nulls_ordering = (yyvsp[0].ival); + } + break; + + case 638: +#line 4084 "gram.y" + { + (yyval.ielem) = makeNode(IndexElem); + (yyval.ielem)->name = NULL; + (yyval.ielem)->expr = (yyvsp[-4].node); + (yyval.ielem)->opclass = (yyvsp[-2].list); + (yyval.ielem)->ordering = (yyvsp[-1].ival); + (yyval.ielem)->nulls_ordering = (yyvsp[0].ival); + } + break; + + case 639: +#line 4094 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 640: +#line 4095 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 641: +#line 4096 "gram.y" + { (yyval.list) = NIL; } + break; + + case 642: +#line 4099 "gram.y" + { (yyval.ival) = SORTBY_ASC; } + break; + + case 643: +#line 4100 "gram.y" + { (yyval.ival) = SORTBY_DESC; } + break; + + case 644: +#line 4101 "gram.y" + { (yyval.ival) = SORTBY_DEFAULT; } + break; + + case 645: +#line 4104 "gram.y" + { (yyval.ival) = SORTBY_NULLS_FIRST; } + break; + + case 646: +#line 4105 "gram.y" + { (yyval.ival) = SORTBY_NULLS_LAST; } + break; + + case 647: +#line 4106 "gram.y" + { (yyval.ival) = SORTBY_NULLS_DEFAULT; } + break; + + case 648: +#line 4124 "gram.y" + { + CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->replace = (yyvsp[-7].boolean); + n->funcname = (yyvsp[-5].list); + n->parameters = (yyvsp[-4].list); + n->returnType = (yyvsp[-2].typnam); + n->options = (yyvsp[-1].list); + n->withClause = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 649: +#line 4136 "gram.y" + { + CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->replace = (yyvsp[-5].boolean); + n->funcname = (yyvsp[-3].list); + n->parameters = (yyvsp[-2].list); + n->returnType = NULL; + n->options = (yyvsp[-1].list); + n->withClause = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 650: +#line 4149 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 651: +#line 4150 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 652: +#line 4153 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 653: +#line 4154 "gram.y" + { (yyval.list) = NIL; } + break; + + case 654: +#line 4158 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].fun_param)); } + break; + + case 655: +#line 4159 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].fun_param)); } + break; + + case 656: +#line 4174 "gram.y" + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = (yyvsp[-1].str); + n->argType = (yyvsp[0].typnam); + n->mode = (yyvsp[-2].fun_param_mode); + (yyval.fun_param) = n; + } + break; + + case 657: +#line 4182 "gram.y" + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = (yyvsp[-2].str); + n->argType = (yyvsp[0].typnam); + n->mode = (yyvsp[-1].fun_param_mode); + (yyval.fun_param) = n; + } + break; + + case 658: +#line 4190 "gram.y" + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = (yyvsp[-1].str); + n->argType = (yyvsp[0].typnam); + n->mode = FUNC_PARAM_IN; + (yyval.fun_param) = n; + } + break; + + case 659: +#line 4198 "gram.y" + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = NULL; + n->argType = (yyvsp[0].typnam); + n->mode = (yyvsp[-1].fun_param_mode); + (yyval.fun_param) = n; + } + break; + + case 660: +#line 4206 "gram.y" + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = NULL; + n->argType = (yyvsp[0].typnam); + n->mode = FUNC_PARAM_IN; + (yyval.fun_param) = n; + } + break; + + case 661: +#line 4216 "gram.y" + { (yyval.fun_param_mode) = FUNC_PARAM_IN; } + break; + + case 662: +#line 4217 "gram.y" + { (yyval.fun_param_mode) = FUNC_PARAM_OUT; } + break; + + case 663: +#line 4218 "gram.y" + { (yyval.fun_param_mode) = FUNC_PARAM_INOUT; } + break; + + case 664: +#line 4219 "gram.y" + { (yyval.fun_param_mode) = FUNC_PARAM_INOUT; } + break; + + case 666: +#line 4230 "gram.y" + { + /* We can catch over-specified results here if we want to, + * but for now better to silently swallow typmod, etc. + * - thomas 2000-03-22 + */ + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 667: +#line 4244 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 668: +#line 4246 "gram.y" + { + (yyval.typnam) = makeTypeNameFromNameList(lcons(makeString((yyvsp[-3].str)), (yyvsp[-2].list))); + (yyval.typnam)->pct_type = true; + (yyval.typnam)->location = (yylsp[-3]); + } + break; + + case 669: +#line 4252 "gram.y" + { + (yyval.typnam) = makeTypeNameFromNameList(lcons(makeString((yyvsp[-3].str)), (yyvsp[-2].list))); + (yyval.typnam)->pct_type = true; + (yyval.typnam)->setof = TRUE; + (yyval.typnam)->location = (yylsp[-3]); + } + break; + + case 670: +#line 4263 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].defelt)); } + break; + + case 671: +#line 4264 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 672: +#line 4272 "gram.y" + { + (yyval.defelt) = makeDefElem("strict", (Node *)makeInteger(FALSE)); + } + break; + + case 673: +#line 4276 "gram.y" + { + (yyval.defelt) = makeDefElem("strict", (Node *)makeInteger(TRUE)); + } + break; + + case 674: +#line 4280 "gram.y" + { + (yyval.defelt) = makeDefElem("strict", (Node *)makeInteger(TRUE)); + } + break; + + case 675: +#line 4284 "gram.y" + { + (yyval.defelt) = makeDefElem("volatility", (Node *)makeString("immutable")); + } + break; + + case 676: +#line 4288 "gram.y" + { + (yyval.defelt) = makeDefElem("volatility", (Node *)makeString("stable")); + } + break; + + case 677: +#line 4292 "gram.y" + { + (yyval.defelt) = makeDefElem("volatility", (Node *)makeString("volatile")); + } + break; + + case 678: +#line 4296 "gram.y" + { + (yyval.defelt) = makeDefElem("security", (Node *)makeInteger(TRUE)); + } + break; + + case 679: +#line 4300 "gram.y" + { + (yyval.defelt) = makeDefElem("security", (Node *)makeInteger(FALSE)); + } + break; + + case 680: +#line 4304 "gram.y" + { + (yyval.defelt) = makeDefElem("security", (Node *)makeInteger(TRUE)); + } + break; + + case 681: +#line 4308 "gram.y" + { + (yyval.defelt) = makeDefElem("security", (Node *)makeInteger(FALSE)); + } + break; + + case 682: +#line 4312 "gram.y" + { + (yyval.defelt) = makeDefElem("cost", (Node *)(yyvsp[0].value)); + } + break; + + case 683: +#line 4316 "gram.y" + { + (yyval.defelt) = makeDefElem("rows", (Node *)(yyvsp[0].value)); + } + break; + + case 684: +#line 4320 "gram.y" + { + /* we abuse the normal content of a DefElem here */ + (yyval.defelt) = makeDefElem("set", (Node *)(yyvsp[0].vsetstmt)); + } + break; + + case 685: +#line 4328 "gram.y" + { + (yyval.defelt) = makeDefElem("as", (Node *)(yyvsp[0].list)); + } + break; + + case 686: +#line 4332 "gram.y" + { + (yyval.defelt) = makeDefElem("language", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 687: +#line 4336 "gram.y" + { + (yyval.defelt) = (yyvsp[0].defelt); + } + break; + + case 688: +#line 4341 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 689: +#line 4343 "gram.y" + { + (yyval.list) = list_make2(makeString((yyvsp[-2].str)), makeString((yyvsp[0].str))); + } + break; + + case 690: +#line 4349 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 691: +#line 4350 "gram.y" + { (yyval.list) = NIL; } + break; + + case 692: +#line 4363 "gram.y" + { + AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->func = (yyvsp[-2].funwithargs); + n->actions = (yyvsp[-1].list); + (yyval.node) = (Node *) n; + } + break; + + case 693: +#line 4373 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].defelt)); } + break; + + case 694: +#line 4374 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 697: +#line 4396 "gram.y" + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_FUNCTION; + n->name = (yyvsp[-2].list); + n->args = extractArgTypes((yyvsp[-1].list)); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = false; + (yyval.node) = (Node *)n; + } + break; + + case 698: +#line 4406 "gram.y" + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_FUNCTION; + n->name = (yyvsp[-2].list); + n->args = extractArgTypes((yyvsp[-1].list)); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = true; + (yyval.node) = (Node *)n; + } + break; + + case 699: +#line 4419 "gram.y" + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_AGGREGATE; + n->name = (yyvsp[-2].list); + n->args = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = false; + (yyval.node) = (Node *)n; + } + break; + + case 700: +#line 4429 "gram.y" + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_AGGREGATE; + n->name = (yyvsp[-2].list); + n->args = (yyvsp[-1].list); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = true; + (yyval.node) = (Node *)n; + } + break; + + case 701: +#line 4442 "gram.y" + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_OPERATOR; + n->name = (yyvsp[-4].list); + n->args = (yyvsp[-2].list); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = false; + (yyval.node) = (Node *)n; + } + break; + + case 702: +#line 4452 "gram.y" + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_OPERATOR; + n->name = (yyvsp[-4].list); + n->args = (yyvsp[-2].list); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = true; + (yyval.node) = (Node *)n; + } + break; + + case 703: +#line 4465 "gram.y" + { + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("missing argument"), + errhint("Use NONE to denote the missing argument of a unary operator."))); + } + break; + + case 704: +#line 4472 "gram.y" + { (yyval.list) = list_make2((yyvsp[-2].typnam), (yyvsp[0].typnam)); } + break; + + case 705: +#line 4474 "gram.y" + { (yyval.list) = list_make2(NULL, (yyvsp[0].typnam)); } + break; + + case 706: +#line 4476 "gram.y" + { (yyval.list) = list_make2((yyvsp[-2].typnam), NULL); } + break; + + case 707: +#line 4481 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 708: +#line 4483 "gram.y" + { (yyval.list) = lcons(makeString((yyvsp[-2].str)), (yyvsp[0].list)); } + break; + + case 709: +#line 4495 "gram.y" + { + CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = (yyvsp[-7].typnam); + n->targettype = (yyvsp[-5].typnam); + n->func = (yyvsp[-1].funwithargs); + n->context = (CoercionContext) (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 710: +#line 4505 "gram.y" + { + CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = (yyvsp[-6].typnam); + n->targettype = (yyvsp[-4].typnam); + n->func = NULL; + n->context = (CoercionContext) (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 711: +#line 4515 "gram.y" + { (yyval.ival) = COERCION_IMPLICIT; } + break; + + case 712: +#line 4516 "gram.y" + { (yyval.ival) = COERCION_ASSIGNMENT; } + break; + + case 713: +#line 4517 "gram.y" + { (yyval.ival) = COERCION_EXPLICIT; } + break; + + case 714: +#line 4522 "gram.y" + { + DropCastStmt *n = makeNode(DropCastStmt); + n->sourcetype = (yyvsp[-4].typnam); + n->targettype = (yyvsp[-2].typnam); + n->behavior = (yyvsp[0].dbehavior); + n->missing_ok = (yyvsp[-6].boolean); + (yyval.node) = (Node *)n; + } + break; + + case 715: +#line 4532 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 716: +#line 4533 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 717: +#line 4548 "gram.y" + { + ReindexStmt *n = makeNode(ReindexStmt); + n->kind = (yyvsp[-2].objtype); + n->relation = (yyvsp[-1].range); + n->name = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 718: +#line 4556 "gram.y" + { + ReindexStmt *n = makeNode(ReindexStmt); + n->kind = OBJECT_DATABASE; + n->name = (yyvsp[-1].str); + n->relation = NULL; + n->do_system = true; + n->do_user = false; + (yyval.node) = (Node *)n; + } + break; + + case 719: +#line 4566 "gram.y" + { + ReindexStmt *n = makeNode(ReindexStmt); + n->kind = OBJECT_DATABASE; + n->name = (yyvsp[-1].str); + n->relation = NULL; + n->do_system = true; + n->do_user = true; + (yyval.node) = (Node *)n; + } + break; + + case 720: +#line 4578 "gram.y" + { (yyval.objtype) = OBJECT_INDEX; } + break; + + case 721: +#line 4579 "gram.y" + { (yyval.objtype) = OBJECT_TABLE; } + break; + + case 722: +#line 4582 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 723: +#line 4583 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 724: +#line 4594 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_AGGREGATE; + n->object = (yyvsp[-4].list); + n->objarg = (yyvsp[-3].list); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 725: +#line 4603 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_CONVERSION; + n->object = (yyvsp[-3].list); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 726: +#line 4611 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_DATABASE; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 727: +#line 4619 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FUNCTION; + n->object = (yyvsp[-3].funwithargs)->funcname; + n->objarg = (yyvsp[-3].funwithargs)->funcargs; + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 728: +#line 4628 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 729: +#line 4636 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_LANGUAGE; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 730: +#line 4644 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_OPCLASS; + n->object = (yyvsp[-5].list); + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 731: +#line 4653 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_OPFAMILY; + n->object = (yyvsp[-5].list); + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 732: +#line 4662 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SCHEMA; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 733: +#line 4670 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLE; + n->relation = (yyvsp[-3].range); + n->subname = NULL; + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 734: +#line 4679 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SEQUENCE; + n->relation = (yyvsp[-3].range); + n->subname = NULL; + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 735: +#line 4688 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_VIEW; + n->relation = (yyvsp[-3].range); + n->subname = NULL; + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 736: +#line 4697 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_INDEX; + n->relation = (yyvsp[-3].range); + n->subname = NULL; + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 737: +#line 4706 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; + n->relation = (yyvsp[-5].range); + n->subname = (yyvsp[-2].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 738: +#line 4715 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TRIGGER; + n->relation = (yyvsp[-3].range); + n->subname = (yyvsp[-5].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 739: +#line 4724 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 740: +#line 4732 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 741: +#line 4740 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLESPACE; + n->subname = (yyvsp[-3].str); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 742: +#line 4748 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSPARSER; + n->object = (yyvsp[-3].list); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 743: +#line 4756 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSDICTIONARY; + n->object = (yyvsp[-3].list); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 744: +#line 4764 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSTEMPLATE; + n->object = (yyvsp[-3].list); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 745: +#line 4772 "gram.y" + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSCONFIGURATION; + n->object = (yyvsp[-3].list); + n->newname = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 746: +#line 4781 "gram.y" + { (yyval.ival) = COLUMN; } + break; + + case 747: +#line 4782 "gram.y" + { (yyval.ival) = 0; } + break; + + case 748: +#line 4793 "gram.y" + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_AGGREGATE; + n->object = (yyvsp[-4].list); + n->objarg = (yyvsp[-3].list); + n->newschema = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 749: +#line 4802 "gram.y" + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_DOMAIN; + n->object = (yyvsp[-3].list); + n->newschema = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 750: +#line 4810 "gram.y" + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_FUNCTION; + n->object = (yyvsp[-3].funwithargs)->funcname; + n->objarg = (yyvsp[-3].funwithargs)->funcargs; + n->newschema = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 751: +#line 4819 "gram.y" + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_SEQUENCE; + n->relation = (yyvsp[-3].range); + n->newschema = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 752: +#line 4827 "gram.y" + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TABLE; + n->relation = (yyvsp[-3].range); + n->newschema = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 753: +#line 4835 "gram.y" + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TYPE; + n->object = (yyvsp[-3].list); + n->newschema = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 754: +#line 4851 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_AGGREGATE; + n->object = (yyvsp[-4].list); + n->objarg = (yyvsp[-3].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 755: +#line 4860 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_CONVERSION; + n->object = (yyvsp[-3].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 756: +#line 4868 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_DATABASE; + n->object = list_make1((yyvsp[-3].str)); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 757: +#line 4876 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_DOMAIN; + n->object = (yyvsp[-3].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 758: +#line 4884 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_FUNCTION; + n->object = (yyvsp[-3].funwithargs)->funcname; + n->objarg = (yyvsp[-3].funwithargs)->funcargs; + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 759: +#line 4893 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_LANGUAGE; + n->object = list_make1((yyvsp[-3].str)); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 760: +#line 4901 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPERATOR; + n->object = (yyvsp[-6].list); + n->objarg = (yyvsp[-4].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 761: +#line 4910 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPCLASS; + n->object = (yyvsp[-5].list); + n->addname = (yyvsp[-3].str); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 762: +#line 4919 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPFAMILY; + n->object = (yyvsp[-5].list); + n->addname = (yyvsp[-3].str); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 763: +#line 4928 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_SCHEMA; + n->object = list_make1((yyvsp[-3].str)); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 764: +#line 4936 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TYPE; + n->object = (yyvsp[-3].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 765: +#line 4944 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TABLESPACE; + n->object = list_make1((yyvsp[-3].str)); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 766: +#line 4952 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TSDICTIONARY; + n->object = (yyvsp[-3].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 767: +#line 4960 "gram.y" + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TSCONFIGURATION; + n->object = (yyvsp[-3].list); + n->newowner = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 768: +#line 4977 "gram.y" + { QueryIsRule=TRUE; } + break; + + case 769: +#line 4980 "gram.y" + { + RuleStmt *n = makeNode(RuleStmt); + n->replace = (yyvsp[-12].boolean); + n->relation = (yyvsp[-4].range); + n->rulename = (yyvsp[-10].str); + n->whereClause = (yyvsp[-3].node); + n->event = (yyvsp[-6].ival); + n->instead = (yyvsp[-1].boolean); + n->actions = (yyvsp[0].list); + (yyval.node) = (Node *)n; + QueryIsRule=FALSE; + } + break; + + case 770: +#line 4995 "gram.y" + { (yyval.list) = NIL; } + break; + + case 771: +#line 4996 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 772: +#line 4997 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 773: +#line 5003 "gram.y" + { if ((yyvsp[0].node) != NULL) + (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); + else + (yyval.list) = (yyvsp[-2].list); + } + break; + + case 774: +#line 5009 "gram.y" + { if ((yyvsp[0].node) != NULL) + (yyval.list) = list_make1((yyvsp[0].node)); + else + (yyval.list) = NIL; + } + break; + + case 780: +#line 5025 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 781: +#line 5026 "gram.y" + { (yyval.node) = NULL; } + break; + + case 782: +#line 5029 "gram.y" + { (yyval.ival) = CMD_SELECT; } + break; + + case 783: +#line 5030 "gram.y" + { (yyval.ival) = CMD_UPDATE; } + break; + + case 784: +#line 5031 "gram.y" + { (yyval.ival) = CMD_DELETE; } + break; + + case 785: +#line 5032 "gram.y" + { (yyval.ival) = CMD_INSERT; } + break; + + case 786: +#line 5036 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 787: +#line 5037 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 788: +#line 5038 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 789: +#line 5044 "gram.y" + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = (yyvsp[-1].range); + n->property = (yyvsp[-3].str); + n->behavior = (yyvsp[0].dbehavior); + n->removeType = OBJECT_RULE; + n->missing_ok = false; + (yyval.node) = (Node *) n; + } + break; + + case 790: +#line 5054 "gram.y" + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = (yyvsp[-1].range); + n->property = (yyvsp[-3].str); + n->behavior = (yyvsp[0].dbehavior); + n->removeType = OBJECT_RULE; + n->missing_ok = true; + (yyval.node) = (Node *) n; + } + break; + + case 791: +#line 5075 "gram.y" + { + NotifyStmt *n = makeNode(NotifyStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = (yyvsp[0].str); + n->relation->schemaname = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 792: +#line 5085 "gram.y" + { + ListenStmt *n = makeNode(ListenStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = (yyvsp[0].str); + n->relation->schemaname = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 793: +#line 5096 "gram.y" + { + UnlistenStmt *n = makeNode(UnlistenStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = (yyvsp[0].str); + n->relation->schemaname = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 794: +#line 5104 "gram.y" + { + UnlistenStmt *n = makeNode(UnlistenStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = "*"; + n->relation->schemaname = NULL; + (yyval.node) = (Node *)n; + } + break; + + case 795: +#line 5125 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK; + n->options = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 796: +#line 5132 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_BEGIN; + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 797: +#line 5139 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_START; + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 798: +#line 5146 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT; + n->options = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 799: +#line 5153 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT; + n->options = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 800: +#line 5160 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK; + n->options = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 801: +#line 5167 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_SAVEPOINT; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString((yyvsp[0].str)))); + (yyval.node) = (Node *)n; + } + break; + + case 802: +#line 5175 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_RELEASE; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString((yyvsp[0].str)))); + (yyval.node) = (Node *)n; + } + break; + + case 803: +#line 5183 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_RELEASE; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString((yyvsp[0].str)))); + (yyval.node) = (Node *)n; + } + break; + + case 804: +#line 5191 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_TO; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString((yyvsp[0].str)))); + (yyval.node) = (Node *)n; + } + break; + + case 805: +#line 5199 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_TO; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString((yyvsp[0].str)))); + (yyval.node) = (Node *)n; + } + break; + + case 806: +#line 5207 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_PREPARE; + n->gid = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 807: +#line 5214 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT_PREPARED; + n->gid = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 808: +#line 5221 "gram.y" + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_PREPARED; + n->gid = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 809: +#line 5229 "gram.y" + {} + break; + + case 810: +#line 5230 "gram.y" + {} + break; + + case 811: +#line 5231 "gram.y" + {} + break; + + case 812: +#line 5236 "gram.y" + { (yyval.defelt) = makeDefElem("transaction_isolation", + makeStringConst((yyvsp[0].str), NULL)); } + break; + + case 813: +#line 5239 "gram.y" + { (yyval.defelt) = makeDefElem("transaction_read_only", + makeIntConst(TRUE)); } + break; + + case 814: +#line 5242 "gram.y" + { (yyval.defelt) = makeDefElem("transaction_read_only", + makeIntConst(FALSE)); } + break; + + case 815: +#line 5249 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].defelt)); } + break; + + case 816: +#line 5251 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].defelt)); } + break; + + case 817: +#line 5253 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 819: +#line 5259 "gram.y" + { (yyval.list) = NIL; } + break; + + case 820: +#line 5273 "gram.y" + { + ViewStmt *n = makeNode(ViewStmt); + n->view = (yyvsp[-4].range); + n->view->istemp = (yyvsp[-6].boolean); + n->aliases = (yyvsp[-3].list); + n->query = (yyvsp[-1].node); + n->replace = false; + (yyval.node) = (Node *) n; + } + break; + + case 821: +#line 5284 "gram.y" + { + ViewStmt *n = makeNode(ViewStmt); + n->view = (yyvsp[-4].range); + n->view->istemp = (yyvsp[-6].boolean); + n->aliases = (yyvsp[-3].list); + n->query = (yyvsp[-1].node); + n->replace = true; + (yyval.node) = (Node *) n; + } + break; + + case 822: +#line 5301 "gram.y" + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH CHECK OPTION is not implemented"))); + } + break; + + case 823: +#line 5307 "gram.y" + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH CHECK OPTION is not implemented"))); + } + break; + + case 824: +#line 5313 "gram.y" + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH CHECK OPTION is not implemented"))); + } + break; + + case 825: +#line 5318 "gram.y" + { (yyval.list) = NIL; } + break; + + case 826: +#line 5329 "gram.y" + { + LoadStmt *n = makeNode(LoadStmt); + n->filename = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 827: +#line 5345 "gram.y" + { + CreatedbStmt *n = makeNode(CreatedbStmt); + n->dbname = (yyvsp[-2].str); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 828: +#line 5354 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 829: +#line 5355 "gram.y" + { (yyval.list) = NIL; } + break; + + case 830: +#line 5360 "gram.y" + { + (yyval.defelt) = makeDefElem("tablespace", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 831: +#line 5364 "gram.y" + { + (yyval.defelt) = makeDefElem("tablespace", NULL); + } + break; + + case 832: +#line 5368 "gram.y" + { + (yyval.defelt) = makeDefElem("location", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 833: +#line 5372 "gram.y" + { + (yyval.defelt) = makeDefElem("location", NULL); + } + break; + + case 834: +#line 5376 "gram.y" + { + (yyval.defelt) = makeDefElem("template", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 835: +#line 5380 "gram.y" + { + (yyval.defelt) = makeDefElem("template", NULL); + } + break; + + case 836: +#line 5384 "gram.y" + { + (yyval.defelt) = makeDefElem("encoding", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 837: +#line 5388 "gram.y" + { + (yyval.defelt) = makeDefElem("encoding", (Node *)makeInteger((yyvsp[0].ival))); + } + break; + + case 838: +#line 5392 "gram.y" + { + (yyval.defelt) = makeDefElem("encoding", NULL); + } + break; + + case 839: +#line 5396 "gram.y" + { + (yyval.defelt) = makeDefElem("connectionlimit", (Node *)makeInteger((yyvsp[0].ival))); + } + break; + + case 840: +#line 5400 "gram.y" + { + (yyval.defelt) = makeDefElem("owner", (Node *)makeString((yyvsp[0].str))); + } + break; + + case 841: +#line 5404 "gram.y" + { + (yyval.defelt) = makeDefElem("owner", NULL); + } + break; + + case 842: +#line 5413 "gram.y" + {} + break; + + case 843: +#line 5414 "gram.y" + {} + break; + + case 844: +#line 5426 "gram.y" + { + AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt); + n->dbname = (yyvsp[-2].str); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 845: +#line 5436 "gram.y" + { + AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt); + n->dbname = (yyvsp[-1].str); + n->setstmt = (yyvsp[0].vsetstmt); + (yyval.node) = (Node *)n; + } + break; + + case 846: +#line 5446 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].defelt)); } + break; + + case 847: +#line 5447 "gram.y" + { (yyval.list) = NIL; } + break; + + case 848: +#line 5452 "gram.y" + { + (yyval.defelt) = makeDefElem("connectionlimit", (Node *)makeInteger((yyvsp[0].ival))); + } + break; + + case 849: +#line 5466 "gram.y" + { + DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = (yyvsp[0].str); + n->missing_ok = FALSE; + (yyval.node) = (Node *)n; + } + break; + + case 850: +#line 5473 "gram.y" + { + DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = (yyvsp[0].str); + n->missing_ok = TRUE; + (yyval.node) = (Node *)n; + } + break; + + case 851: +#line 5490 "gram.y" + { + CreateDomainStmt *n = makeNode(CreateDomainStmt); + n->domainname = (yyvsp[-3].list); + n->typename = (yyvsp[-1].typnam); + n->constraints = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 852: +#line 5502 "gram.y" + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'T'; + n->typename = (yyvsp[-1].list); + n->def = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 853: +#line 5511 "gram.y" + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'N'; + n->typename = (yyvsp[-3].list); + (yyval.node) = (Node *)n; + } + break; + + case 854: +#line 5519 "gram.y" + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'O'; + n->typename = (yyvsp[-3].list); + (yyval.node) = (Node *)n; + } + break; + + case 855: +#line 5527 "gram.y" + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'C'; + n->typename = (yyvsp[-2].list); + n->def = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 856: +#line 5536 "gram.y" + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'X'; + n->typename = (yyvsp[-4].list); + n->name = (yyvsp[-1].str); + n->behavior = (yyvsp[0].dbehavior); + (yyval.node) = (Node *)n; + } + break; + + case 857: +#line 5546 "gram.y" + {} + break; + + case 858: +#line 5547 "gram.y" + {} + break; + + case 859: +#line 5559 "gram.y" + { + AlterTSDictionaryStmt *n = makeNode(AlterTSDictionaryStmt); + n->dictname = (yyvsp[-1].list); + n->options = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 860: +#line 5569 "gram.y" + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = (yyvsp[-6].list); + n->tokentype = (yyvsp[-2].list); + n->dicts = (yyvsp[0].list); + n->override = false; + n->replace = false; + (yyval.node) = (Node*)n; + } + break; + + case 861: +#line 5579 "gram.y" + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = (yyvsp[-6].list); + n->tokentype = (yyvsp[-2].list); + n->dicts = (yyvsp[0].list); + n->override = true; + n->replace = false; + (yyval.node) = (Node*)n; + } + break; + + case 862: +#line 5589 "gram.y" + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = (yyvsp[-6].list); + n->tokentype = NIL; + n->dicts = list_make2((yyvsp[-2].list),(yyvsp[0].list)); + n->override = false; + n->replace = true; + (yyval.node) = (Node*)n; + } + break; + + case 863: +#line 5599 "gram.y" + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = (yyvsp[-8].list); + n->tokentype = (yyvsp[-4].list); + n->dicts = list_make2((yyvsp[-2].list),(yyvsp[0].list)); + n->override = false; + n->replace = true; + (yyval.node) = (Node*)n; + } + break; + + case 864: +#line 5609 "gram.y" + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = (yyvsp[-4].list); + n->tokentype = (yyvsp[0].list); + n->missing_ok = false; + (yyval.node) = (Node*)n; + } + break; + + case 865: +#line 5617 "gram.y" + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = (yyvsp[-6].list); + n->tokentype = (yyvsp[0].list); + n->missing_ok = true; + (yyval.node) = (Node*)n; + } + break; + + case 866: +#line 5639 "gram.y" + { + CreateConversionStmt *n = makeNode(CreateConversionStmt); + n->conversion_name = (yyvsp[-6].list); + n->for_encoding_name = (yyvsp[-4].str); + n->to_encoding_name = (yyvsp[-2].str); + n->func_name = (yyvsp[0].list); + n->def = (yyvsp[-8].boolean); + (yyval.node) = (Node *)n; + } + break; + + case 867: +#line 5661 "gram.y" + { + ClusterStmt *n = makeNode(ClusterStmt); + n->relation = (yyvsp[-1].range); + n->indexname = (yyvsp[0].str); + (yyval.node) = (Node*)n; + } + break; + + case 868: +#line 5668 "gram.y" + { + ClusterStmt *n = makeNode(ClusterStmt); + n->relation = NULL; + n->indexname = NULL; + (yyval.node) = (Node*)n; + } + break; + + case 869: +#line 5676 "gram.y" + { + ClusterStmt *n = makeNode(ClusterStmt); + n->relation = (yyvsp[0].range); + n->indexname = (yyvsp[-2].str); + (yyval.node) = (Node*)n; + } + break; + + case 870: +#line 5685 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 871: +#line 5686 "gram.y" + { (yyval.str) = NULL; } + break; + + case 872: +#line 5699 "gram.y" + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = true; + n->analyze = false; + n->full = (yyvsp[-2].boolean); + n->freeze_min_age = (yyvsp[-1].boolean) ? 0 : -1; + n->verbose = (yyvsp[0].boolean); + n->relation = NULL; + n->va_cols = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 873: +#line 5711 "gram.y" + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = true; + n->analyze = false; + n->full = (yyvsp[-3].boolean); + n->freeze_min_age = (yyvsp[-2].boolean) ? 0 : -1; + n->verbose = (yyvsp[-1].boolean); + n->relation = (yyvsp[0].range); + n->va_cols = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 874: +#line 5723 "gram.y" + { + VacuumStmt *n = (VacuumStmt *) (yyvsp[0].node); + n->vacuum = true; + n->full = (yyvsp[-3].boolean); + n->freeze_min_age = (yyvsp[-2].boolean) ? 0 : -1; + n->verbose |= (yyvsp[-1].boolean); + (yyval.node) = (Node *)n; + } + break; + + case 875: +#line 5735 "gram.y" + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = false; + n->analyze = true; + n->full = false; + n->freeze_min_age = -1; + n->verbose = (yyvsp[0].boolean); + n->relation = NULL; + n->va_cols = NIL; + (yyval.node) = (Node *)n; + } + break; + + case 876: +#line 5747 "gram.y" + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = false; + n->analyze = true; + n->full = false; + n->freeze_min_age = -1; + n->verbose = (yyvsp[-2].boolean); + n->relation = (yyvsp[-1].range); + n->va_cols = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 877: +#line 5761 "gram.y" + {} + break; + + case 878: +#line 5762 "gram.y" + {} + break; + + case 879: +#line 5766 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 880: +#line 5767 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 881: +#line 5770 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 882: +#line 5771 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 883: +#line 5774 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 884: +#line 5775 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 885: +#line 5779 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 886: +#line 5780 "gram.y" + { (yyval.list) = NIL; } + break; + + case 887: +#line 5792 "gram.y" + { + ExplainStmt *n = makeNode(ExplainStmt); + n->analyze = (yyvsp[-2].boolean); + n->verbose = (yyvsp[-1].boolean); + n->query = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 894: +#line 5811 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 895: +#line 5812 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 896: +#line 5823 "gram.y" + { + PrepareStmt *n = makeNode(PrepareStmt); + n->name = (yyvsp[-3].str); + n->argtypes = (yyvsp[-2].list); + n->query = (yyvsp[0].node); + (yyval.node) = (Node *) n; + } + break; + + case 897: +#line 5832 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 898: +#line 5833 "gram.y" + { (yyval.list) = NIL; } + break; + + case 903: +#line 5851 "gram.y" + { + ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = (yyvsp[-1].str); + n->params = (yyvsp[0].list); + n->into = NULL; + (yyval.node) = (Node *) n; + } + break; + + case 904: +#line 5860 "gram.y" + { + ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = (yyvsp[-1].str); + n->params = (yyvsp[0].list); + (yyvsp[-4].into)->rel->istemp = (yyvsp[-6].boolean); + n->into = (yyvsp[-4].into); + if ((yyvsp[-4].into)->colNames) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("column name list not allowed in CREATE TABLE / AS EXECUTE"))); + /* ... because it's not implemented, but it could be */ + (yyval.node) = (Node *) n; + } + break; + + case 905: +#line 5875 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 906: +#line 5876 "gram.y" + { (yyval.list) = NIL; } + break; + + case 907: +#line 5887 "gram.y" + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 908: +#line 5893 "gram.y" + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = (yyvsp[0].str); + (yyval.node) = (Node *) n; + } + break; + + case 909: +#line 5899 "gram.y" + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = NULL; + (yyval.node) = (Node *) n; + } + break; + + case 910: +#line 5905 "gram.y" + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = NULL; + (yyval.node) = (Node *) n; + } + break; + + case 911: +#line 5921 "gram.y" + { + (yyvsp[-1].istmt)->relation = (yyvsp[-2].range); + (yyvsp[-1].istmt)->returningList = (yyvsp[0].list); + (yyval.node) = (Node *) (yyvsp[-1].istmt); + } + break; + + case 912: +#line 5930 "gram.y" + { + (yyval.istmt) = makeNode(InsertStmt); + (yyval.istmt)->cols = NIL; + (yyval.istmt)->selectStmt = (yyvsp[0].node); + } + break; + + case 913: +#line 5936 "gram.y" + { + (yyval.istmt) = makeNode(InsertStmt); + (yyval.istmt)->cols = (yyvsp[-2].list); + (yyval.istmt)->selectStmt = (yyvsp[0].node); + } + break; + + case 914: +#line 5942 "gram.y" + { + (yyval.istmt) = makeNode(InsertStmt); + (yyval.istmt)->cols = NIL; + (yyval.istmt)->selectStmt = NULL; + } + break; + + case 915: +#line 5951 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].target)); } + break; + + case 916: +#line 5953 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].target)); } + break; + + case 917: +#line 5958 "gram.y" + { + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = (yyvsp[-1].str); + (yyval.target)->indirection = (yyvsp[0].list); + (yyval.target)->val = NULL; + (yyval.target)->location = (yylsp[-1]); + } + break; + + case 918: +#line 5968 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 919: +#line 5969 "gram.y" + { (yyval.list) = NIL; } + break; + + case 920: +#line 5982 "gram.y" + { + DeleteStmt *n = makeNode(DeleteStmt); + n->relation = (yyvsp[-3].range); + n->usingClause = (yyvsp[-2].list); + n->whereClause = (yyvsp[-1].node); + n->returningList = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 921: +#line 5993 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 922: +#line 5994 "gram.y" + { (yyval.list) = NIL; } + break; + + case 923: +#line 5998 "gram.y" + { + LockStmt *n = makeNode(LockStmt); + + n->relations = (yyvsp[-2].list); + n->mode = (yyvsp[-1].ival); + n->nowait = (yyvsp[0].boolean); + (yyval.node) = (Node *)n; + } + break; + + case 924: +#line 6008 "gram.y" + { (yyval.ival) = (yyvsp[-1].ival); } + break; + + case 925: +#line 6009 "gram.y" + { (yyval.ival) = AccessExclusiveLock; } + break; + + case 926: +#line 6012 "gram.y" + { (yyval.ival) = AccessShareLock; } + break; + + case 927: +#line 6013 "gram.y" + { (yyval.ival) = RowShareLock; } + break; + + case 928: +#line 6014 "gram.y" + { (yyval.ival) = RowExclusiveLock; } + break; + + case 929: +#line 6015 "gram.y" + { (yyval.ival) = ShareUpdateExclusiveLock; } + break; + + case 930: +#line 6016 "gram.y" + { (yyval.ival) = ShareLock; } + break; + + case 931: +#line 6017 "gram.y" + { (yyval.ival) = ShareRowExclusiveLock; } + break; + + case 932: +#line 6018 "gram.y" + { (yyval.ival) = ExclusiveLock; } + break; + + case 933: +#line 6019 "gram.y" + { (yyval.ival) = AccessExclusiveLock; } + break; + + case 934: +#line 6022 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 935: +#line 6023 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 936: +#line 6039 "gram.y" + { + UpdateStmt *n = makeNode(UpdateStmt); + n->relation = (yyvsp[-5].range); + n->targetList = (yyvsp[-3].list); + n->fromClause = (yyvsp[-2].list); + n->whereClause = (yyvsp[-1].node); + n->returningList = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + break; + + case 937: +#line 6051 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 938: +#line 6052 "gram.y" + { (yyval.list) = list_concat((yyvsp[-2].list),(yyvsp[0].list)); } + break; + + case 939: +#line 6056 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].target)); } + break; + + case 940: +#line 6057 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 941: +#line 6062 "gram.y" + { + (yyval.target) = (yyvsp[-2].target); + (yyval.target)->val = (Node *) (yyvsp[0].node); + } + break; + + case 942: +#line 6070 "gram.y" + { + ListCell *col_cell; + ListCell *val_cell; + + /* + * Break the ctext_row apart, merge individual expressions + * into the destination ResTargets. XXX this approach + * cannot work for general row expressions as sources. + */ + if (list_length((yyvsp[-3].list)) != list_length((yyvsp[0].list))) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("number of columns does not match number of values"))); + forboth(col_cell, (yyvsp[-3].list), val_cell, (yyvsp[0].list)) + { + ResTarget *res_col = (ResTarget *) lfirst(col_cell); + Node *res_val = (Node *) lfirst(val_cell); + + res_col->val = res_val; + } + + (yyval.list) = (yyvsp[-3].list); + } + break; + + case 943: +#line 6097 "gram.y" + { + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = (yyvsp[-1].str); + (yyval.target)->indirection = (yyvsp[0].list); + (yyval.target)->val = NULL; /* upper production sets this */ + (yyval.target)->location = (yylsp[-1]); + } + break; + + case 944: +#line 6107 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].target)); } + break; + + case 945: +#line 6108 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list),(yyvsp[0].target)); } + break; + + case 946: +#line 6119 "gram.y" + { + DeclareCursorStmt *n = makeNode(DeclareCursorStmt); + n->portalname = (yyvsp[-5].str); + /* currently we always set FAST_PLAN option */ + n->options = (yyvsp[-4].ival) | (yyvsp[-2].ival) | CURSOR_OPT_FAST_PLAN; + n->query = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 947: +#line 6129 "gram.y" + { (yyval.ival) = 0; } + break; + + case 948: +#line 6130 "gram.y" + { (yyval.ival) = (yyvsp[-2].ival) | CURSOR_OPT_NO_SCROLL; } + break; + + case 949: +#line 6131 "gram.y" + { (yyval.ival) = (yyvsp[-1].ival) | CURSOR_OPT_SCROLL; } + break; + + case 950: +#line 6132 "gram.y" + { (yyval.ival) = (yyvsp[-1].ival) | CURSOR_OPT_BINARY; } + break; + + case 951: +#line 6133 "gram.y" + { (yyval.ival) = (yyvsp[-1].ival) | CURSOR_OPT_INSENSITIVE; } + break; + + case 952: +#line 6136 "gram.y" + { (yyval.ival) = 0; } + break; + + case 953: +#line 6137 "gram.y" + { (yyval.ival) = CURSOR_OPT_HOLD; } + break; + + case 954: +#line 6138 "gram.y" + { (yyval.ival) = 0; } + break; + + case 957: +#line 6191 "gram.y" + { (yyval.node) = (yyvsp[-1].node); } + break; + + case 958: +#line 6192 "gram.y" + { (yyval.node) = (yyvsp[-1].node); } + break; + + case 959: +#line 6202 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 960: +#line 6204 "gram.y" + { + insertSelectOptions((SelectStmt *) (yyvsp[-1].node), (yyvsp[0].list), NIL, + NULL, NULL); + (yyval.node) = (yyvsp[-1].node); + } + break; + + case 961: +#line 6210 "gram.y" + { + insertSelectOptions((SelectStmt *) (yyvsp[-3].node), (yyvsp[-2].list), (yyvsp[-1].list), + list_nth((yyvsp[0].list), 0), list_nth((yyvsp[0].list), 1)); + (yyval.node) = (yyvsp[-3].node); + } + break; + + case 962: +#line 6216 "gram.y" + { + insertSelectOptions((SelectStmt *) (yyvsp[-3].node), (yyvsp[-2].list), (yyvsp[0].list), + list_nth((yyvsp[-1].list), 0), list_nth((yyvsp[-1].list), 1)); + (yyval.node) = (yyvsp[-3].node); + } + break; + + case 963: +#line 6224 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 964: +#line 6225 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 965: +#line 6255 "gram.y" + { + SelectStmt *n = makeNode(SelectStmt); + n->distinctClause = (yyvsp[-6].list); + n->targetList = (yyvsp[-5].list); + n->intoClause = (yyvsp[-4].into); + n->fromClause = (yyvsp[-3].list); + n->whereClause = (yyvsp[-2].node); + n->groupClause = (yyvsp[-1].list); + n->havingClause = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 966: +#line 6266 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 967: +#line 6268 "gram.y" + { + (yyval.node) = makeSetOp(SETOP_UNION, (yyvsp[-1].boolean), (yyvsp[-3].node), (yyvsp[0].node)); + } + break; + + case 968: +#line 6272 "gram.y" + { + (yyval.node) = makeSetOp(SETOP_INTERSECT, (yyvsp[-1].boolean), (yyvsp[-3].node), (yyvsp[0].node)); + } + break; + + case 969: +#line 6276 "gram.y" + { + (yyval.node) = makeSetOp(SETOP_EXCEPT, (yyvsp[-1].boolean), (yyvsp[-3].node), (yyvsp[0].node)); + } + break; + + case 970: +#line 6283 "gram.y" + { + (yyval.into) = makeNode(IntoClause); + (yyval.into)->rel = (yyvsp[0].range); + (yyval.into)->colNames = NIL; + (yyval.into)->options = NIL; + (yyval.into)->onCommit = ONCOMMIT_NOOP; + (yyval.into)->tableSpaceName = NULL; + } + break; + + case 971: +#line 6292 "gram.y" + { (yyval.into) = NULL; } + break; + + case 972: +#line 6301 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = true; + } + break; + + case 973: +#line 6306 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = true; + } + break; + + case 974: +#line 6311 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = true; + } + break; + + case 975: +#line 6316 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = true; + } + break; + + case 976: +#line 6321 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = true; + } + break; + + case 977: +#line 6326 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = true; + } + break; + + case 978: +#line 6331 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = false; + } + break; + + case 979: +#line 6336 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + (yyval.range)->istemp = false; + } + break; + + case 980: +#line 6342 "gram.y" + {} + break; + + case 981: +#line 6343 "gram.y" + {} + break; + + case 982: +#line 6346 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 983: +#line 6347 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 984: +#line 6348 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 985: +#line 6355 "gram.y" + { (yyval.list) = list_make1(NIL); } + break; + + case 986: +#line 6356 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 987: +#line 6357 "gram.y" + { (yyval.list) = NIL; } + break; + + case 988: +#line 6358 "gram.y" + { (yyval.list) = NIL; } + break; + + case 989: +#line 6362 "gram.y" + { (yyval.list) = (yyvsp[0].list);} + break; + + case 990: +#line 6363 "gram.y" + { (yyval.list) = NIL; } + break; + + case 991: +#line 6367 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 992: +#line 6371 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].sortby)); } + break; + + case 993: +#line 6372 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].sortby)); } + break; + + case 994: +#line 6376 "gram.y" + { + (yyval.sortby) = makeNode(SortBy); + (yyval.sortby)->node = (yyvsp[-3].node); + (yyval.sortby)->sortby_dir = SORTBY_USING; + (yyval.sortby)->sortby_nulls = (yyvsp[0].ival); + (yyval.sortby)->useOp = (yyvsp[-1].list); + } + break; + + case 995: +#line 6384 "gram.y" + { + (yyval.sortby) = makeNode(SortBy); + (yyval.sortby)->node = (yyvsp[-2].node); + (yyval.sortby)->sortby_dir = (yyvsp[-1].ival); + (yyval.sortby)->sortby_nulls = (yyvsp[0].ival); + (yyval.sortby)->useOp = NIL; + } + break; + + case 996: +#line 6396 "gram.y" + { (yyval.list) = list_make2((yyvsp[0].node), (yyvsp[-2].node)); } + break; + + case 997: +#line 6398 "gram.y" + { (yyval.list) = list_make2((yyvsp[-2].node), (yyvsp[0].node)); } + break; + + case 998: +#line 6400 "gram.y" + { (yyval.list) = list_make2(NULL, (yyvsp[0].node)); } + break; + + case 999: +#line 6402 "gram.y" + { (yyval.list) = list_make2((yyvsp[0].node), NULL); } + break; + + case 1000: +#line 6404 "gram.y" + { + /* Disabled because it was too confusing, bjm 2002-02-18 */ + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("LIMIT #,# syntax is not supported"), + errhint("Use separate LIMIT and OFFSET clauses."))); + } + break; + + case 1001: +#line 6414 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1002: +#line 6416 "gram.y" + { (yyval.list) = list_make2(NULL,NULL); } + break; + + case 1003: +#line 6420 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1004: +#line 6422 "gram.y" + { + /* LIMIT ALL is represented as a NULL constant */ + A_Const *n = makeNode(A_Const); + n->val.type = T_Null; + (yyval.node) = (Node *)n; + } + break; + + case 1005: +#line 6431 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1006: +#line 6435 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1007: +#line 6436 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1008: +#line 6440 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1009: +#line 6441 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1010: +#line 6445 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1011: +#line 6446 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1012: +#line 6450 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1013: +#line 6451 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1014: +#line 6455 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 1015: +#line 6456 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].node)); } + break; + + case 1016: +#line 6461 "gram.y" + { + LockingClause *n = makeNode(LockingClause); + n->lockedRels = (yyvsp[-1].list); + n->forUpdate = TRUE; + n->noWait = (yyvsp[0].boolean); + (yyval.node) = (Node *) n; + } + break; + + case 1017: +#line 6469 "gram.y" + { + LockingClause *n = makeNode(LockingClause); + n->lockedRels = (yyvsp[-1].list); + n->forUpdate = FALSE; + n->noWait = (yyvsp[0].boolean); + (yyval.node) = (Node *) n; + } + break; + + case 1018: +#line 6479 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1019: +#line 6480 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1020: +#line 6486 "gram.y" + { + SelectStmt *n = makeNode(SelectStmt); + n->valuesLists = list_make1((yyvsp[0].list)); + (yyval.node) = (Node *) n; + } + break; + + case 1021: +#line 6492 "gram.y" + { + SelectStmt *n = (SelectStmt *) (yyvsp[-2].node); + n->valuesLists = lappend(n->valuesLists, (yyvsp[0].list)); + (yyval.node) = (Node *) n; + } + break; + + case 1022: +#line 6509 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1023: +#line 6510 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1024: +#line 6514 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 1025: +#line 6515 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 1026: +#line 6526 "gram.y" + { + (yyval.node) = (Node *) (yyvsp[0].range); + } + break; + + case 1027: +#line 6530 "gram.y" + { + (yyvsp[-1].range)->alias = (yyvsp[0].alias); + (yyval.node) = (Node *) (yyvsp[-1].range); + } + break; + + case 1028: +#line 6535 "gram.y" + { + RangeFunction *n = makeNode(RangeFunction); + n->funccallnode = (yyvsp[0].node); + n->coldeflist = NIL; + (yyval.node) = (Node *) n; + } + break; + + case 1029: +#line 6542 "gram.y" + { + RangeFunction *n = makeNode(RangeFunction); + n->funccallnode = (yyvsp[-1].node); + n->alias = (yyvsp[0].alias); + n->coldeflist = NIL; + (yyval.node) = (Node *) n; + } + break; + + case 1030: +#line 6550 "gram.y" + { + RangeFunction *n = makeNode(RangeFunction); + n->funccallnode = (yyvsp[-4].node); + n->coldeflist = (yyvsp[-1].list); + (yyval.node) = (Node *) n; + } + break; + + case 1031: +#line 6557 "gram.y" + { + RangeFunction *n = makeNode(RangeFunction); + Alias *a = makeNode(Alias); + n->funccallnode = (yyvsp[-5].node); + a->aliasname = (yyvsp[-3].str); + n->alias = a; + n->coldeflist = (yyvsp[-1].list); + (yyval.node) = (Node *) n; + } + break; + + case 1032: +#line 6567 "gram.y" + { + RangeFunction *n = makeNode(RangeFunction); + Alias *a = makeNode(Alias); + n->funccallnode = (yyvsp[-4].node); + a->aliasname = (yyvsp[-3].str); + n->alias = a; + n->coldeflist = (yyvsp[-1].list); + (yyval.node) = (Node *) n; + } + break; + + case 1033: +#line 6577 "gram.y" + { + /* + * The SQL spec does not permit a subselect + * () without an alias clause, + * so we don't either. This avoids the problem + * of needing to invent a unique refname for it. + * That could be surmounted if there's sufficient + * popular demand, but for now let's just implement + * the spec and see if anyone complains. + * However, it does seem like a good idea to emit + * an error message that's better than "syntax error". + */ + if (IsA((yyvsp[0].node), SelectStmt) && + ((SelectStmt *) (yyvsp[0].node))->valuesLists) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("VALUES in FROM must have an alias"), + errhint("For example, FROM (VALUES ...) [AS] foo."))); + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("subquery in FROM must have an alias"), + errhint("For example, FROM (SELECT ...) [AS] foo."))); + (yyval.node) = NULL; + } + break; + + case 1034: +#line 6603 "gram.y" + { + RangeSubselect *n = makeNode(RangeSubselect); + n->subquery = (yyvsp[-1].node); + n->alias = (yyvsp[0].alias); + (yyval.node) = (Node *) n; + } + break; + + case 1035: +#line 6610 "gram.y" + { + (yyval.node) = (Node *) (yyvsp[0].jexpr); + } + break; + + case 1036: +#line 6614 "gram.y" + { + (yyvsp[-2].jexpr)->alias = (yyvsp[0].alias); + (yyval.node) = (Node *) (yyvsp[-2].jexpr); + } + break; + + case 1037: +#line 6640 "gram.y" + { + (yyval.jexpr) = (yyvsp[-1].jexpr); + } + break; + + case 1038: +#line 6644 "gram.y" + { + /* CROSS JOIN is same as unqualified inner join */ + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; + n->isNatural = FALSE; + n->larg = (yyvsp[-3].node); + n->rarg = (yyvsp[0].node); + n->using = NIL; + n->quals = NULL; + (yyval.jexpr) = n; + } + break; + + case 1039: +#line 6656 "gram.y" + { + JoinExpr *n = makeNode(JoinExpr); + n->jointype = (yyvsp[-3].jtype); + n->isNatural = FALSE; + n->larg = (yyvsp[-4].node); + n->rarg = (yyvsp[-1].node); + if ((yyvsp[0].node) != NULL && IsA((yyvsp[0].node), List)) + n->using = (List *) (yyvsp[0].node); /* USING clause */ + else + n->quals = (yyvsp[0].node); /* ON clause */ + (yyval.jexpr) = n; + } + break; + + case 1040: +#line 6669 "gram.y" + { + /* letting join_type reduce to empty doesn't work */ + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; + n->isNatural = FALSE; + n->larg = (yyvsp[-3].node); + n->rarg = (yyvsp[-1].node); + if ((yyvsp[0].node) != NULL && IsA((yyvsp[0].node), List)) + n->using = (List *) (yyvsp[0].node); /* USING clause */ + else + n->quals = (yyvsp[0].node); /* ON clause */ + (yyval.jexpr) = n; + } + break; + + case 1041: +#line 6683 "gram.y" + { + JoinExpr *n = makeNode(JoinExpr); + n->jointype = (yyvsp[-2].jtype); + n->isNatural = TRUE; + n->larg = (yyvsp[-4].node); + n->rarg = (yyvsp[0].node); + n->using = NIL; /* figure out which columns later... */ + n->quals = NULL; /* fill later */ + (yyval.jexpr) = n; + } + break; + + case 1042: +#line 6694 "gram.y" + { + /* letting join_type reduce to empty doesn't work */ + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; + n->isNatural = TRUE; + n->larg = (yyvsp[-3].node); + n->rarg = (yyvsp[0].node); + n->using = NIL; /* figure out which columns later... */ + n->quals = NULL; /* fill later */ + (yyval.jexpr) = n; + } + break; + + case 1043: +#line 6709 "gram.y" + { + (yyval.alias) = makeNode(Alias); + (yyval.alias)->aliasname = (yyvsp[-3].str); + (yyval.alias)->colnames = (yyvsp[-1].list); + } + break; + + case 1044: +#line 6715 "gram.y" + { + (yyval.alias) = makeNode(Alias); + (yyval.alias)->aliasname = (yyvsp[0].str); + } + break; + + case 1045: +#line 6720 "gram.y" + { + (yyval.alias) = makeNode(Alias); + (yyval.alias)->aliasname = (yyvsp[-3].str); + (yyval.alias)->colnames = (yyvsp[-1].list); + } + break; + + case 1046: +#line 6726 "gram.y" + { + (yyval.alias) = makeNode(Alias); + (yyval.alias)->aliasname = (yyvsp[0].str); + } + break; + + case 1047: +#line 6732 "gram.y" + { (yyval.jtype) = JOIN_FULL; } + break; + + case 1048: +#line 6733 "gram.y" + { (yyval.jtype) = JOIN_LEFT; } + break; + + case 1049: +#line 6734 "gram.y" + { (yyval.jtype) = JOIN_RIGHT; } + break; + + case 1050: +#line 6735 "gram.y" + { (yyval.jtype) = JOIN_INNER; } + break; + + case 1051: +#line 6739 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1052: +#line 6740 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1053: +#line 6752 "gram.y" + { (yyval.node) = (Node *) (yyvsp[-1].list); } + break; + + case 1054: +#line 6753 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1055: +#line 6759 "gram.y" + { + /* default inheritance */ + (yyval.range) = (yyvsp[0].range); + (yyval.range)->inhOpt = INH_DEFAULT; + (yyval.range)->alias = NULL; + } + break; + + case 1056: +#line 6766 "gram.y" + { + /* inheritance query */ + (yyval.range) = (yyvsp[-1].range); + (yyval.range)->inhOpt = INH_YES; + (yyval.range)->alias = NULL; + } + break; + + case 1057: +#line 6773 "gram.y" + { + /* no inheritance */ + (yyval.range) = (yyvsp[0].range); + (yyval.range)->inhOpt = INH_NO; + (yyval.range)->alias = NULL; + } + break; + + case 1058: +#line 6780 "gram.y" + { + /* no inheritance, SQL99-style syntax */ + (yyval.range) = (yyvsp[-1].range); + (yyval.range)->inhOpt = INH_NO; + (yyval.range)->alias = NULL; + } + break; + + case 1059: +#line 6799 "gram.y" + { + (yyval.range) = (yyvsp[0].range); + } + break; + + case 1060: +#line 6803 "gram.y" + { + Alias *alias = makeNode(Alias); + alias->aliasname = (yyvsp[0].str); + (yyvsp[-1].range)->alias = alias; + (yyval.range) = (yyvsp[-1].range); + } + break; + + case 1061: +#line 6810 "gram.y" + { + Alias *alias = makeNode(Alias); + alias->aliasname = (yyvsp[0].str); + (yyvsp[-2].range)->alias = alias; + (yyval.range) = (yyvsp[-2].range); + } + break; + + case 1062: +#line 6819 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1063: +#line 6824 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1064: +#line 6825 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1065: +#line 6830 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1066: +#line 6832 "gram.y" + { + CurrentOfExpr *n = makeNode(CurrentOfExpr); + /* cvarno is filled in by parse analysis */ + n->cursor_name = (yyvsp[0].str); + n->cursor_param = 0; + (yyval.node) = (Node *) n; + } + break; + + case 1067: +#line 6840 "gram.y" + { + CurrentOfExpr *n = makeNode(CurrentOfExpr); + /* cvarno is filled in by parse analysis */ + n->cursor_name = NULL; + n->cursor_param = (yyvsp[0].ival); + (yyval.node) = (Node *) n; + } + break; + + case 1068: +#line 6847 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1069: +#line 6853 "gram.y" + { + (yyval.list) = list_make1((yyvsp[0].node)); + } + break; + + case 1070: +#line 6857 "gram.y" + { + (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); + } + break; + + case 1071: +#line 6863 "gram.y" + { + ColumnDef *n = makeNode(ColumnDef); + n->colname = (yyvsp[-1].str); + n->typename = (yyvsp[0].typnam); + n->constraints = NIL; + n->is_local = true; + (yyval.node) = (Node *)n; + } + break; + + case 1072: +#line 6884 "gram.y" + { + (yyval.typnam) = (yyvsp[-1].typnam); + (yyval.typnam)->arrayBounds = (yyvsp[0].list); + } + break; + + case 1073: +#line 6889 "gram.y" + { + (yyval.typnam) = (yyvsp[-1].typnam); + (yyval.typnam)->arrayBounds = (yyvsp[0].list); + (yyval.typnam)->setof = TRUE; + } + break; + + case 1074: +#line 6895 "gram.y" + { + /* SQL99's redundant syntax */ + (yyval.typnam) = (yyvsp[-4].typnam); + (yyval.typnam)->arrayBounds = list_make1(makeInteger((yyvsp[-1].ival))); + } + break; + + case 1075: +#line 6901 "gram.y" + { + /* SQL99's redundant syntax */ + (yyval.typnam) = (yyvsp[-4].typnam); + (yyval.typnam)->arrayBounds = list_make1(makeInteger((yyvsp[-1].ival))); + (yyval.typnam)->setof = TRUE; + } + break; + + case 1076: +#line 6911 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), makeInteger(-1)); } + break; + + case 1077: +#line 6913 "gram.y" + { (yyval.list) = lappend((yyvsp[-3].list), makeInteger((yyvsp[-1].ival))); } + break; + + case 1078: +#line 6915 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1079: +#line 6919 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1080: +#line 6920 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1081: +#line 6921 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1082: +#line 6922 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1083: +#line 6923 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1084: +#line 6925 "gram.y" + { + (yyval.typnam) = (yyvsp[-1].typnam); + if ((yyvsp[0].ival) != INTERVAL_FULL_RANGE) + (yyval.typnam)->typmods = list_make1(makeIntConst((yyvsp[0].ival))); + } + break; + + case 1085: +#line 6931 "gram.y" + { + (yyval.typnam) = (yyvsp[-4].typnam); + (yyval.typnam)->typmods = list_make2(makeIntConst((yyvsp[0].ival)), + makeIntConst((yyvsp[-2].ival))); + } + break; + + case 1086: +#line 6950 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1087: +#line 6951 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1088: +#line 6952 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1089: +#line 6953 "gram.y" + { (yyval.typnam) = (yyvsp[0].typnam); } + break; + + case 1090: +#line 6965 "gram.y" + { + (yyval.typnam) = makeTypeName((yyvsp[-1].str)); + (yyval.typnam)->typmods = (yyvsp[0].list); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1091: +#line 6971 "gram.y" + { + (yyval.typnam) = makeTypeNameFromNameList(lcons(makeString((yyvsp[-2].str)), (yyvsp[-1].list))); + (yyval.typnam)->typmods = (yyvsp[0].list); + (yyval.typnam)->location = (yylsp[-2]); + } + break; + + case 1092: +#line 6978 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1093: +#line 6979 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1094: +#line 6986 "gram.y" + { + (yyval.typnam) = SystemTypeName("int4"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1095: +#line 6991 "gram.y" + { + (yyval.typnam) = SystemTypeName("int4"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1096: +#line 6996 "gram.y" + { + (yyval.typnam) = SystemTypeName("int2"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1097: +#line 7001 "gram.y" + { + (yyval.typnam) = SystemTypeName("int8"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1098: +#line 7006 "gram.y" + { + (yyval.typnam) = SystemTypeName("float4"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1099: +#line 7011 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1100: +#line 7016 "gram.y" + { + (yyval.typnam) = SystemTypeName("float8"); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1101: +#line 7021 "gram.y" + { + (yyval.typnam) = SystemTypeName("numeric"); + (yyval.typnam)->typmods = (yyvsp[0].list); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1102: +#line 7027 "gram.y" + { + (yyval.typnam) = SystemTypeName("numeric"); + (yyval.typnam)->typmods = (yyvsp[0].list); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1103: +#line 7033 "gram.y" + { + (yyval.typnam) = SystemTypeName("numeric"); + (yyval.typnam)->typmods = (yyvsp[0].list); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1104: +#line 7039 "gram.y" + { + (yyval.typnam) = SystemTypeName("bool"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1105: +#line 7046 "gram.y" + { + /* + * Check FLOAT() precision limits assuming IEEE floating + * types - thomas 1997-09-18 + */ + if ((yyvsp[-1].ival) < 1) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("precision for type float must be at least 1 bit"))); + else if ((yyvsp[-1].ival) <= 24) + (yyval.typnam) = SystemTypeName("float4"); + else if ((yyvsp[-1].ival) <= 53) + (yyval.typnam) = SystemTypeName("float8"); + else + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("precision for type float must be less than 54 bits"))); + } + break; + + case 1106: +#line 7065 "gram.y" + { + (yyval.typnam) = SystemTypeName("float8"); + } + break; + + case 1107: +#line 7075 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 1108: +#line 7079 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 1109: +#line 7087 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 1110: +#line 7091 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + (yyval.typnam)->typmods = NIL; + } + break; + + case 1111: +#line 7099 "gram.y" + { + char *typname; + + typname = (yyvsp[-3].boolean) ? "varbit" : "bit"; + (yyval.typnam) = SystemTypeName(typname); + (yyval.typnam)->typmods = (yyvsp[-1].list); + (yyval.typnam)->location = (yylsp[-4]); + } + break; + + case 1112: +#line 7111 "gram.y" + { + /* bit defaults to bit(1), varbit to no limit */ + if ((yyvsp[0].boolean)) + { + (yyval.typnam) = SystemTypeName("varbit"); + } + else + { + (yyval.typnam) = SystemTypeName("bit"); + (yyval.typnam)->typmods = list_make1(makeIntConst(1)); + } + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1113: +#line 7132 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 1114: +#line 7136 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 1115: +#line 7142 "gram.y" + { + (yyval.typnam) = (yyvsp[0].typnam); + } + break; + + case 1116: +#line 7146 "gram.y" + { + /* Length was not specified so allow to be unrestricted. + * This handles problems with fixed-length (bpchar) strings + * which in column definitions must default to a length + * of one, but should not be constrained if the length + * was not specified. + */ + (yyval.typnam) = (yyvsp[0].typnam); + (yyval.typnam)->typmods = NIL; + } + break; + + case 1117: +#line 7159 "gram.y" + { + if (((yyvsp[0].str) != NULL) && (strcmp((yyvsp[0].str), "sql_text") != 0)) + { + char *type; + + type = palloc(strlen((yyvsp[-4].str)) + 1 + strlen((yyvsp[0].str)) + 1); + strcpy(type, (yyvsp[-4].str)); + strcat(type, "_"); + strcat(type, (yyvsp[0].str)); + (yyvsp[-4].str) = type; + } + + (yyval.typnam) = SystemTypeName((yyvsp[-4].str)); + (yyval.typnam)->typmods = list_make1(makeIntConst((yyvsp[-2].ival))); + (yyval.typnam)->location = (yylsp[-4]); + } + break; + + case 1118: +#line 7178 "gram.y" + { + if (((yyvsp[0].str) != NULL) && (strcmp((yyvsp[0].str), "sql_text") != 0)) + { + char *type; + + type = palloc(strlen((yyvsp[-1].str)) + 1 + strlen((yyvsp[0].str)) + 1); + strcpy(type, (yyvsp[-1].str)); + strcat(type, "_"); + strcat(type, (yyvsp[0].str)); + (yyvsp[-1].str) = type; + } + + (yyval.typnam) = SystemTypeName((yyvsp[-1].str)); + + /* char defaults to char(1), varchar to no limit */ + if (strcmp((yyvsp[-1].str), "char") == 0) + (yyval.typnam)->typmods = list_make1(makeIntConst(1)); + + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1119: +#line 7201 "gram.y" + { (yyval.str) = (yyvsp[0].boolean) ? "varchar": "char"; } + break; + + case 1120: +#line 7203 "gram.y" + { (yyval.str) = (yyvsp[0].boolean) ? "varchar": "char"; } + break; + + case 1121: +#line 7205 "gram.y" + { (yyval.str) = "varchar"; } + break; + + case 1122: +#line 7207 "gram.y" + { (yyval.str) = (yyvsp[0].boolean) ? "varchar": "char"; } + break; + + case 1123: +#line 7209 "gram.y" + { (yyval.str) = (yyvsp[0].boolean) ? "varchar": "char"; } + break; + + case 1124: +#line 7211 "gram.y" + { (yyval.str) = (yyvsp[0].boolean) ? "varchar": "char"; } + break; + + case 1125: +#line 7215 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 1126: +#line 7216 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 1127: +#line 7220 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1128: +#line 7221 "gram.y" + { (yyval.str) = NULL; } + break; + + case 1129: +#line 7229 "gram.y" + { + if ((yyvsp[0].boolean)) + (yyval.typnam) = SystemTypeName("timestamptz"); + else + (yyval.typnam) = SystemTypeName("timestamp"); + /* XXX the timezone field seems to be unused + * - thomas 2001-09-06 + */ + (yyval.typnam)->timezone = (yyvsp[0].boolean); + (yyval.typnam)->typmods = list_make1(makeIntConst((yyvsp[-2].ival))); + (yyval.typnam)->location = (yylsp[-4]); + } + break; + + case 1130: +#line 7242 "gram.y" + { + if ((yyvsp[0].boolean)) + (yyval.typnam) = SystemTypeName("timestamptz"); + else + (yyval.typnam) = SystemTypeName("timestamp"); + /* XXX the timezone field seems to be unused + * - thomas 2001-09-06 + */ + (yyval.typnam)->timezone = (yyvsp[0].boolean); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1131: +#line 7254 "gram.y" + { + if ((yyvsp[0].boolean)) + (yyval.typnam) = SystemTypeName("timetz"); + else + (yyval.typnam) = SystemTypeName("time"); + (yyval.typnam)->typmods = list_make1(makeIntConst((yyvsp[-2].ival))); + (yyval.typnam)->location = (yylsp[-4]); + } + break; + + case 1132: +#line 7263 "gram.y" + { + if ((yyvsp[0].boolean)) + (yyval.typnam) = SystemTypeName("timetz"); + else + (yyval.typnam) = SystemTypeName("time"); + (yyval.typnam)->location = (yylsp[-1]); + } + break; + + case 1133: +#line 7274 "gram.y" + { + (yyval.typnam) = SystemTypeName("interval"); + (yyval.typnam)->location = (yylsp[0]); + } + break; + + case 1134: +#line 7281 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 1135: +#line 7282 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 1136: +#line 7283 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 1137: +#line 7287 "gram.y" + { (yyval.ival) = INTERVAL_MASK(YEAR); } + break; + + case 1138: +#line 7288 "gram.y" + { (yyval.ival) = INTERVAL_MASK(MONTH); } + break; + + case 1139: +#line 7289 "gram.y" + { (yyval.ival) = INTERVAL_MASK(DAY); } + break; + + case 1140: +#line 7290 "gram.y" + { (yyval.ival) = INTERVAL_MASK(HOUR); } + break; + + case 1141: +#line 7291 "gram.y" + { (yyval.ival) = INTERVAL_MASK(MINUTE); } + break; + + case 1142: +#line 7292 "gram.y" + { (yyval.ival) = INTERVAL_MASK(SECOND); } + break; + + case 1143: +#line 7294 "gram.y" + { (yyval.ival) = INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH); } + break; + + case 1144: +#line 7296 "gram.y" + { (yyval.ival) = INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR); } + break; + + case 1145: +#line 7298 "gram.y" + { (yyval.ival) = INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE); } + break; + + case 1146: +#line 7301 "gram.y" + { (yyval.ival) = INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND); } + break; + + case 1147: +#line 7304 "gram.y" + { (yyval.ival) = INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE); } + break; + + case 1148: +#line 7306 "gram.y" + { (yyval.ival) = INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) + | INTERVAL_MASK(SECOND); } + break; + + case 1149: +#line 7309 "gram.y" + { (yyval.ival) = INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND); } + break; + + case 1150: +#line 7310 "gram.y" + { (yyval.ival) = INTERVAL_FULL_RANGE; } + break; + + case 1151: +#line 7336 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1152: +#line 7338 "gram.y" + { (yyval.node) = makeTypeCast((yyvsp[-2].node), (yyvsp[0].typnam)); } + break; + + case 1153: +#line 7340 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("timezone"); + n->args = list_make2((yyvsp[0].node), (yyvsp[-4].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *) n; + } + break; + + case 1154: +#line 7359 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1155: +#line 7361 "gram.y" + { (yyval.node) = doNegate((yyvsp[0].node), (yylsp[-1])); } + break; + + case 1156: +#line 7363 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1157: +#line 7365 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1158: +#line 7367 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1159: +#line 7369 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1160: +#line 7371 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1161: +#line 7373 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1162: +#line 7375 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1163: +#line 7377 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1164: +#line 7379 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1165: +#line 7382 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OP, (yyvsp[-1].list), (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1166: +#line 7384 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OP, (yyvsp[-1].list), NULL, (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1167: +#line 7386 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OP, (yyvsp[0].list), (yyvsp[-1].node), NULL, (yylsp[0])); } + break; + + case 1168: +#line 7389 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_AND, NIL, (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1169: +#line 7391 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OR, NIL, (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1170: +#line 7393 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1171: +#line 7396 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1172: +#line 7398 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2((yyvsp[-2].node), (yyvsp[0].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-1]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", (yyvsp[-4].node), (Node *) n, (yylsp[-3])); + } + break; + + case 1173: +#line 7408 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", (yyvsp[-3].node), (yyvsp[0].node), (yylsp[-2])); } + break; + + case 1174: +#line 7410 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2((yyvsp[-2].node), (yyvsp[0].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-1]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", (yyvsp[-5].node), (Node *) n, (yylsp[-4])); + } + break; + + case 1175: +#line 7420 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1176: +#line 7422 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2((yyvsp[-2].node), (yyvsp[0].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-1]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", (yyvsp[-4].node), (Node *) n, (yylsp[-3])); + } + break; + + case 1177: +#line 7432 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", (yyvsp[-3].node), (yyvsp[0].node), (yylsp[-2])); } + break; + + case 1178: +#line 7434 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2((yyvsp[-2].node), (yyvsp[0].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-1]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", (yyvsp[-5].node), (Node *) n, (yylsp[-4])); + } + break; + + case 1179: +#line 7445 "gram.y" + { + A_Const *c = makeNode(A_Const); + FuncCall *n = makeNode(FuncCall); + c->val.type = T_Null; + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2((yyvsp[0].node), (Node *) c); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-2]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", (yyvsp[-3].node), (Node *) n, (yylsp[-2])); + } + break; + + case 1180: +#line 7457 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2((yyvsp[-2].node), (yyvsp[0].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-1]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", (yyvsp[-5].node), (Node *) n, (yylsp[-4])); + } + break; + + case 1181: +#line 7467 "gram.y" + { + A_Const *c = makeNode(A_Const); + FuncCall *n = makeNode(FuncCall); + c->val.type = T_Null; + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2((yyvsp[0].node), (Node *) c); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[0]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", (yyvsp[-4].node), (Node *) n, (yylsp[-3])); + } + break; + + case 1182: +#line 7479 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2((yyvsp[-2].node), (yyvsp[0].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-1]); + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", (yyvsp[-6].node), (Node *) n, (yylsp[-5])); + } + break; + + case 1183: +#line 7499 "gram.y" + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) (yyvsp[-2].node); + n->nulltesttype = IS_NULL; + (yyval.node) = (Node *)n; + } + break; + + case 1184: +#line 7506 "gram.y" + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) (yyvsp[-1].node); + n->nulltesttype = IS_NULL; + (yyval.node) = (Node *)n; + } + break; + + case 1185: +#line 7513 "gram.y" + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) (yyvsp[-3].node); + n->nulltesttype = IS_NOT_NULL; + (yyval.node) = (Node *)n; + } + break; + + case 1186: +#line 7520 "gram.y" + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) (yyvsp[-1].node); + n->nulltesttype = IS_NOT_NULL; + (yyval.node) = (Node *)n; + } + break; + + case 1187: +#line 7527 "gram.y" + { + (yyval.node) = (Node *)makeOverlaps((yyvsp[-2].list), (yyvsp[0].list), (yylsp[-1])); + } + break; + + case 1188: +#line 7531 "gram.y" + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) (yyvsp[-2].node); + b->booltesttype = IS_TRUE; + (yyval.node) = (Node *)b; + } + break; + + case 1189: +#line 7538 "gram.y" + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) (yyvsp[-3].node); + b->booltesttype = IS_NOT_TRUE; + (yyval.node) = (Node *)b; + } + break; + + case 1190: +#line 7545 "gram.y" + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) (yyvsp[-2].node); + b->booltesttype = IS_FALSE; + (yyval.node) = (Node *)b; + } + break; + + case 1191: +#line 7552 "gram.y" + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) (yyvsp[-3].node); + b->booltesttype = IS_NOT_FALSE; + (yyval.node) = (Node *)b; + } + break; + + case 1192: +#line 7559 "gram.y" + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) (yyvsp[-2].node); + b->booltesttype = IS_UNKNOWN; + (yyval.node) = (Node *)b; + } + break; + + case 1193: +#line 7566 "gram.y" + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) (yyvsp[-3].node); + b->booltesttype = IS_NOT_UNKNOWN; + (yyval.node) = (Node *)b; + } + break; + + case 1194: +#line 7573 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", (yyvsp[-4].node), (yyvsp[0].node), (yylsp[-3])); + } + break; + + case 1195: +#line 7577 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, + (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, + "=", (yyvsp[-5].node), (yyvsp[0].node), (yylsp[-4])), + (yylsp[-4])); + + } + break; + + case 1196: +#line 7585 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OF, "=", (yyvsp[-5].node), (Node *) (yyvsp[-1].list), (yylsp[-4])); + } + break; + + case 1197: +#line 7589 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OF, "<>", (yyvsp[-6].node), (Node *) (yyvsp[-1].list), (yylsp[-5])); + } + break; + + case 1198: +#line 7593 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", (yyvsp[-5].node), (yyvsp[-2].node), (yylsp[-4])), + (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", (yyvsp[-5].node), (yyvsp[0].node), (yylsp[-4])), + (yylsp[-4])); + } + break; + + case 1199: +#line 7600 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, "<", (yyvsp[-6].node), (yyvsp[-2].node), (yylsp[-5])), + (Node *) makeSimpleA_Expr(AEXPR_OP, ">", (yyvsp[-6].node), (yyvsp[0].node), (yylsp[-5])), + (yylsp[-5])); + } + break; + + case 1200: +#line 7607 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", (yyvsp[-5].node), (yyvsp[-2].node), (yylsp[-4])), + (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", (yyvsp[-5].node), (yyvsp[0].node), (yylsp[-4])), + (yylsp[-4])), + (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", (yyvsp[-5].node), (yyvsp[0].node), (yylsp[-4])), + (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", (yyvsp[-5].node), (yyvsp[-2].node), (yylsp[-4])), + (yylsp[-4])), + (yylsp[-4])); + } + break; + + case 1201: +#line 7620 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, "<", (yyvsp[-6].node), (yyvsp[-2].node), (yylsp[-5])), + (Node *) makeSimpleA_Expr(AEXPR_OP, ">", (yyvsp[-6].node), (yyvsp[0].node), (yylsp[-5])), + (yylsp[-5])), + (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, "<", (yyvsp[-6].node), (yyvsp[0].node), (yylsp[-5])), + (Node *) makeSimpleA_Expr(AEXPR_OP, ">", (yyvsp[-6].node), (yyvsp[-2].node), (yylsp[-5])), + (yylsp[-5])), + (yylsp[-5])); + } + break; + + case 1202: +#line 7633 "gram.y" + { + /* in_expr returns a SubLink or a list of a_exprs */ + if (IsA((yyvsp[0].node), SubLink)) + { + /* generate foo = ANY (subquery) */ + SubLink *n = (SubLink *) (yyvsp[0].node); + n->subLinkType = ANY_SUBLINK; + n->testexpr = (yyvsp[-2].node); + n->operName = list_make1(makeString("=")); + (yyval.node) = (Node *)n; + } + else + { + /* generate scalar IN expression */ + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_IN, "=", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); + } + } + break; + + case 1203: +#line 7651 "gram.y" + { + /* in_expr returns a SubLink or a list of a_exprs */ + if (IsA((yyvsp[0].node), SubLink)) + { + /* generate NOT (foo = ANY (subquery)) */ + /* Make an = ANY node */ + SubLink *n = (SubLink *) (yyvsp[0].node); + n->subLinkType = ANY_SUBLINK; + n->testexpr = (yyvsp[-3].node); + n->operName = list_make1(makeString("=")); + /* Stick a NOT on top */ + (yyval.node) = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (Node *) n, (yylsp[-2])); + } + else + { + /* generate scalar NOT IN expression */ + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_IN, "<>", (yyvsp[-3].node), (yyvsp[0].node), (yylsp[-2])); + } + } + break; + + case 1204: +#line 7671 "gram.y" + { + SubLink *n = makeNode(SubLink); + n->subLinkType = (yyvsp[-1].ival); + n->testexpr = (yyvsp[-3].node); + n->operName = (yyvsp[-2].list); + n->subselect = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 1205: +#line 7680 "gram.y" + { + if ((yyvsp[-3].ival) == ANY_SUBLINK) + (yyval.node) = (Node *) makeA_Expr(AEXPR_OP_ANY, (yyvsp[-4].list), (yyvsp[-5].node), (yyvsp[-1].node), (yylsp[-4])); + else + (yyval.node) = (Node *) makeA_Expr(AEXPR_OP_ALL, (yyvsp[-4].list), (yyvsp[-5].node), (yyvsp[-1].node), (yylsp[-4])); + } + break; + + case 1206: +#line 7687 "gram.y" + { + /* Not sure how to get rid of the parentheses + * but there are lots of shift/reduce errors without them. + * + * Should be able to implement this by plopping the entire + * select into a node, then transforming the target expressions + * from whatever they are into count(*), and testing the + * entire result equal to one. + * But, will probably implement a separate node in the executor. + */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("UNIQUE predicate is not yet implemented"))); + } + break; + + case 1207: +#line 7702 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1((yyvsp[-2].node))); + } + break; + + case 1208: +#line 7706 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, + makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1((yyvsp[-3].node))), + (yylsp[-2])); + } + break; + + case 1209: +#line 7723 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1210: +#line 7725 "gram.y" + { (yyval.node) = makeTypeCast((yyvsp[-2].node), (yyvsp[0].typnam)); } + break; + + case 1211: +#line 7727 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1212: +#line 7729 "gram.y" + { (yyval.node) = doNegate((yyvsp[0].node), (yylsp[-1])); } + break; + + case 1213: +#line 7731 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1214: +#line 7733 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1215: +#line 7735 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1216: +#line 7737 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1217: +#line 7739 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1218: +#line 7741 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1219: +#line 7743 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1220: +#line 7745 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1221: +#line 7747 "gram.y" + { (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1222: +#line 7749 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OP, (yyvsp[-1].list), (yyvsp[-2].node), (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1223: +#line 7751 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OP, (yyvsp[-1].list), NULL, (yyvsp[0].node), (yylsp[-1])); } + break; + + case 1224: +#line 7753 "gram.y" + { (yyval.node) = (Node *) makeA_Expr(AEXPR_OP, (yyvsp[0].list), (yyvsp[-1].node), NULL, (yylsp[0])); } + break; + + case 1225: +#line 7755 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", (yyvsp[-4].node), (yyvsp[0].node), (yylsp[-3])); + } + break; + + case 1226: +#line 7759 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_NOT, NIL, + NULL, (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", (yyvsp[-5].node), (yyvsp[0].node), (yylsp[-4])), (yylsp[-4])); + } + break; + + case 1227: +#line 7764 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OF, "=", (yyvsp[-5].node), (Node *) (yyvsp[-1].list), (yylsp[-4])); + } + break; + + case 1228: +#line 7768 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_OF, "<>", (yyvsp[-6].node), (Node *) (yyvsp[-1].list), (yylsp[-5])); + } + break; + + case 1229: +#line 7772 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1((yyvsp[-2].node))); + } + break; + + case 1230: +#line 7776 "gram.y" + { + (yyval.node) = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, + makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1((yyvsp[-3].node))), + (yylsp[-2])); + } + break; + + case 1231: +#line 7791 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1232: +#line 7792 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1233: +#line 7794 "gram.y" + { + ParamRef *p = makeNode(ParamRef); + p->number = (yyvsp[-1].ival); + if ((yyvsp[0].list)) + { + A_Indirection *n = makeNode(A_Indirection); + n->arg = (Node *) p; + n->indirection = (yyvsp[0].list); + (yyval.node) = (Node *) n; + } + else + (yyval.node) = (Node *) p; + } + break; + + case 1234: +#line 7808 "gram.y" + { + if ((yyvsp[0].list)) + { + A_Indirection *n = makeNode(A_Indirection); + n->arg = (yyvsp[-2].node); + n->indirection = (yyvsp[0].list); + (yyval.node) = (Node *)n; + } + else + (yyval.node) = (yyvsp[-2].node); + } + break; + + case 1235: +#line 7820 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1236: +#line 7822 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1237: +#line 7824 "gram.y" + { + SubLink *n = makeNode(SubLink); + n->subLinkType = EXPR_SUBLINK; + n->testexpr = NULL; + n->operName = NIL; + n->subselect = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 1238: +#line 7833 "gram.y" + { + SubLink *n = makeNode(SubLink); + n->subLinkType = EXISTS_SUBLINK; + n->testexpr = NULL; + n->operName = NIL; + n->subselect = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 1239: +#line 7842 "gram.y" + { + SubLink *n = makeNode(SubLink); + n->subLinkType = ARRAY_SUBLINK; + n->testexpr = NULL; + n->operName = NIL; + n->subselect = (yyvsp[0].node); + (yyval.node) = (Node *)n; + } + break; + + case 1240: +#line 7851 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1241: +#line 7853 "gram.y" + { + RowExpr *r = makeNode(RowExpr); + r->args = (yyvsp[0].list); + r->row_typeid = 0; /* not analyzed yet */ + (yyval.node) = (Node *)r; + } + break; + + case 1242: +#line 7870 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = (yyvsp[-2].list); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-2]); + (yyval.node) = (Node *)n; + } + break; + + case 1243: +#line 7880 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = (yyvsp[-3].list); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1244: +#line 7890 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = (yyvsp[-4].list); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + /* Ideally we'd mark the FuncCall node to indicate + * "must be an aggregate", but there's no provision + * for that in FuncCall at the moment. + */ + n->location = (yylsp[-4]); + (yyval.node) = (Node *)n; + } + break; + + case 1245: +#line 7904 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = (yyvsp[-4].list); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = TRUE; + n->location = (yylsp[-4]); + (yyval.node) = (Node *)n; + } + break; + + case 1246: +#line 7914 "gram.y" + { + /* + * We consider AGGREGATE(*) to invoke a parameterless + * aggregate. This does the right thing for COUNT(*), + * and there are no other aggregates in SQL92 that accept + * '*' as parameter. + * + * The FuncCall node is also marked agg_star = true, + * so that later processing can detect what the argument + * really was. + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = (yyvsp[-3].list); + n->args = NIL; + n->agg_star = TRUE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1247: +#line 7934 "gram.y" + { + /* + * Translate as "'now'::text::date". + * + * We cannot use "'now'::date" because coerce_type() will + * immediately reduce that to a constant representing + * today's date. We need to delay the conversion until + * runtime, else the wrong things will happen when + * CURRENT_DATE is used in a column default value or rule. + * + * This could be simplified if we had a way to generate + * an expression tree representing runtime application + * of type-input conversion functions. (As of PG 7.3 + * that is actually possible, but not clear that we want + * to rely on it.) + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("date"); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1248: +#line 7962 "gram.y" + { + /* + * Translate as "'now'::text::timetz". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timetz"); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1249: +#line 7979 "gram.y" + { + /* + * Translate as "'now'::text::timetz(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + d = SystemTypeName("timetz"); + d->typmods = list_make1(makeIntConst((yyvsp[-1].ival))); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1250: +#line 7996 "gram.y" + { + /* + * Translate as "now()", since we have a function that + * does exactly what is needed. + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("now"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[0]); + (yyval.node) = (Node *)n; + } + break; + + case 1251: +#line 8010 "gram.y" + { + /* + * Translate as "'now'::text::timestamptz(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timestamptz"); + d->typmods = list_make1(makeIntConst((yyvsp[-1].ival))); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1252: +#line 8028 "gram.y" + { + /* + * Translate as "'now'::text::time". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("time"); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1253: +#line 8045 "gram.y" + { + /* + * Translate as "'now'::text::time(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + d = SystemTypeName("time"); + d->typmods = list_make1(makeIntConst((yyvsp[-1].ival))); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1254: +#line 8062 "gram.y" + { + /* + * Translate as "'now'::text::timestamp". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timestamp"); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1255: +#line 8079 "gram.y" + { + /* + * Translate as "'now'::text::timestamp(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timestamp"); + d->typmods = list_make1(makeIntConst((yyvsp[-1].ival))); + + (yyval.node) = (Node *)makeTypeCast((Node *)s, d); + } + break; + + case 1256: +#line 8097 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("current_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[0]); + (yyval.node) = (Node *)n; + } + break; + + case 1257: +#line 8107 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("current_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[0]); + (yyval.node) = (Node *)n; + } + break; + + case 1258: +#line 8117 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("session_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[0]); + (yyval.node) = (Node *)n; + } + break; + + case 1259: +#line 8127 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("current_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[0]); + (yyval.node) = (Node *)n; + } + break; + + case 1260: +#line 8137 "gram.y" + { (yyval.node) = makeTypeCast((yyvsp[-3].node), (yyvsp[-1].typnam)); } + break; + + case 1261: +#line 8139 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("date_part"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1262: +#line 8149 "gram.y" + { + /* overlay(A PLACING B FROM C FOR D) is converted to + * substring(A, 1, C-1) || B || substring(A, C+1, C+D) + * overlay(A PLACING B FROM C) is converted to + * substring(A, 1, C-1) || B || substring(A, C+1, C+char_length(B)) + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("overlay"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1263: +#line 8164 "gram.y" + { + /* position(A in B) is converted to position(B, A) */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("position"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1264: +#line 8175 "gram.y" + { + /* substring(A from B for C) is converted to + * substring(A, B, C) - thomas 2000-11-28 + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("substring"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1265: +#line 8188 "gram.y" + { + /* TREAT(expr AS target) converts expr of a particular type to target, + * which is defined to be a subtype of the original expression. + * In SQL99, this is intended for use with structured UDTs, + * but let's make this a generally useful form allowing stronger + * coercions than are handled by implicit casting. + */ + FuncCall *n = makeNode(FuncCall); + /* Convert SystemTypeName() to SystemFuncName() even though + * at the moment they result in the same thing. + */ + n->funcname = SystemFuncName(((Value *)llast((yyvsp[-1].typnam)->names))->val.str); + n->args = list_make1((yyvsp[-3].node)); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-5]); + (yyval.node) = (Node *)n; + } + break; + + case 1266: +#line 8207 "gram.y" + { + /* various trim expressions are defined in SQL92 + * - thomas 1997-07-19 + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("btrim"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-4]); + (yyval.node) = (Node *)n; + } + break; + + case 1267: +#line 8220 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("ltrim"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-4]); + (yyval.node) = (Node *)n; + } + break; + + case 1268: +#line 8230 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("rtrim"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-4]); + (yyval.node) = (Node *)n; + } + break; + + case 1269: +#line 8240 "gram.y" + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("btrim"); + n->args = (yyvsp[-1].list); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = (yylsp[-3]); + (yyval.node) = (Node *)n; + } + break; + + case 1270: +#line 8250 "gram.y" + { + (yyval.node) = (Node *) makeSimpleA_Expr(AEXPR_NULLIF, "=", (yyvsp[-3].node), (yyvsp[-1].node), (yylsp[-5])); + } + break; + + case 1271: +#line 8254 "gram.y" + { + CoalesceExpr *c = makeNode(CoalesceExpr); + c->args = (yyvsp[-1].list); + (yyval.node) = (Node *)c; + } + break; + + case 1272: +#line 8260 "gram.y" + { + MinMaxExpr *v = makeNode(MinMaxExpr); + v->args = (yyvsp[-1].list); + v->op = IS_GREATEST; + (yyval.node) = (Node *)v; + } + break; + + case 1273: +#line 8267 "gram.y" + { + MinMaxExpr *v = makeNode(MinMaxExpr); + v->args = (yyvsp[-1].list); + v->op = IS_LEAST; + (yyval.node) = (Node *)v; + } + break; + + case 1274: +#line 8274 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLCONCAT, NULL, NIL, (yyvsp[-1].list)); + } + break; + + case 1275: +#line 8278 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLELEMENT, (yyvsp[-1].str), NIL, NIL); + } + break; + + case 1276: +#line 8282 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLELEMENT, (yyvsp[-3].str), (yyvsp[-1].list), NIL); + } + break; + + case 1277: +#line 8286 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLELEMENT, (yyvsp[-3].str), NIL, (yyvsp[-1].list)); + } + break; + + case 1278: +#line 8290 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLELEMENT, (yyvsp[-5].str), (yyvsp[-3].list), (yyvsp[-1].list)); + } + break; + + case 1279: +#line 8294 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLFOREST, NULL, (yyvsp[-1].list), NIL); + } + break; + + case 1280: +#line 8298 "gram.y" + { + XmlExpr *x = (XmlExpr *) makeXmlExpr(IS_XMLPARSE, NULL, NIL, + list_make2((yyvsp[-2].node), + makeBoolAConst((yyvsp[-1].boolean)))); + x->xmloption = (yyvsp[-3].ival); + (yyval.node) = (Node *)x; + } + break; + + case 1281: +#line 8306 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLPI, (yyvsp[-1].str), NULL, NIL); + } + break; + + case 1282: +#line 8310 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLPI, (yyvsp[-3].str), NULL, list_make1((yyvsp[-1].node))); + } + break; + + case 1283: +#line 8314 "gram.y" + { + (yyval.node) = makeXmlExpr(IS_XMLROOT, NULL, NIL, + list_make3((yyvsp[-4].node), (yyvsp[-2].node), (yyvsp[-1].node))); + } + break; + + case 1284: +#line 8319 "gram.y" + { + XmlSerialize *n = makeNode(XmlSerialize); + n->xmloption = (yyvsp[-4].ival); + n->expr = (yyvsp[-3].node); + n->typename = (yyvsp[-1].typnam); + (yyval.node) = (Node *)n; + } + break; + + case 1285: +#line 8332 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1286: +#line 8334 "gram.y" + { + A_Const *val = makeNode(A_Const); + val->val.type = T_Null; + (yyval.node) = (Node *) val; + } + break; + + case 1287: +#line 8342 "gram.y" + { (yyval.node) = (Node *) makeIntConst(XML_STANDALONE_YES); } + break; + + case 1288: +#line 8344 "gram.y" + { (yyval.node) = (Node *) makeIntConst(XML_STANDALONE_NO); } + break; + + case 1289: +#line 8346 "gram.y" + { (yyval.node) = (Node *) makeIntConst(XML_STANDALONE_NO_VALUE); } + break; + + case 1290: +#line 8348 "gram.y" + { (yyval.node) = (Node *) makeIntConst(XML_STANDALONE_OMITTED); } + break; + + case 1291: +#line 8351 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1292: +#line 8354 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].target)); } + break; + + case 1293: +#line 8355 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].target)); } + break; + + case 1294: +#line 8359 "gram.y" + { + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = (yyvsp[0].str); + (yyval.target)->indirection = NULL; + (yyval.target)->val = (Node *) (yyvsp[-2].node); + (yyval.target)->location = (yylsp[-2]); + } + break; + + case 1295: +#line 8367 "gram.y" + { + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = NULL; + (yyval.target)->indirection = NULL; + (yyval.target)->val = (Node *) (yyvsp[0].node); + (yyval.target)->location = (yylsp[0]); + } + break; + + case 1296: +#line 8376 "gram.y" + { (yyval.ival) = XMLOPTION_DOCUMENT; } + break; + + case 1297: +#line 8377 "gram.y" + { (yyval.ival) = XMLOPTION_CONTENT; } + break; + + case 1298: +#line 8380 "gram.y" + { (yyval.boolean) = TRUE; } + break; + + case 1299: +#line 8381 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 1300: +#line 8382 "gram.y" + { (yyval.boolean) = FALSE; } + break; + + case 1301: +#line 8395 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1302: +#line 8396 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1303: +#line 8397 "gram.y" + { (yyval.list) = lappend((yyvsp[-3].list), (yyvsp[-1].node)); } + break; + + case 1304: +#line 8400 "gram.y" + { (yyval.ival) = ANY_SUBLINK; } + break; + + case 1305: +#line 8401 "gram.y" + { (yyval.ival) = ANY_SUBLINK; } + break; + + case 1306: +#line 8402 "gram.y" + { (yyval.ival) = ALL_SUBLINK; } + break; + + case 1307: +#line 8405 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1308: +#line 8406 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1309: +#line 8409 "gram.y" + { (yyval.str) = "+"; } + break; + + case 1310: +#line 8410 "gram.y" + { (yyval.str) = "-"; } + break; + + case 1311: +#line 8411 "gram.y" + { (yyval.str) = "*"; } + break; + + case 1312: +#line 8412 "gram.y" + { (yyval.str) = "/"; } + break; + + case 1313: +#line 8413 "gram.y" + { (yyval.str) = "%"; } + break; + + case 1314: +#line 8414 "gram.y" + { (yyval.str) = "^"; } + break; + + case 1315: +#line 8415 "gram.y" + { (yyval.str) = "<"; } + break; + + case 1316: +#line 8416 "gram.y" + { (yyval.str) = ">"; } + break; + + case 1317: +#line 8417 "gram.y" + { (yyval.str) = "="; } + break; + + case 1318: +#line 8421 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 1319: +#line 8423 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1320: +#line 8428 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 1321: +#line 8430 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1322: +#line 8435 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 1323: +#line 8437 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1324: +#line 8439 "gram.y" + { (yyval.list) = list_make1(makeString("~~")); } + break; + + case 1325: +#line 8441 "gram.y" + { (yyval.list) = list_make1(makeString("!~~")); } + break; + + case 1326: +#line 8443 "gram.y" + { (yyval.list) = list_make1(makeString("~~*")); } + break; + + case 1327: +#line 8445 "gram.y" + { (yyval.list) = list_make1(makeString("!~~*")); } + break; + + case 1328: +#line 8457 "gram.y" + { + (yyval.list) = list_make1((yyvsp[0].node)); + } + break; + + case 1329: +#line 8461 "gram.y" + { + (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); + } + break; + + case 1330: +#line 8468 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->val.type = T_String; + n->val.val.str = (yyvsp[-2].str); + (yyval.list) = list_make2((Node *) n, (yyvsp[0].node)); + } + break; + + case 1331: +#line 8474 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1332: +#line 8477 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].typnam)); } + break; + + case 1333: +#line 8478 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].typnam)); } + break; + + case 1334: +#line 8482 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 1335: +#line 8484 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 1336: +#line 8488 "gram.y" + { + ArrayExpr *n = makeNode(ArrayExpr); + n->elements = (yyvsp[-1].list); + (yyval.node) = (Node *)n; + } + break; + + case 1337: +#line 8494 "gram.y" + { + ArrayExpr *n = makeNode(ArrayExpr); + n->elements = (yyvsp[-1].list); + (yyval.node) = (Node *)n; + } + break; + + case 1338: +#line 8506 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1339: +#line 8507 "gram.y" + { (yyval.str) = "year"; } + break; + + case 1340: +#line 8508 "gram.y" + { (yyval.str) = "month"; } + break; + + case 1341: +#line 8509 "gram.y" + { (yyval.str) = "day"; } + break; + + case 1342: +#line 8510 "gram.y" + { (yyval.str) = "hour"; } + break; + + case 1343: +#line 8511 "gram.y" + { (yyval.str) = "minute"; } + break; + + case 1344: +#line 8512 "gram.y" + { (yyval.str) = "second"; } + break; + + case 1345: +#line 8513 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1346: +#line 8523 "gram.y" + { + (yyval.list) = list_make4((yyvsp[-3].node), (yyvsp[-2].node), (yyvsp[-1].node), (yyvsp[0].node)); + } + break; + + case 1347: +#line 8527 "gram.y" + { + (yyval.list) = list_make3((yyvsp[-2].node), (yyvsp[-1].node), (yyvsp[0].node)); + } + break; + + case 1348: +#line 8534 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1349: +#line 8540 "gram.y" + { (yyval.list) = list_make2((yyvsp[0].node), (yyvsp[-2].node)); } + break; + + case 1350: +#line 8541 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1351: +#line 8558 "gram.y" + { + (yyval.list) = list_make3((yyvsp[-2].node), (yyvsp[-1].node), (yyvsp[0].node)); + } + break; + + case 1352: +#line 8562 "gram.y" + { + /* not legal per SQL99, but might as well allow it */ + (yyval.list) = list_make3((yyvsp[-2].node), (yyvsp[0].node), (yyvsp[-1].node)); + } + break; + + case 1353: +#line 8567 "gram.y" + { + (yyval.list) = list_make2((yyvsp[-1].node), (yyvsp[0].node)); + } + break; + + case 1354: +#line 8571 "gram.y" + { + /* + * Since there are no cases where this syntax allows + * a textual FOR value, we forcibly cast the argument + * to int4. The possible matches in pg_proc are + * substring(text,int4) and substring(text,text), + * and we don't want the parser to choose the latter, + * which it is likely to do if the second argument + * is unknown or doesn't have an implicit cast to int4. + */ + A_Const *n = makeNode(A_Const); + n->val.type = T_Integer; + n->val.val.ival = 1; + (yyval.list) = list_make3((yyvsp[-1].node), (Node *) n, + makeTypeCast((yyvsp[0].node), SystemTypeName("int4"))); + } + break; + + case 1355: +#line 8588 "gram.y" + { + (yyval.list) = (yyvsp[0].list); + } + break; + + case 1356: +#line 8592 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1357: +#line 8596 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1358: +#line 8599 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1359: +#line 8602 "gram.y" + { (yyval.list) = lappend((yyvsp[0].list), (yyvsp[-2].node)); } + break; + + case 1360: +#line 8603 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1361: +#line 8604 "gram.y" + { (yyval.list) = (yyvsp[0].list); } + break; + + case 1362: +#line 8608 "gram.y" + { + SubLink *n = makeNode(SubLink); + n->subselect = (yyvsp[0].node); + /* other fields will be filled later */ + (yyval.node) = (Node *)n; + } + break; + + case 1363: +#line 8614 "gram.y" + { (yyval.node) = (Node *)(yyvsp[-1].list); } + break; + + case 1364: +#line 8625 "gram.y" + { + CaseExpr *c = makeNode(CaseExpr); + c->casetype = 0; /* not analyzed yet */ + c->arg = (Expr *) (yyvsp[-3].node); + c->args = (yyvsp[-2].list); + c->defresult = (Expr *) (yyvsp[-1].node); + (yyval.node) = (Node *)c; + } + break; + + case 1365: +#line 8637 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 1366: +#line 8638 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].node)); } + break; + + case 1367: +#line 8643 "gram.y" + { + CaseWhen *w = makeNode(CaseWhen); + w->expr = (Expr *) (yyvsp[-2].node); + w->result = (Expr *) (yyvsp[0].node); + (yyval.node) = (Node *)w; + } + break; + + case 1368: +#line 8652 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1369: +#line 8653 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1370: +#line 8656 "gram.y" + { (yyval.node) = (yyvsp[0].node); } + break; + + case 1371: +#line 8657 "gram.y" + { (yyval.node) = NULL; } + break; + + case 1372: +#line 8666 "gram.y" + { + (yyval.node) = makeColumnRef((yyvsp[0].str), NIL, (yylsp[0])); + } + break; + + case 1373: +#line 8670 "gram.y" + { + (yyval.node) = makeColumnRef((yyvsp[-1].str), (yyvsp[0].list), (yylsp[-1])); + } + break; + + case 1374: +#line 8677 "gram.y" + { + (yyval.node) = (Node *) makeString((yyvsp[0].str)); + } + break; + + case 1375: +#line 8681 "gram.y" + { + (yyval.node) = (Node *) makeString("*"); + } + break; + + case 1376: +#line 8685 "gram.y" + { + A_Indices *ai = makeNode(A_Indices); + ai->lidx = NULL; + ai->uidx = (yyvsp[-1].node); + (yyval.node) = (Node *) ai; + } + break; + + case 1377: +#line 8692 "gram.y" + { + A_Indices *ai = makeNode(A_Indices); + ai->lidx = (yyvsp[-3].node); + ai->uidx = (yyvsp[-1].node); + (yyval.node) = (Node *) ai; + } + break; + + case 1378: +#line 8701 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 1379: +#line 8702 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].node)); } + break; + + case 1380: +#line 8706 "gram.y" + { (yyval.list) = NIL; } + break; + + case 1381: +#line 8707 "gram.y" + { (yyval.list) = lappend((yyvsp[-1].list), (yyvsp[0].node)); } + break; + + case 1384: +#line 8722 "gram.y" + { (yyval.node) = (Node *) (yyvsp[0].node); } + break; + + case 1385: +#line 8723 "gram.y" + { (yyval.node) = (Node *) makeNode(SetToDefault); } + break; + + case 1386: +#line 8727 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].node)); } + break; + + case 1387: +#line 8728 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].node)); } + break; + + case 1388: +#line 8736 "gram.y" + { (yyval.list) = (yyvsp[-1].list); } + break; + + case 1389: +#line 8747 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].target)); } + break; + + case 1390: +#line 8748 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].target)); } + break; + + case 1391: +#line 8753 "gram.y" + { + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = (yyvsp[0].str); + (yyval.target)->indirection = NIL; + (yyval.target)->val = (Node *)(yyvsp[-2].node); + (yyval.target)->location = (yylsp[-2]); + } + break; + + case 1392: +#line 8761 "gram.y" + { + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = NULL; + (yyval.target)->indirection = NIL; + (yyval.target)->val = (Node *)(yyvsp[0].node); + (yyval.target)->location = (yylsp[0]); + } + break; + + case 1393: +#line 8769 "gram.y" + { + ColumnRef *n = makeNode(ColumnRef); + n->fields = list_make1(makeString("*")); + n->location = (yylsp[0]); + + (yyval.target) = makeNode(ResTarget); + (yyval.target)->name = NULL; + (yyval.target)->indirection = NIL; + (yyval.target)->val = (Node *)n; + (yyval.target)->location = (yylsp[0]); + } + break; + + case 1394: +#line 8790 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1395: +#line 8791 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1396: +#line 8795 "gram.y" + { (yyval.list) = list_make1((yyvsp[0].range)); } + break; + + case 1397: +#line 8796 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), (yyvsp[0].range)); } + break; + + case 1398: +#line 8808 "gram.y" + { + (yyval.range) = makeNode(RangeVar); + (yyval.range)->catalogname = NULL; + (yyval.range)->schemaname = NULL; + (yyval.range)->relname = (yyvsp[0].str); + } + break; + + case 1399: +#line 8815 "gram.y" + { + check_qualified_name((yyvsp[0].list)); + (yyval.range) = makeNode(RangeVar); + switch (list_length((yyvsp[0].list))) + { + case 1: + (yyval.range)->catalogname = NULL; + (yyval.range)->schemaname = (yyvsp[-1].str); + (yyval.range)->relname = strVal(linitial((yyvsp[0].list))); + break; + case 2: + (yyval.range)->catalogname = (yyvsp[-1].str); + (yyval.range)->schemaname = strVal(linitial((yyvsp[0].list))); + (yyval.range)->relname = strVal(lsecond((yyvsp[0].list))); + break; + default: + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(lcons(makeString((yyvsp[-1].str)), (yyvsp[0].list)))))); + break; + } + } + break; + + case 1400: +#line 8841 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 1401: +#line 8843 "gram.y" + { (yyval.list) = lappend((yyvsp[-2].list), makeString((yyvsp[0].str))); } + break; + + case 1402: +#line 8847 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1403: +#line 8850 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1404: +#line 8853 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1405: +#line 8855 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1406: +#line 8857 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1407: +#line 8859 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1408: +#line 8870 "gram.y" + { (yyval.list) = list_make1(makeString((yyvsp[0].str))); } + break; + + case 1409: +#line 8872 "gram.y" + { (yyval.list) = check_func_name(lcons(makeString((yyvsp[-1].str)), (yyvsp[0].list))); } + break; + + case 1410: +#line 8880 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->val.type = T_Integer; + n->val.val.ival = (yyvsp[0].ival); + (yyval.node) = (Node *)n; + } + break; + + case 1411: +#line 8887 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->val.type = T_Float; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1412: +#line 8894 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->val.type = T_String; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1413: +#line 8901 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->val.type = T_BitString; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1414: +#line 8908 "gram.y" + { + /* This is a bit constant per SQL99: + * Without Feature F511, "BIT data type", + * a shall not be a + * or a . + */ + A_Const *n = makeNode(A_Const); + n->val.type = T_BitString; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1415: +#line 8920 "gram.y" + { + /* generic type 'literal' syntax */ + A_Const *n = makeNode(A_Const); + n->typename = makeTypeNameFromNameList((yyvsp[-1].list)); + n->typename->location = (yylsp[-1]); + n->val.type = T_String; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1416: +#line 8930 "gram.y" + { + /* generic syntax with a type modifier */ + A_Const *n = makeNode(A_Const); + n->typename = makeTypeNameFromNameList((yyvsp[-4].list)); + n->typename->typmods = (yyvsp[-2].list); + n->typename->location = (yylsp[-4]); + n->val.type = T_String; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1417: +#line 8941 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->typename = (yyvsp[-1].typnam); + n->val.type = T_String; + n->val.val.str = (yyvsp[0].str); + (yyval.node) = (Node *)n; + } + break; + + case 1418: +#line 8949 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->typename = (yyvsp[-2].typnam); + n->val.type = T_String; + n->val.val.str = (yyvsp[-1].str); + /* precision is not specified, but fields may be... */ + if ((yyvsp[0].ival) != INTERVAL_FULL_RANGE) + n->typename->typmods = list_make1(makeIntConst((yyvsp[0].ival))); + (yyval.node) = (Node *)n; + } + break; + + case 1419: +#line 8960 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->typename = (yyvsp[-5].typnam); + n->val.type = T_String; + n->val.val.str = (yyvsp[-1].str); + n->typename->typmods = list_make2(makeIntConst((yyvsp[0].ival)), + makeIntConst((yyvsp[-3].ival))); + (yyval.node) = (Node *)n; + } + break; + + case 1420: +#line 8970 "gram.y" + { + (yyval.node) = (Node *)makeBoolAConst(TRUE); + } + break; + + case 1421: +#line 8974 "gram.y" + { + (yyval.node) = (Node *)makeBoolAConst(FALSE); + } + break; + + case 1422: +#line 8978 "gram.y" + { + A_Const *n = makeNode(A_Const); + n->val.type = T_Null; + (yyval.node) = (Node *)n; + } + break; + + case 1423: +#line 8985 "gram.y" + { (yyval.ival) = (yyvsp[0].ival); } + break; + + case 1424: +#line 8986 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1425: +#line 8987 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1426: +#line 8989 "gram.y" + { (yyval.ival) = (yyvsp[0].ival); } + break; + + case 1427: +#line 8990 "gram.y" + { (yyval.ival) = - (yyvsp[0].ival); } + break; + + case 1428: +#line 9006 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1429: +#line 9007 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1430: +#line 9008 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1431: +#line 9013 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1432: +#line 9014 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1433: +#line 9015 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1434: +#line 9021 "gram.y" + { (yyval.str) = (yyvsp[0].str); } + break; + + case 1435: +#line 9022 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1436: +#line 9023 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1437: +#line 9024 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1438: +#line 9025 "gram.y" + { (yyval.str) = pstrdup((yyvsp[0].keyword)); } + break; + + case 1811: +#line 9457 "gram.y" + { + if (QueryIsRule) + (yyval.str) = "*OLD*"; + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("OLD used in query that is not in a rule"))); + } + break; + + case 1812: +#line 9466 "gram.y" + { + if (QueryIsRule) + (yyval.str) = "*NEW*"; + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("NEW used in query that is not in a rule"))); + } + break; + + + default: break; + } + +/* Line 1126 of yacc.c. */ +#line 25035 "gram.c" + + yyvsp -= yylen; + yyssp -= yylen; + yylsp -= yylen; + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + char *yymsg = 0; +# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +#if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +#endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= yysize1 < yysize; + yysize = yysize1; + + if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yymsg; + int yyi = 0; + while ((*yyp = *yyf)) + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + { + yyerror (YY_("syntax error")); + goto yyexhaustedlab; + } + } + else +#endif /* YYERROR_VERBOSE */ + yyerror (YY_("syntax error")); + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + yylsp -= yylen; + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the look-ahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp); + YYPOPSTACK; + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 9476 "gram.y" + + +static Node * +makeColumnRef(char *relname, List *indirection, int location) +{ + /* + * Generate a ColumnRef node, with an A_Indirection node added if there + * is any subscripting in the specified indirection list. However, + * any field selection at the start of the indirection list must be + * transposed into the "fields" part of the ColumnRef node. + */ + ColumnRef *c = makeNode(ColumnRef); + int nfields = 0; + ListCell *l; + + c->location = location; + foreach(l, indirection) + { + if (IsA(lfirst(l), A_Indices)) + { + A_Indirection *i = makeNode(A_Indirection); + + if (nfields == 0) + { + /* easy case - all indirection goes to A_Indirection */ + c->fields = list_make1(makeString(relname)); + i->indirection = indirection; + } + else + { + /* got to split the list in two */ + i->indirection = list_copy_tail(indirection, nfields); + indirection = list_truncate(indirection, nfields); + c->fields = lcons(makeString(relname), indirection); + } + i->arg = (Node *) c; + return (Node *) i; + } + nfields++; + } + /* No subscripting, so all indirection gets added to field list */ + c->fields = lcons(makeString(relname), indirection); + return (Node *) c; +} + +static Node * +makeTypeCast(Node *arg, TypeName *typename) +{ + /* + * Simply generate a TypeCast node. + * + * Earlier we would determine whether an A_Const would + * be acceptable, however Domains require coerce_type() + * to process them -- applying constraints as required. + */ + TypeCast *n = makeNode(TypeCast); + n->arg = arg; + n->typename = typename; + return (Node *) n; +} + +static Node * +makeStringConst(char *str, TypeName *typename) +{ + A_Const *n = makeNode(A_Const); + + n->val.type = T_String; + n->val.val.str = str; + n->typename = typename; + + return (Node *)n; +} + +static Node * +makeIntConst(int val) +{ + A_Const *n = makeNode(A_Const); + n->val.type = T_Integer; + n->val.val.ival = val; + n->typename = SystemTypeName("int4"); + + return (Node *)n; +} + +static Node * +makeFloatConst(char *str) +{ + A_Const *n = makeNode(A_Const); + + n->val.type = T_Float; + n->val.val.str = str; + n->typename = SystemTypeName("float8"); + + return (Node *)n; +} + +static Node * +makeAConst(Value *v) +{ + Node *n; + + switch (v->type) + { + case T_Float: + n = makeFloatConst(v->val.str); + break; + + case T_Integer: + n = makeIntConst(v->val.ival); + break; + + case T_String: + default: + n = makeStringConst(v->val.str, NULL); + break; + } + + return n; +} + +/* makeBoolAConst() + * Create an A_Const node and initialize to a boolean constant. + */ +static A_Const * +makeBoolAConst(bool state) +{ + A_Const *n = makeNode(A_Const); + n->val.type = T_String; + n->val.val.str = (state? "t": "f"); + n->typename = SystemTypeName("bool"); + return n; +} + +/* makeOverlaps() + * Create and populate a FuncCall node to support the OVERLAPS operator. + */ +static FuncCall * +makeOverlaps(List *largs, List *rargs, int location) +{ + FuncCall *n = makeNode(FuncCall); + + n->funcname = SystemFuncName("overlaps"); + if (list_length(largs) == 1) + largs = lappend(largs, largs); + else if (list_length(largs) != 2) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("wrong number of parameters on left side of OVERLAPS expression"))); + if (list_length(rargs) == 1) + rargs = lappend(rargs, rargs); + else if (list_length(rargs) != 2) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("wrong number of parameters on right side of OVERLAPS expression"))); + n->args = list_concat(largs, rargs); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = location; + return n; +} + +/* check_qualified_name --- check the result of qualified_name production + * + * It's easiest to let the grammar production for qualified_name allow + * subscripts and '*', which we then must reject here. + */ +static void +check_qualified_name(List *names) +{ + ListCell *i; + + foreach(i, names) + { + if (!IsA(lfirst(i), String)) + yyerror("syntax error"); + else if (strcmp(strVal(lfirst(i)), "*") == 0) + yyerror("syntax error"); + } +} + +/* check_func_name --- check the result of func_name production + * + * It's easiest to let the grammar production for func_name allow subscripts + * and '*', which we then must reject here. + */ +static List * +check_func_name(List *names) +{ + ListCell *i; + + foreach(i, names) + { + if (!IsA(lfirst(i), String)) + yyerror("syntax error"); + else if (strcmp(strVal(lfirst(i)), "*") == 0) + yyerror("syntax error"); + } + return names; +} + +/* extractArgTypes() + * Given a list of FunctionParameter nodes, extract a list of just the + * argument types (TypeNames) for input parameters only. This is what + * is needed to look up an existing function, which is what is wanted by + * the productions that use this call. + */ +static List * +extractArgTypes(List *parameters) +{ + List *result = NIL; + ListCell *i; + + foreach(i, parameters) + { + FunctionParameter *p = (FunctionParameter *) lfirst(i); + + if (p->mode != FUNC_PARAM_OUT) /* keep if IN or INOUT */ + result = lappend(result, p->argType); + } + return result; +} + +/* findLeftmostSelect() + * Find the leftmost component SelectStmt in a set-operation parsetree. + */ +static SelectStmt * +findLeftmostSelect(SelectStmt *node) +{ + while (node && node->op != SETOP_NONE) + node = node->larg; + return node; +} + +/* insertSelectOptions() + * Insert ORDER BY, etc into an already-constructed SelectStmt. + * + * This routine is just to avoid duplicating code in SelectStmt productions. + */ +static void +insertSelectOptions(SelectStmt *stmt, + List *sortClause, List *lockingClause, + Node *limitOffset, Node *limitCount) +{ + /* + * Tests here are to reject constructs like + * (SELECT foo ORDER BY bar) ORDER BY baz + */ + if (sortClause) + { + if (stmt->sortClause) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple ORDER BY clauses not allowed"))); + stmt->sortClause = sortClause; + } + /* We can handle multiple locking clauses, though */ + stmt->lockingClause = list_concat(stmt->lockingClause, lockingClause); + if (limitOffset) + { + if (stmt->limitOffset) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple OFFSET clauses not allowed"))); + stmt->limitOffset = limitOffset; + } + if (limitCount) + { + if (stmt->limitCount) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple LIMIT clauses not allowed"))); + stmt->limitCount = limitCount; + } +} + +static Node * +makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg) +{ + SelectStmt *n = makeNode(SelectStmt); + + n->op = op; + n->all = all; + n->larg = (SelectStmt *) larg; + n->rarg = (SelectStmt *) rarg; + return (Node *) n; +} + +/* SystemFuncName() + * Build a properly-qualified reference to a built-in function. + */ +List * +SystemFuncName(char *name) +{ + return list_make1(makeString(name)); +} + +/* SystemTypeName() + * Build a properly-qualified reference to a built-in type. + * + * typmod is defaulted, but may be changed afterwards by caller. + */ +TypeName * +SystemTypeName(char *name) +{ + return makeTypeNameFromNameList(list_make1(makeString(name))); +} + +/* parser_init() + * Initialize to parse one query string + */ +void +parser_init(void) +{ + QueryIsRule = FALSE; +} + +/* exprIsNullConstant() + * Test whether an a_expr is a plain NULL constant or not. + */ +bool +exprIsNullConstant(Node *arg) +{ + if (arg && IsA(arg, A_Const)) + { + A_Const *con = (A_Const *) arg; + + if (con->val.type == T_Null && + con->typename == NULL) + return TRUE; + } + return FALSE; +} + +/* doNegate() + * Handle negation of a numeric constant. + * + * Formerly, we did this here because the optimizer couldn't cope with + * indexquals that looked like "var = -4" --- it wants "var = const" + * and a unary minus operator applied to a constant didn't qualify. + * As of Postgres 7.0, that problem doesn't exist anymore because there + * is a constant-subexpression simplifier in the optimizer. However, + * there's still a good reason for doing this here, which is that we can + * postpone committing to a particular internal representation for simple + * negative constants. It's better to leave "-123.456" in string form + * until we know what the desired type is. + */ +static Node * +doNegate(Node *n, int location) +{ + if (IsA(n, A_Const)) + { + A_Const *con = (A_Const *)n; + + if (con->val.type == T_Integer) + { + con->val.val.ival = -con->val.val.ival; + return n; + } + if (con->val.type == T_Float) + { + doNegateFloat(&con->val); + return n; + } + } + + return (Node *) makeSimpleA_Expr(AEXPR_OP, "-", NULL, n, location); +} + +static void +doNegateFloat(Value *v) +{ + char *oldval = v->val.str; + + if (*oldval == '+') + oldval++; + if (*oldval == '-') + v->val.str = oldval+1; /* just strip the '-' */ + else + { + char *newval = (char *) palloc(strlen(oldval) + 2); + + *newval = '-'; + strcpy(newval+1, oldval); + v->val.str = newval; + } +} + +static Node * +makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args) +{ + XmlExpr *x = makeNode(XmlExpr); + + x->op = op; + x->name = name; + /* + * named_args is a list of ResTarget; it'll be split apart into separate + * expression and name lists in transformXmlExpr(). + */ + x->named_args = named_args; + x->arg_names = NIL; + x->args = args; + return (Node *) x; +} + +/* + * Create a DefElem setting "oids" to the specified value. + */ +static DefElem * +defWithOids(bool value) +{ + DefElem *f = makeNode(DefElem); + + f->defname = "oids"; + f->arg = (Node *) makeInteger(value); + return f; +} + + + +#undef yylex + + +/* + * Must undefine base_yylex before including scan.c, since we want it + * to create the function base_yylex not filtered_base_yylex. + */ +#undef base_yylex + +#include "scan.c" + diff --git a/parser/gram.h b/parser/gram.h new file mode 100644 index 0000000..31682e4 --- /dev/null +++ b/parser/gram.h @@ -0,0 +1,873 @@ +/* A Bison parser, made by GNU Bison 2.1. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + + 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, 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. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ABORT_P = 258, + ABSOLUTE_P = 259, + ACCESS = 260, + ACTION = 261, + ADD_P = 262, + ADMIN = 263, + AFTER = 264, + AGGREGATE = 265, + ALL = 266, + ALSO = 267, + ALTER = 268, + ALWAYS = 269, + ANALYSE = 270, + ANALYZE = 271, + AND = 272, + ANY = 273, + ARRAY = 274, + AS = 275, + ASC = 276, + ASSERTION = 277, + ASSIGNMENT = 278, + ASYMMETRIC = 279, + AT = 280, + AUTHORIZATION = 281, + BACKWARD = 282, + BEFORE = 283, + BEGIN_P = 284, + BETWEEN = 285, + BIGINT = 286, + BINARY = 287, + BIT = 288, + BOOLEAN_P = 289, + BOTH = 290, + BY = 291, + CACHE = 292, + CALLED = 293, + CASCADE = 294, + CASCADED = 295, + CASE = 296, + CAST = 297, + CHAIN = 298, + CHAR_P = 299, + CHARACTER = 300, + CHARACTERISTICS = 301, + CHECK = 302, + CHECKPOINT = 303, + CLASS = 304, + CLOSE = 305, + CLUSTER = 306, + COALESCE = 307, + COLLATE = 308, + COLUMN = 309, + COMMENT = 310, + COMMIT = 311, + COMMITTED = 312, + CONCURRENTLY = 313, + CONFIGURATION = 314, + CONNECTION = 315, + CONSTRAINT = 316, + CONSTRAINTS = 317, + CONTENT_P = 318, + CONVERSION_P = 319, + COPY = 320, + COST = 321, + CREATE = 322, + CREATEDB = 323, + CREATEROLE = 324, + CREATEUSER = 325, + CROSS = 326, + CSV = 327, + CURRENT_P = 328, + CURRENT_DATE = 329, + CURRENT_ROLE = 330, + CURRENT_TIME = 331, + CURRENT_TIMESTAMP = 332, + CURRENT_USER = 333, + CURSOR = 334, + CYCLE = 335, + DATABASE = 336, + DAY_P = 337, + DEALLOCATE = 338, + DEC = 339, + DECIMAL_P = 340, + DECLARE = 341, + DEFAULT = 342, + DEFAULTS = 343, + DEFERRABLE = 344, + DEFERRED = 345, + DEFINER = 346, + DELETE_P = 347, + DELIMITER = 348, + DELIMITERS = 349, + DESC = 350, + DICTIONARY = 351, + DISABLE_P = 352, + DISCARD = 353, + DISTINCT = 354, + DO = 355, + DOCUMENT_P = 356, + DOMAIN_P = 357, + DOUBLE_P = 358, + DROP = 359, + EACH = 360, + ELSE = 361, + ENABLE_P = 362, + ENCODING = 363, + ENCRYPTED = 364, + END_P = 365, + ENUM_P = 366, + ESCAPE = 367, + EXCEPT = 368, + EXCLUDING = 369, + EXCLUSIVE = 370, + EXECUTE = 371, + EXISTS = 372, + EXPLAIN = 373, + EXTERNAL = 374, + EXTRACT = 375, + FALSE_P = 376, + FAMILY = 377, + FETCH = 378, + FIRST_P = 379, + FLOAT_P = 380, + FOR = 381, + FORCE = 382, + FOREIGN = 383, + FORWARD = 384, + FREEZE = 385, + FROM = 386, + FULL = 387, + FUNCTION = 388, + GLOBAL = 389, + GRANT = 390, + GRANTED = 391, + GREATEST = 392, + GROUP_P = 393, + HANDLER = 394, + HAVING = 395, + HEADER_P = 396, + HOLD = 397, + HOUR_P = 398, + IF_P = 399, + ILIKE = 400, + IMMEDIATE = 401, + IMMUTABLE = 402, + IMPLICIT_P = 403, + IN_P = 404, + INCLUDING = 405, + INCREMENT = 406, + INDEX = 407, + INDEXES = 408, + INHERIT = 409, + INHERITS = 410, + INITIALLY = 411, + INNER_P = 412, + INOUT = 413, + INPUT_P = 414, + INSENSITIVE = 415, + INSERT = 416, + INSTEAD = 417, + INT_P = 418, + INTEGER = 419, + INTERSECT = 420, + INTERVAL = 421, + INTO = 422, + INVOKER = 423, + IS = 424, + ISNULL = 425, + ISOLATION = 426, + JOIN = 427, + KEY = 428, + LANCOMPILER = 429, + LANGUAGE = 430, + LARGE_P = 431, + LAST_P = 432, + LEADING = 433, + LEAST = 434, + LEFT = 435, + LEVEL = 436, + LIKE = 437, + LIMIT = 438, + LISTEN = 439, + LOAD = 440, + LOCAL = 441, + LOCALTIME = 442, + LOCALTIMESTAMP = 443, + LOCATION = 444, + LOCK_P = 445, + LOGIN_P = 446, + MAPPING = 447, + MATCH = 448, + MAXVALUE = 449, + MINUTE_P = 450, + MINVALUE = 451, + MODE = 452, + MONTH_P = 453, + MOVE = 454, + NAME_P = 455, + NAMES = 456, + NATIONAL = 457, + NATURAL = 458, + NCHAR = 459, + NEW = 460, + NEXT = 461, + NO = 462, + NOCREATEDB = 463, + NOCREATEROLE = 464, + NOCREATEUSER = 465, + NOINHERIT = 466, + NOLOGIN_P = 467, + NONE = 468, + NOSUPERUSER = 469, + NOT = 470, + NOTHING = 471, + NOTIFY = 472, + NOTNULL = 473, + NOWAIT = 474, + NULL_P = 475, + NULLIF = 476, + NULLS_P = 477, + NUMERIC = 478, + OBJECT_P = 479, + OF = 480, + OFF = 481, + OFFSET = 482, + OIDS = 483, + OLD = 484, + ON = 485, + ONLY = 486, + OPERATOR = 487, + OPTION = 488, + OR = 489, + ORDER = 490, + OUT_P = 491, + OUTER_P = 492, + OVERLAPS = 493, + OVERLAY = 494, + OWNED = 495, + OWNER = 496, + PARSER = 497, + PARTIAL = 498, + PASSWORD = 499, + PLACING = 500, + PLANS = 501, + POSITION = 502, + PRECISION = 503, + PRESERVE = 504, + PREPARE = 505, + PREPARED = 506, + PRIMARY = 507, + PRIOR = 508, + PRIVILEGES = 509, + PROCEDURAL = 510, + PROCEDURE = 511, + QUOTE = 512, + READ = 513, + REAL = 514, + REASSIGN = 515, + RECHECK = 516, + REFERENCES = 517, + REINDEX = 518, + RELATIVE_P = 519, + RELEASE = 520, + RENAME = 521, + REPEATABLE = 522, + REPLACE = 523, + REPLICA = 524, + RESET = 525, + RESTART = 526, + RESTRICT = 527, + RETURNING = 528, + RETURNS = 529, + REVOKE = 530, + RIGHT = 531, + ROLE = 532, + ROLLBACK = 533, + ROW = 534, + ROWS = 535, + RULE = 536, + SAVEPOINT = 537, + SCHEMA = 538, + SCROLL = 539, + SEARCH = 540, + SECOND_P = 541, + SECURITY = 542, + SELECT = 543, + SEQUENCE = 544, + SERIALIZABLE = 545, + SESSION = 546, + SESSION_USER = 547, + SET = 548, + SETOF = 549, + SHARE = 550, + SHOW = 551, + SIMILAR = 552, + SIMPLE = 553, + SMALLINT = 554, + SOME = 555, + STABLE = 556, + STANDALONE_P = 557, + START = 558, + STATEMENT = 559, + STATISTICS = 560, + STDIN = 561, + STDOUT = 562, + STORAGE = 563, + STRICT_P = 564, + STRIP_P = 565, + SUBSTRING = 566, + SUPERUSER_P = 567, + SYMMETRIC = 568, + SYSID = 569, + SYSTEM_P = 570, + TABLE = 571, + TABLESPACE = 572, + TEMP = 573, + TEMPLATE = 574, + TEMPORARY = 575, + TEXT_P = 576, + THEN = 577, + TIME = 578, + TIMESTAMP = 579, + TO = 580, + TRAILING = 581, + TRANSACTION = 582, + TREAT = 583, + TRIGGER = 584, + TRIM = 585, + TRUE_P = 586, + TRUNCATE = 587, + TRUSTED = 588, + TYPE_P = 589, + UNCOMMITTED = 590, + UNENCRYPTED = 591, + UNION = 592, + UNIQUE = 593, + UNKNOWN = 594, + UNLISTEN = 595, + UNTIL = 596, + UPDATE = 597, + USER = 598, + USING = 599, + VACUUM = 600, + VALID = 601, + VALIDATOR = 602, + VALUE_P = 603, + VALUES = 604, + VARCHAR = 605, + VARYING = 606, + VERBOSE = 607, + VERSION_P = 608, + VIEW = 609, + VOLATILE = 610, + WHEN = 611, + WHERE = 612, + WHITESPACE_P = 613, + WITH = 614, + WITHOUT = 615, + WORK = 616, + WRITE = 617, + XML_P = 618, + XMLATTRIBUTES = 619, + XMLCONCAT = 620, + XMLELEMENT = 621, + XMLFOREST = 622, + XMLPARSE = 623, + XMLPI = 624, + XMLROOT = 625, + XMLSERIALIZE = 626, + YEAR_P = 627, + YES_P = 628, + ZONE = 629, + NULLS_FIRST = 630, + NULLS_LAST = 631, + WITH_CASCADED = 632, + WITH_LOCAL = 633, + WITH_CHECK = 634, + IDENT = 635, + FCONST = 636, + SCONST = 637, + BCONST = 638, + XCONST = 639, + Op = 640, + ICONST = 641, + PARAM = 642, + POSTFIXOP = 643, + UMINUS = 644, + TYPECAST = 645 + }; +#endif +/* Tokens. */ +#define ABORT_P 258 +#define ABSOLUTE_P 259 +#define ACCESS 260 +#define ACTION 261 +#define ADD_P 262 +#define ADMIN 263 +#define AFTER 264 +#define AGGREGATE 265 +#define ALL 266 +#define ALSO 267 +#define ALTER 268 +#define ALWAYS 269 +#define ANALYSE 270 +#define ANALYZE 271 +#define AND 272 +#define ANY 273 +#define ARRAY 274 +#define AS 275 +#define ASC 276 +#define ASSERTION 277 +#define ASSIGNMENT 278 +#define ASYMMETRIC 279 +#define AT 280 +#define AUTHORIZATION 281 +#define BACKWARD 282 +#define BEFORE 283 +#define BEGIN_P 284 +#define BETWEEN 285 +#define BIGINT 286 +#define BINARY 287 +#define BIT 288 +#define BOOLEAN_P 289 +#define BOTH 290 +#define BY 291 +#define CACHE 292 +#define CALLED 293 +#define CASCADE 294 +#define CASCADED 295 +#define CASE 296 +#define CAST 297 +#define CHAIN 298 +#define CHAR_P 299 +#define CHARACTER 300 +#define CHARACTERISTICS 301 +#define CHECK 302 +#define CHECKPOINT 303 +#define CLASS 304 +#define CLOSE 305 +#define CLUSTER 306 +#define COALESCE 307 +#define COLLATE 308 +#define COLUMN 309 +#define COMMENT 310 +#define COMMIT 311 +#define COMMITTED 312 +#define CONCURRENTLY 313 +#define CONFIGURATION 314 +#define CONNECTION 315 +#define CONSTRAINT 316 +#define CONSTRAINTS 317 +#define CONTENT_P 318 +#define CONVERSION_P 319 +#define COPY 320 +#define COST 321 +#define CREATE 322 +#define CREATEDB 323 +#define CREATEROLE 324 +#define CREATEUSER 325 +#define CROSS 326 +#define CSV 327 +#define CURRENT_P 328 +#define CURRENT_DATE 329 +#define CURRENT_ROLE 330 +#define CURRENT_TIME 331 +#define CURRENT_TIMESTAMP 332 +#define CURRENT_USER 333 +#define CURSOR 334 +#define CYCLE 335 +#define DATABASE 336 +#define DAY_P 337 +#define DEALLOCATE 338 +#define DEC 339 +#define DECIMAL_P 340 +#define DECLARE 341 +#define DEFAULT 342 +#define DEFAULTS 343 +#define DEFERRABLE 344 +#define DEFERRED 345 +#define DEFINER 346 +#define DELETE_P 347 +#define DELIMITER 348 +#define DELIMITERS 349 +#define DESC 350 +#define DICTIONARY 351 +#define DISABLE_P 352 +#define DISCARD 353 +#define DISTINCT 354 +#define DO 355 +#define DOCUMENT_P 356 +#define DOMAIN_P 357 +#define DOUBLE_P 358 +#define DROP 359 +#define EACH 360 +#define ELSE 361 +#define ENABLE_P 362 +#define ENCODING 363 +#define ENCRYPTED 364 +#define END_P 365 +#define ENUM_P 366 +#define ESCAPE 367 +#define EXCEPT 368 +#define EXCLUDING 369 +#define EXCLUSIVE 370 +#define EXECUTE 371 +#define EXISTS 372 +#define EXPLAIN 373 +#define EXTERNAL 374 +#define EXTRACT 375 +#define FALSE_P 376 +#define FAMILY 377 +#define FETCH 378 +#define FIRST_P 379 +#define FLOAT_P 380 +#define FOR 381 +#define FORCE 382 +#define FOREIGN 383 +#define FORWARD 384 +#define FREEZE 385 +#define FROM 386 +#define FULL 387 +#define FUNCTION 388 +#define GLOBAL 389 +#define GRANT 390 +#define GRANTED 391 +#define GREATEST 392 +#define GROUP_P 393 +#define HANDLER 394 +#define HAVING 395 +#define HEADER_P 396 +#define HOLD 397 +#define HOUR_P 398 +#define IF_P 399 +#define ILIKE 400 +#define IMMEDIATE 401 +#define IMMUTABLE 402 +#define IMPLICIT_P 403 +#define IN_P 404 +#define INCLUDING 405 +#define INCREMENT 406 +#define INDEX 407 +#define INDEXES 408 +#define INHERIT 409 +#define INHERITS 410 +#define INITIALLY 411 +#define INNER_P 412 +#define INOUT 413 +#define INPUT_P 414 +#define INSENSITIVE 415 +#define INSERT 416 +#define INSTEAD 417 +#define INT_P 418 +#define INTEGER 419 +#define INTERSECT 420 +#define INTERVAL 421 +#define INTO 422 +#define INVOKER 423 +#define IS 424 +#define ISNULL 425 +#define ISOLATION 426 +#define JOIN 427 +#define KEY 428 +#define LANCOMPILER 429 +#define LANGUAGE 430 +#define LARGE_P 431 +#define LAST_P 432 +#define LEADING 433 +#define LEAST 434 +#define LEFT 435 +#define LEVEL 436 +#define LIKE 437 +#define LIMIT 438 +#define LISTEN 439 +#define LOAD 440 +#define LOCAL 441 +#define LOCALTIME 442 +#define LOCALTIMESTAMP 443 +#define LOCATION 444 +#define LOCK_P 445 +#define LOGIN_P 446 +#define MAPPING 447 +#define MATCH 448 +#define MAXVALUE 449 +#define MINUTE_P 450 +#define MINVALUE 451 +#define MODE 452 +#define MONTH_P 453 +#define MOVE 454 +#define NAME_P 455 +#define NAMES 456 +#define NATIONAL 457 +#define NATURAL 458 +#define NCHAR 459 +#define NEW 460 +#define NEXT 461 +#define NO 462 +#define NOCREATEDB 463 +#define NOCREATEROLE 464 +#define NOCREATEUSER 465 +#define NOINHERIT 466 +#define NOLOGIN_P 467 +#define NONE 468 +#define NOSUPERUSER 469 +#define NOT 470 +#define NOTHING 471 +#define NOTIFY 472 +#define NOTNULL 473 +#define NOWAIT 474 +#define NULL_P 475 +#define NULLIF 476 +#define NULLS_P 477 +#define NUMERIC 478 +#define OBJECT_P 479 +#define OF 480 +#define OFF 481 +#define OFFSET 482 +#define OIDS 483 +#define OLD 484 +#define ON 485 +#define ONLY 486 +#define OPERATOR 487 +#define OPTION 488 +#define OR 489 +#define ORDER 490 +#define OUT_P 491 +#define OUTER_P 492 +#define OVERLAPS 493 +#define OVERLAY 494 +#define OWNED 495 +#define OWNER 496 +#define PARSER 497 +#define PARTIAL 498 +#define PASSWORD 499 +#define PLACING 500 +#define PLANS 501 +#define POSITION 502 +#define PRECISION 503 +#define PRESERVE 504 +#define PREPARE 505 +#define PREPARED 506 +#define PRIMARY 507 +#define PRIOR 508 +#define PRIVILEGES 509 +#define PROCEDURAL 510 +#define PROCEDURE 511 +#define QUOTE 512 +#define READ 513 +#define REAL 514 +#define REASSIGN 515 +#define RECHECK 516 +#define REFERENCES 517 +#define REINDEX 518 +#define RELATIVE_P 519 +#define RELEASE 520 +#define RENAME 521 +#define REPEATABLE 522 +#define REPLACE 523 +#define REPLICA 524 +#define RESET 525 +#define RESTART 526 +#define RESTRICT 527 +#define RETURNING 528 +#define RETURNS 529 +#define REVOKE 530 +#define RIGHT 531 +#define ROLE 532 +#define ROLLBACK 533 +#define ROW 534 +#define ROWS 535 +#define RULE 536 +#define SAVEPOINT 537 +#define SCHEMA 538 +#define SCROLL 539 +#define SEARCH 540 +#define SECOND_P 541 +#define SECURITY 542 +#define SELECT 543 +#define SEQUENCE 544 +#define SERIALIZABLE 545 +#define SESSION 546 +#define SESSION_USER 547 +#define SET 548 +#define SETOF 549 +#define SHARE 550 +#define SHOW 551 +#define SIMILAR 552 +#define SIMPLE 553 +#define SMALLINT 554 +#define SOME 555 +#define STABLE 556 +#define STANDALONE_P 557 +#define START 558 +#define STATEMENT 559 +#define STATISTICS 560 +#define STDIN 561 +#define STDOUT 562 +#define STORAGE 563 +#define STRICT_P 564 +#define STRIP_P 565 +#define SUBSTRING 566 +#define SUPERUSER_P 567 +#define SYMMETRIC 568 +#define SYSID 569 +#define SYSTEM_P 570 +#define TABLE 571 +#define TABLESPACE 572 +#define TEMP 573 +#define TEMPLATE 574 +#define TEMPORARY 575 +#define TEXT_P 576 +#define THEN 577 +#define TIME 578 +#define TIMESTAMP 579 +#define TO 580 +#define TRAILING 581 +#define TRANSACTION 582 +#define TREAT 583 +#define TRIGGER 584 +#define TRIM 585 +#define TRUE_P 586 +#define TRUNCATE 587 +#define TRUSTED 588 +#define TYPE_P 589 +#define UNCOMMITTED 590 +#define UNENCRYPTED 591 +#define UNION 592 +#define UNIQUE 593 +#define UNKNOWN 594 +#define UNLISTEN 595 +#define UNTIL 596 +#define UPDATE 597 +#define USER 598 +#define USING 599 +#define VACUUM 600 +#define VALID 601 +#define VALIDATOR 602 +#define VALUE_P 603 +#define VALUES 604 +#define VARCHAR 605 +#define VARYING 606 +#define VERBOSE 607 +#define VERSION_P 608 +#define VIEW 609 +#define VOLATILE 610 +#define WHEN 611 +#define WHERE 612 +#define WHITESPACE_P 613 +#define WITH 614 +#define WITHOUT 615 +#define WORK 616 +#define WRITE 617 +#define XML_P 618 +#define XMLATTRIBUTES 619 +#define XMLCONCAT 620 +#define XMLELEMENT 621 +#define XMLFOREST 622 +#define XMLPARSE 623 +#define XMLPI 624 +#define XMLROOT 625 +#define XMLSERIALIZE 626 +#define YEAR_P 627 +#define YES_P 628 +#define ZONE 629 +#define NULLS_FIRST 630 +#define NULLS_LAST 631 +#define WITH_CASCADED 632 +#define WITH_LOCAL 633 +#define WITH_CHECK 634 +#define IDENT 635 +#define FCONST 636 +#define SCONST 637 +#define BCONST 638 +#define XCONST 639 +#define Op 640 +#define ICONST 641 +#define PARAM 642 +#define POSTFIXOP 643 +#define UMINUS 644 +#define TYPECAST 645 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 146 "gram.y" +typedef union YYSTYPE { + int ival; + char chr; + char *str; + const char *keyword; + bool boolean; + JoinType jtype; + DropBehavior dbehavior; + OnCommitAction oncommit; + List *list; + Node *node; + Value *value; + ObjectType objtype; + + TypeName *typnam; + FunctionParameter *fun_param; + FunctionParameterMode fun_param_mode; + FuncWithArgs *funwithargs; + DefElem *defelt; + SortBy *sortby; + JoinExpr *jexpr; + IndexElem *ielem; + Alias *alias; + RangeVar *range; + IntoClause *into; + A_Indices *aind; + ResTarget *target; + PrivTarget *privtarget; + + InsertStmt *istmt; + VariableSetStmt *vsetstmt; +} YYSTYPE; +/* Line 1447 of yacc.c. */ +#line 851 "gram.h" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE base_yylval; + +#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + +extern YYLTYPE base_yylloc; + + diff --git a/parser/gram.y b/parser/gram.y new file mode 100644 index 0000000..df44903 --- /dev/null +++ b/parser/gram.y @@ -0,0 +1,9904 @@ +%{ + +/*#define YYDEBUG 1*/ +/*------------------------------------------------------------------------- + * + * gram.y + * POSTGRES SQL YACC rules/actions + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.603 2007/09/24 01:29:28 adunstan Exp $ + * + * HISTORY + * AUTHOR DATE MAJOR EVENT + * Andrew Yu Sept, 1994 POSTQUEL to SQL conversion + * Andrew Yu Oct, 1994 lispy code conversion + * + * NOTES + * CAPITALS are used to represent terminal symbols. + * non-capitals are used to represent non-terminals. + * SQL92-specific syntax is separated from plain SQL/Postgres syntax + * to help isolate the non-extensible portions of the parser. + * + * In general, nothing in this file should initiate database accesses + * nor depend on changeable state (such as SET variables). If you do + * database accesses, your code will fail when we have aborted the + * current transaction and are just parsing commands to find the next + * ROLLBACK or COMMIT. If you make use of SET variables, then you + * will do the wrong thing in multi-query strings like this: + * SET SQL_inheritance TO off; SELECT * FROM foo; + * because the entire string is parsed by gram.y before the SET gets + * executed. Anything that depends on the database or changeable state + * should be handled during parse analysis so that it happens at the + * right time not the wrong time. The handling of SQL_inheritance is + * a good example. + * + * WARNINGS + * If you use a list, make sure the datum is a node so that the printing + * routines work. + * + * Sometimes we assign constants to makeStrings. Make sure we don't free + * those. + * + *------------------------------------------------------------------------- + */ +#include "pool_parser.h" + +#include +#include +#include +#include +#include + +#include "nodes.h" +#include "keywords.h" +#include "pool_memory.h" +#include "gramparse.h" +#include "makefuncs.h" +#include "pool_string.h" +#include "parser.h" + +/* Location tracking support --- simpler than bison's default */ +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do { \ + if (N) \ + (Current) = (Rhs)[1]; \ + else \ + (Current) = (Rhs)[0]; \ + } while (0) + +/* + * We track token locations in terms of byte offsets from the start of the + * source string, not the column number/line number representation that + * bison uses by default. Also, to minimize overhead we track only one + * location (usually the first token location) for each construct, not + * the beginning and ending locations as bison does by default. It's + * therefore sufficient to make YYLTYPE an int. + */ +#define YYLTYPE int + +/* for XML data type */ +typedef enum +{ + XML_STANDALONE_YES, + XML_STANDALONE_NO, + XML_STANDALONE_NO_VALUE, + XML_STANDALONE_OMITTED +} XmlStandaloneType; + + +/* + * The %name-prefix option below will make bison call base_yylex, but we + * really want it to call filtered_base_yylex (see parser.c). + */ +#define base_yylex filtered_base_yylex + +#define ereport(a,b) yyerror("") +#define Assert +List *parsetree; /* final parse result is delivered here */ + +static bool QueryIsRule = FALSE; + +extern TypeName *SystemTypeName(char *name); +extern List *SystemFuncName(char *name); +extern void yyerror(const char *s); + +/* + * If you need access to certain yacc-generated variables and find that + * they're static by default, uncomment the next line. (this is not a + * problem, yet.) + */ +/*#define __YYSCLASS*/ + +static Node *makeColumnRef(char *relname, List *indirection, int location); +static Node *makeTypeCast(Node *arg, TypeName *typename); +static Node *makeStringConst(char *str, TypeName *typename); +static Node *makeIntConst(int val); +static Node *makeFloatConst(char *str); +static Node *makeAConst(Value *v); +static A_Const *makeBoolAConst(bool state); +static FuncCall *makeOverlaps(List *largs, List *rargs, int location); +static void check_qualified_name(List *names); +static List *check_func_name(List *names); +static List *extractArgTypes(List *parameters); +static SelectStmt *findLeftmostSelect(SelectStmt *node); +static void insertSelectOptions(SelectStmt *stmt, + List *sortClause, List *lockingClause, + Node *limitOffset, Node *limitCount); +static Node *makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg); +static Node *doNegate(Node *n, int location); +static void doNegateFloat(Value *v); +static Node *makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args); +static DefElem *defWithOids(bool value); + + +%} + +%name-prefix="base_yy" +%locations + +%union +{ + int ival; + char chr; + char *str; + const char *keyword; + bool boolean; + JoinType jtype; + DropBehavior dbehavior; + OnCommitAction oncommit; + List *list; + Node *node; + Value *value; + ObjectType objtype; + + TypeName *typnam; + FunctionParameter *fun_param; + FunctionParameterMode fun_param_mode; + FuncWithArgs *funwithargs; + DefElem *defelt; + SortBy *sortby; + JoinExpr *jexpr; + IndexElem *ielem; + Alias *alias; + RangeVar *range; + IntoClause *into; + A_Indices *aind; + ResTarget *target; + PrivTarget *privtarget; + + InsertStmt *istmt; + VariableSetStmt *vsetstmt; +} + +%type stmt schema_stmt + AlterDatabaseStmt AlterDatabaseSetStmt AlterDomainStmt AlterGroupStmt + AlterObjectSchemaStmt AlterOwnerStmt AlterSeqStmt AlterTableStmt + AlterUserStmt AlterUserSetStmt AlterRoleStmt AlterRoleSetStmt + AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt + ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt + CreateDomainStmt CreateGroupStmt CreateOpClassStmt + CreateOpFamilyStmt AlterOpFamilyStmt CreatePLangStmt + CreateSchemaStmt CreateSeqStmt CreateStmt CreateTableSpaceStmt + CreateAssertStmt CreateTrigStmt CreateUserStmt CreateRoleStmt + CreatedbStmt DeclareCursorStmt DefineStmt DeleteStmt DiscardStmt + DropGroupStmt DropOpClassStmt DropOpFamilyStmt DropPLangStmt DropStmt + DropAssertStmt DropTrigStmt DropRuleStmt DropCastStmt DropRoleStmt + DropUserStmt DropdbStmt DropTableSpaceStmt ExplainStmt FetchStmt + GrantStmt GrantRoleStmt IndexStmt InsertStmt ListenStmt LoadStmt + LockStmt NotifyStmt ExplainableStmt PreparableStmt + CreateFunctionStmt AlterFunctionStmt ReindexStmt RemoveAggrStmt + RemoveFuncStmt RemoveOperStmt RenameStmt RevokeStmt RevokeRoleStmt + RuleActionStmt RuleActionStmtOrEmpty RuleStmt + SelectStmt TransactionStmt TruncateStmt + UnlistenStmt UpdateStmt VacuumStmt + VariableResetStmt VariableSetStmt VariableShowStmt + ViewStmt CheckPointStmt CreateConversionStmt + DeallocateStmt PrepareStmt ExecuteStmt + DropOwnedStmt ReassignOwnedStmt + AlterTSConfigurationStmt AlterTSDictionaryStmt + +%type select_no_parens select_with_parens select_clause + simple_select values_clause + +%type alter_column_default opclass_item opclass_drop alter_using +%type add_drop opt_asc_desc opt_nulls_order + +%type alter_table_cmd alter_rel_cmd +%type alter_table_cmds alter_rel_cmds + +%type opt_drop_behavior + +%type createdb_opt_list alterdb_opt_list copy_opt_list + transaction_mode_list +%type createdb_opt_item alterdb_opt_item copy_opt_item + transaction_mode_item + +%type opt_lock lock_type cast_context +%type opt_force opt_or_replace + opt_grant_grant_option opt_grant_admin_option + opt_nowait opt_if_exists + +%type OptRoleList +%type OptRoleElem + +%type OptSchemaName +%type OptSchemaEltList + +%type TriggerActionTime TriggerForSpec opt_trusted +%type opt_lancompiler + +%type TriggerEvents +%type TriggerFuncArg + +%type relation_name copy_file_name + database_name access_method_clause access_method attr_name + index_name name file_name cluster_index_specification + +%type func_name handler_name qual_Op qual_all_Op subquery_Op + opt_class opt_validator + +%type qualified_name OptConstrFromTable + +%type all_Op MathOp SpecialRuleRelation + +%type iso_level opt_encoding +%type grantee +%type grantee_list +%type privilege +%type privileges privilege_list +%type privilege_target +%type function_with_argtypes +%type function_with_argtypes_list +%type TriggerOneEvent + +%type stmtblock stmtmulti + OptTableElementList TableElementList OptInherit definition + OptWith opt_distinct opt_definition func_args func_args_list + func_as createfunc_opt_list alterfunc_opt_list + aggr_args old_aggr_definition old_aggr_list + oper_argtypes RuleActionList RuleActionMulti + opt_column_list columnList opt_name_list + sort_clause opt_sort_clause sortby_list index_params + name_list from_clause from_list opt_array_bounds + qualified_name_list any_name any_name_list + any_operator expr_list attrs + target_list insert_column_list set_target_list + set_clause_list set_clause multiple_set_clause + ctext_expr_list ctext_row def_list indirection opt_indirection + group_clause TriggerFuncArgs select_limit + opt_select_limit opclass_item_list opclass_drop_list + opt_opfamily transaction_mode_list_or_empty + TableFuncElementList opt_type_modifiers + prep_type_clause + execute_param_clause using_clause returning_clause + enum_val_list + +%type OptTempTableName +%type into_clause create_as_target + +%type createfunc_opt_item common_func_opt_item +%type func_arg +%type arg_class +%type func_return func_type + +%type TriggerForType OptTemp +%type OnCommitOption + +%type for_locking_item +%type for_locking_clause opt_for_locking_clause for_locking_items +%type locked_rels_list +%type opt_all + +%type join_outer join_qual +%type join_type + +%type extract_list overlay_list position_list +%type substr_list trim_list +%type opt_interval +%type overlay_placing substr_from substr_for + +%type opt_instead opt_analyze +%type index_opt_unique opt_verbose opt_full +%type opt_freeze opt_default opt_recheck +%type opt_binary opt_oids copy_delimiter + +%type copy_from + +%type opt_column event cursor_options opt_hold +%type reindex_type drop_type comment_type + +%type fetch_direction select_limit_value select_offset_value + +%type OptSeqList +%type OptSeqElem + +%type insert_rest + +%type set_rest SetResetClause + +%type TableElement ConstraintElem TableFuncElement +%type columnDef +%type def_elem old_aggr_elem +%type def_arg columnElem where_clause where_or_current_clause + a_expr b_expr c_expr func_expr AexprConst indirection_el + columnref in_expr having_clause func_table array_expr +%type row type_list array_expr_list +%type case_expr case_arg when_clause case_default +%type when_clause_list +%type sub_type +%type OptCreateAs CreateAsList +%type CreateAsElement ctext_expr +%type NumericOnly FloatOnly IntegerOnly +%type alias_clause +%type sortby +%type index_elem +%type table_ref +%type joined_table +%type relation_expr +%type relation_expr_opt_alias +%type target_el single_set_clause set_target insert_column_item + +%type Typename SimpleTypename ConstTypename + GenericType Numeric opt_float + Character ConstCharacter + CharacterWithLength CharacterWithoutLength + ConstDatetime ConstInterval + Bit ConstBit BitWithLength BitWithoutLength +%type character +%type extract_arg +%type opt_charset +%type opt_varying opt_timezone + +%type Iconst SignedIconst +%type Sconst comment_text +%type RoleId opt_granted_by opt_boolean ColId_or_Sconst +%type var_list +%type ColId ColLabel var_name type_function_name param_name +%type var_value zone_value + +%type unreserved_keyword type_func_name_keyword +%type col_name_keyword reserved_keyword + +%type TableConstraint TableLikeClause +%type TableLikeOptionList +%type TableLikeOption +%type ColQualList +%type ColConstraint ColConstraintElem ConstraintAttr +%type key_actions key_delete key_match key_update key_action +%type ConstraintAttributeSpec ConstraintDeferrabilitySpec + ConstraintTimeSpec + +%type constraints_set_list +%type constraints_set_mode +%type OptTableSpace OptConsTableSpace OptTableSpaceOwner +%type opt_check_option + +%type xml_attribute_el +%type xml_attribute_list xml_attributes +%type xml_root_version opt_xml_root_standalone +%type document_or_content +%type xml_whitespace_option + + +/* + * If you make any token changes, update the keyword table in + * parser/keywords.c and add new keywords to the appropriate one of + * the reserved-or-not-so-reserved keyword lists, below; search + * this file for "Name classification hierarchy". + */ + +/* ordinary key words in alphabetical order */ +%token ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER + AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC + ASSERTION ASSIGNMENT ASYMMETRIC AT AUTHORIZATION + + BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT + BOOLEAN_P BOTH BY + + CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P + CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE + CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT + COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS + CONTENT_P CONVERSION_P COPY COST CREATE CREATEDB + CREATEROLE CREATEUSER CROSS CSV CURRENT_P CURRENT_DATE CURRENT_ROLE + CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE + + DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS + DEFERRABLE DEFERRED DEFINER DELETE_P DELIMITER DELIMITERS DESC + DICTIONARY DISABLE_P DISCARD DISTINCT DO DOCUMENT_P DOMAIN_P DOUBLE_P DROP + + EACH ELSE ENABLE_P ENCODING ENCRYPTED END_P ENUM_P ESCAPE EXCEPT EXCLUDING + EXCLUSIVE EXECUTE EXISTS EXPLAIN EXTERNAL EXTRACT + + FALSE_P FAMILY FETCH FIRST_P FLOAT_P FOR FORCE FOREIGN FORWARD + FREEZE FROM FULL FUNCTION + + GLOBAL GRANT GRANTED GREATEST GROUP_P + + HANDLER HAVING HEADER_P HOLD HOUR_P + + IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IN_P INCLUDING INCREMENT + INDEX INDEXES INHERIT INHERITS INITIALLY INNER_P INOUT INPUT_P + INSENSITIVE INSERT INSTEAD INT_P INTEGER INTERSECT + INTERVAL INTO INVOKER IS ISNULL ISOLATION + + JOIN + + KEY + + LANCOMPILER LANGUAGE LARGE_P LAST_P LEADING LEAST LEFT LEVEL + LIKE LIMIT LISTEN LOAD LOCAL LOCALTIME LOCALTIMESTAMP LOCATION + LOCK_P LOGIN_P + + MAPPING MATCH MAXVALUE MINUTE_P MINVALUE MODE MONTH_P MOVE + + NAME_P NAMES NATIONAL NATURAL NCHAR NEW NEXT NO NOCREATEDB + NOCREATEROLE NOCREATEUSER NOINHERIT NOLOGIN_P NONE NOSUPERUSER + NOT NOTHING NOTIFY NOTNULL NOWAIT NULL_P NULLIF NULLS_P NUMERIC + + OBJECT_P OF OFF OFFSET OIDS OLD ON ONLY OPERATOR OPTION OR + ORDER OUT_P OUTER_P OVERLAPS OVERLAY OWNED OWNER + + PARSER PARTIAL PASSWORD PLACING PLANS POSITION + PRECISION PRESERVE PREPARE PREPARED PRIMARY + PRIOR PRIVILEGES PROCEDURAL PROCEDURE + + QUOTE + + READ REAL REASSIGN RECHECK REFERENCES REINDEX RELATIVE_P RELEASE RENAME + REPEATABLE REPLACE REPLICA RESET RESTART RESTRICT RETURNING RETURNS REVOKE + RIGHT ROLE ROLLBACK ROW ROWS RULE + + SAVEPOINT SCHEMA SCROLL SEARCH SECOND_P SECURITY SELECT SEQUENCE + SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE + SHOW SIMILAR SIMPLE SMALLINT SOME STABLE STANDALONE_P START STATEMENT + STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P SUBSTRING SUPERUSER_P + SYMMETRIC SYSID SYSTEM_P + + TABLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME TIMESTAMP + TO TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P + TRUNCATE TRUSTED TYPE_P + + UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL + UPDATE USER USING + + VACUUM VALID VALIDATOR VALUE_P VALUES VARCHAR VARYING + VERBOSE VERSION_P VIEW VOLATILE + + WHEN WHERE WHITESPACE_P WITH WITHOUT WORK WRITE + + XML_P XMLATTRIBUTES XMLCONCAT XMLELEMENT XMLFOREST XMLPARSE + XMLPI XMLROOT XMLSERIALIZE + + YEAR_P YES_P + + ZONE + +/* The grammar thinks these are keywords, but they are not in the keywords.c + * list and so can never be entered directly. The filter in parser.c + * creates these tokens when required. + */ +%token NULLS_FIRST NULLS_LAST WITH_CASCADED WITH_LOCAL WITH_CHECK + +/* Special token types, not actually keywords - see the "lex" file */ +%token IDENT FCONST SCONST BCONST XCONST Op +%token ICONST PARAM + +/* precedence: lowest to highest */ +%nonassoc SET /* see relation_expr_opt_alias */ +%left UNION EXCEPT +%left INTERSECT +%left OR +%left AND +%right NOT +%right '=' +%nonassoc '<' '>' +%nonassoc LIKE ILIKE SIMILAR +%nonassoc ESCAPE +%nonassoc OVERLAPS +%nonassoc BETWEEN +%nonassoc IN_P +%left POSTFIXOP /* dummy for postfix Op rules */ +%left Op OPERATOR /* multi-character ops and user-defined operators */ +%nonassoc NOTNULL +%nonassoc ISNULL +%nonassoc IS NULL_P TRUE_P FALSE_P UNKNOWN /* sets precedence for IS NULL, etc */ +%left '+' '-' +%left '*' '/' '%' +%left '^' +/* Unary Operators */ +%left AT ZONE /* sets precedence for AT TIME ZONE */ +%right UMINUS +%left '[' ']' +%left '(' ')' +%left TYPECAST +%left '.' +/* + * These might seem to be low-precedence, but actually they are not part + * of the arithmetic hierarchy at all in their use as JOIN operators. + * We make them high-precedence to support their use as function names. + * They wouldn't be given a precedence at all, were it not that we need + * left-associativity among the JOIN rules themselves. + */ +%left JOIN CROSS LEFT FULL RIGHT INNER_P NATURAL +/* kluge to keep xml_whitespace_option from causing shift/reduce conflicts */ +%right PRESERVE STRIP_P +%% + +/* + * Handle comment-only lines, and ;; SELECT * FROM pg_class ;;; + * psql already handles such cases, but other interfaces don't. + * bjm 1999/10/05 + */ +stmtblock: stmtmulti { parsetree = $1; } + ; + +/* the thrashing around here is to discard "empty" statements... */ +stmtmulti: stmtmulti ';' stmt + { if ($3 != NULL) + $$ = lappend($1, $3); + else + $$ = $1; + } + | stmt + { if ($1 != NULL) + $$ = list_make1($1); + else + $$ = NIL; + } + ; + +stmt : + AlterDatabaseStmt + | AlterDatabaseSetStmt + | AlterDomainStmt + | AlterFunctionStmt + | AlterGroupStmt + | AlterObjectSchemaStmt + | AlterOwnerStmt + | AlterSeqStmt + | AlterTableStmt + | AlterRoleSetStmt + | AlterRoleStmt + | AlterTSConfigurationStmt + | AlterTSDictionaryStmt + | AlterUserSetStmt + | AlterUserStmt + | AnalyzeStmt + | CheckPointStmt + | ClosePortalStmt + | ClusterStmt + | CommentStmt + | ConstraintsSetStmt + | CopyStmt + | CreateAsStmt + | CreateAssertStmt + | CreateCastStmt + | CreateConversionStmt + | CreateDomainStmt + | CreateFunctionStmt + | CreateGroupStmt + | CreateOpClassStmt + | CreateOpFamilyStmt + | AlterOpFamilyStmt + | CreatePLangStmt + | CreateSchemaStmt + | CreateSeqStmt + | CreateStmt + | CreateTableSpaceStmt + | CreateTrigStmt + | CreateRoleStmt + | CreateUserStmt + | CreatedbStmt + | DeallocateStmt + | DeclareCursorStmt + | DefineStmt + | DeleteStmt + | DiscardStmt + | DropAssertStmt + | DropCastStmt + | DropGroupStmt + | DropOpClassStmt + | DropOpFamilyStmt + | DropOwnedStmt + | DropPLangStmt + | DropRuleStmt + | DropStmt + | DropTableSpaceStmt + | DropTrigStmt + | DropRoleStmt + | DropUserStmt + | DropdbStmt + | ExecuteStmt + | ExplainStmt + | FetchStmt + | GrantStmt + | GrantRoleStmt + | IndexStmt + | InsertStmt + | ListenStmt + | LoadStmt + | LockStmt + | NotifyStmt + | PrepareStmt + | ReassignOwnedStmt + | ReindexStmt + | RemoveAggrStmt + | RemoveFuncStmt + | RemoveOperStmt + | RenameStmt + | RevokeStmt + | RevokeRoleStmt + | RuleStmt + | SelectStmt + | TransactionStmt + | TruncateStmt + | UnlistenStmt + | UpdateStmt + | VacuumStmt + | VariableResetStmt + | VariableSetStmt + | VariableShowStmt + | ViewStmt + | /*EMPTY*/ + { $$ = NULL; } + ; + +/***************************************************************************** + * + * Create a new Postgres DBMS role + * + *****************************************************************************/ + +CreateRoleStmt: + CREATE ROLE RoleId opt_with OptRoleList + { + CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_ROLE; + n->role = $3; + n->options = $5; + $$ = (Node *)n; + } + ; + + +opt_with: WITH {} + | /*EMPTY*/ {} + ; + +/* + * Options for CREATE ROLE and ALTER ROLE (also used by CREATE/ALTER USER + * for backwards compatibility). Note: the only option required by SQL99 + * is "WITH ADMIN name". + */ +OptRoleList: + OptRoleList OptRoleElem { $$ = lappend($1, $2); } + | /* EMPTY */ { $$ = NIL; } + ; + +OptRoleElem: + PASSWORD Sconst + { + $$ = makeDefElem("password", + (Node *)makeString($2)); + } + | PASSWORD NULL_P + { + $$ = makeDefElem("password", NULL); + } + | ENCRYPTED PASSWORD Sconst + { + $$ = makeDefElem("encryptedPassword", + (Node *)makeString($3)); + } + | UNENCRYPTED PASSWORD Sconst + { + $$ = makeDefElem("unencryptedPassword", + (Node *)makeString($3)); + } + | SUPERUSER_P + { + $$ = makeDefElem("superuser", (Node *)makeInteger(TRUE)); + } + | NOSUPERUSER + { + $$ = makeDefElem("superuser", (Node *)makeInteger(FALSE)); + } + | INHERIT + { + $$ = makeDefElem("inherit", (Node *)makeInteger(TRUE)); + } + | NOINHERIT + { + $$ = makeDefElem("inherit", (Node *)makeInteger(FALSE)); + } + | CREATEDB + { + $$ = makeDefElem("createdb", (Node *)makeInteger(TRUE)); + } + | NOCREATEDB + { + $$ = makeDefElem("createdb", (Node *)makeInteger(FALSE)); + } + | CREATEROLE + { + $$ = makeDefElem("createrole", (Node *)makeInteger(TRUE)); + } + | NOCREATEROLE + { + $$ = makeDefElem("createrole", (Node *)makeInteger(FALSE)); + } + | CREATEUSER + { + /* For backwards compatibility, synonym for SUPERUSER */ + $$ = makeDefElem("superuser", (Node *)makeInteger(TRUE)); + } + | NOCREATEUSER + { + $$ = makeDefElem("superuser", (Node *)makeInteger(FALSE)); + } + | LOGIN_P + { + $$ = makeDefElem("canlogin", (Node *)makeInteger(TRUE)); + } + | NOLOGIN_P + { + $$ = makeDefElem("canlogin", (Node *)makeInteger(FALSE)); + } + | CONNECTION LIMIT SignedIconst + { + $$ = makeDefElem("connectionlimit", (Node *)makeInteger($3)); + } + | VALID UNTIL Sconst + { + $$ = makeDefElem("validUntil", (Node *)makeString($3)); + } + /* Supported but not documented for roles, for use by ALTER GROUP. */ + | USER name_list + { + $$ = makeDefElem("rolemembers", (Node *)$2); + } + /* The following are not supported by ALTER ROLE/USER/GROUP */ + | SYSID Iconst + { + $$ = makeDefElem("sysid", (Node *)makeInteger($2)); + } + | ADMIN name_list + { + $$ = makeDefElem("adminmembers", (Node *)$2); + } + | ROLE name_list + { + $$ = makeDefElem("rolemembers", (Node *)$2); + } + | IN_P ROLE name_list + { + $$ = makeDefElem("addroleto", (Node *)$3); + } + | IN_P GROUP_P name_list + { + $$ = makeDefElem("addroleto", (Node *)$3); + } + ; + + +/***************************************************************************** + * + * Create a new Postgres DBMS user (role with implied login ability) + * + *****************************************************************************/ + +CreateUserStmt: + CREATE USER RoleId opt_with OptRoleList + { + CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_USER; + n->role = $3; + n->options = $5; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Alter a postgresql DBMS role + * + *****************************************************************************/ + +AlterRoleStmt: + ALTER ROLE RoleId opt_with OptRoleList + { + AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = $3; + n->action = +1; /* add, if there are members */ + n->options = $5; + $$ = (Node *)n; + } + ; + +AlterRoleSetStmt: + ALTER ROLE RoleId SetResetClause + { + AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = $3; + n->setstmt = $4; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Alter a postgresql DBMS user + * + *****************************************************************************/ + +AlterUserStmt: + ALTER USER RoleId opt_with OptRoleList + { + AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = $3; + n->action = +1; /* add, if there are members */ + n->options = $5; + $$ = (Node *)n; + } + ; + + +AlterUserSetStmt: + ALTER USER RoleId SetResetClause + { + AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt); + n->role = $3; + n->setstmt = $4; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Drop a postgresql DBMS role + * + * XXX Ideally this would have CASCADE/RESTRICT options, but since a role + * might own objects in multiple databases, there is presently no way to + * implement either cascading or restricting. Caveat DBA. + *****************************************************************************/ + +DropRoleStmt: + DROP ROLE name_list + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = FALSE; + n->roles = $3; + $$ = (Node *)n; + } + | DROP ROLE IF_P EXISTS name_list + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = TRUE; + n->roles = $5; + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * + * Drop a postgresql DBMS user + * + * XXX Ideally this would have CASCADE/RESTRICT options, but since a user + * might own objects in multiple databases, there is presently no way to + * implement either cascading or restricting. Caveat DBA. + *****************************************************************************/ + +DropUserStmt: + DROP USER name_list + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = FALSE; + n->roles = $3; + $$ = (Node *)n; + } + | DROP USER IF_P EXISTS name_list + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->roles = $5; + n->missing_ok = TRUE; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Create a postgresql group (role without login ability) + * + *****************************************************************************/ + +CreateGroupStmt: + CREATE GROUP_P RoleId opt_with OptRoleList + { + CreateRoleStmt *n = makeNode(CreateRoleStmt); + n->stmt_type = ROLESTMT_GROUP; + n->role = $3; + n->options = $5; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Alter a postgresql group + * + *****************************************************************************/ + +AlterGroupStmt: + ALTER GROUP_P RoleId add_drop USER name_list + { + AlterRoleStmt *n = makeNode(AlterRoleStmt); + n->role = $3; + n->action = $4; + n->options = list_make1(makeDefElem("rolemembers", + (Node *)$6)); + $$ = (Node *)n; + } + ; + +add_drop: ADD_P { $$ = +1; } + | DROP { $$ = -1; } + ; + + +/***************************************************************************** + * + * Drop a postgresql group + * + * XXX see above notes about cascading DROP USER; groups have same problem. + *****************************************************************************/ + +DropGroupStmt: + DROP GROUP_P name_list + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = FALSE; + n->roles = $3; + $$ = (Node *)n; + } + | DROP GROUP_P IF_P EXISTS name_list + { + DropRoleStmt *n = makeNode(DropRoleStmt); + n->missing_ok = TRUE; + n->roles = $5; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Manipulate a schema + * + *****************************************************************************/ + +CreateSchemaStmt: + CREATE SCHEMA OptSchemaName AUTHORIZATION RoleId OptSchemaEltList + { + CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* One can omit the schema name or the authorization id. */ + if ($3 != NULL) + n->schemaname = $3; + else + n->schemaname = $5; + n->authid = $5; + n->schemaElts = $6; + $$ = (Node *)n; + } + | CREATE SCHEMA ColId OptSchemaEltList + { + CreateSchemaStmt *n = makeNode(CreateSchemaStmt); + /* ...but not both */ + n->schemaname = $3; + n->authid = NULL; + n->schemaElts = $4; + $$ = (Node *)n; + } + ; + +OptSchemaName: + ColId { $$ = $1; } + | /* EMPTY */ { $$ = NULL; } + ; + +OptSchemaEltList: + OptSchemaEltList schema_stmt { $$ = lappend($1, $2); } + | /* EMPTY */ { $$ = NIL; } + ; + +/* + * schema_stmt are the ones that can show up inside a CREATE SCHEMA + * statement (in addition to by themselves). + */ +schema_stmt: + CreateStmt + | IndexStmt + | CreateSeqStmt + | CreateTrigStmt + | GrantStmt + | ViewStmt + ; + + +/***************************************************************************** + * + * Set PG internal variable + * SET name TO 'var_value' + * Include SQL92 syntax (thomas 1997-10-22): + * SET TIME ZONE 'var_value' + * + *****************************************************************************/ + +VariableSetStmt: + SET set_rest + { + VariableSetStmt *n = $2; + n->is_local = false; + $$ = (Node *) n; + } + | SET LOCAL set_rest + { + VariableSetStmt *n = $3; + n->is_local = true; + $$ = (Node *) n; + } + | SET SESSION set_rest + { + VariableSetStmt *n = $3; + n->is_local = false; + $$ = (Node *) n; + } + ; + +set_rest: /* Generic SET syntaxes: */ + var_name TO var_list + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = $1; + n->args = $3; + $$ = n; + } + | var_name '=' var_list + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = $1; + n->args = $3; + $$ = n; + } + | var_name TO DEFAULT + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; + n->name = $1; + $$ = n; + } + | var_name '=' DEFAULT + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; + n->name = $1; + $$ = n; + } + | var_name FROM CURRENT_P + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_CURRENT; + n->name = $1; + $$ = n; + } + /* Special syntaxes mandated by SQL standard: */ + | TIME ZONE zone_value + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "timezone"; + if ($3 != NULL) + n->args = list_make1($3); + else + n->kind = VAR_SET_DEFAULT; + $$ = n; + } + | TRANSACTION transaction_mode_list + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; + n->name = "TRANSACTION"; + n->args = $2; + $$ = n; + } + | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_MULTI; + n->name = "SESSION CHARACTERISTICS"; + n->args = $5; + $$ = n; + } + | NAMES opt_encoding + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "client_encoding"; + if ($2 != NULL) + n->args = list_make1(makeStringConst($2, NULL)); + else + n->kind = VAR_SET_DEFAULT; + $$ = n; + } + | ROLE ColId_or_Sconst + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "role"; + n->args = list_make1(makeStringConst($2, NULL)); + $$ = n; + } + | SESSION AUTHORIZATION ColId_or_Sconst + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "session_authorization"; + n->args = list_make1(makeStringConst($3, NULL)); + $$ = n; + } + | SESSION AUTHORIZATION DEFAULT + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_DEFAULT; + n->name = "session_authorization"; + $$ = n; + } + | XML_P OPTION document_or_content + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_SET_VALUE; + n->name = "xmloption"; + n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT", NULL)); + $$ = n; + } + ; + +var_name: ColId { $$ = $1; } + | var_name '.' ColId + { + $$ = palloc(strlen($1) + strlen($3) + 2); + sprintf($$, "%s.%s", $1, $3); + } + ; + +var_list: var_value { $$ = list_make1($1); } + | var_list ',' var_value { $$ = lappend($1, $3); } + ; + +var_value: opt_boolean + { $$ = makeStringConst($1, NULL); } + | ColId_or_Sconst + { $$ = makeStringConst($1, NULL); } + | NumericOnly + { $$ = makeAConst($1); } + ; + +iso_level: READ UNCOMMITTED { $$ = "read uncommitted"; } + | READ COMMITTED { $$ = "read committed"; } + | REPEATABLE READ { $$ = "repeatable read"; } + | SERIALIZABLE { $$ = "serializable"; } + ; + +opt_boolean: + TRUE_P { $$ = "true"; } + | FALSE_P { $$ = "false"; } + | ON { $$ = "on"; } + | OFF { $$ = "off"; } + ; + +/* Timezone values can be: + * - a string such as 'pst8pdt' + * - an identifier such as "pst8pdt" + * - an integer or floating point number + * - a time interval per SQL99 + * ColId gives reduce/reduce errors against ConstInterval and LOCAL, + * so use IDENT and reject anything which is a reserved word. + */ +zone_value: + Sconst + { + $$ = makeStringConst($1, NULL); + } + | IDENT + { + $$ = makeStringConst($1, NULL); + } + | ConstInterval Sconst opt_interval + { + A_Const *n = (A_Const *) makeStringConst($2, $1); + if ($3 != INTERVAL_FULL_RANGE) + { + if (($3 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("time zone interval must be HOUR or HOUR TO MINUTE"))); + n->typename->typmods = list_make1(makeIntConst($3)); + } + $$ = (Node *)n; + } + | ConstInterval '(' Iconst ')' Sconst opt_interval + { + A_Const *n = (A_Const *) makeStringConst($5, $1); + if (($6 != INTERVAL_FULL_RANGE) + && (($6 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("time zone interval must be HOUR or HOUR TO MINUTE"))); + n->typename->typmods = list_make2(makeIntConst($6), + makeIntConst($3)); + $$ = (Node *)n; + } + | NumericOnly { $$ = makeAConst($1); } + | DEFAULT { $$ = NULL; } + | LOCAL { $$ = NULL; } + ; + +opt_encoding: + Sconst { $$ = $1; } + | DEFAULT { $$ = NULL; } + | /*EMPTY*/ { $$ = NULL; } + ; + +ColId_or_Sconst: + ColId { $$ = $1; } + | SCONST { $$ = $1; } + ; + +VariableResetStmt: + RESET var_name + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = $2; + $$ = (Node *) n; + } + | RESET TIME ZONE + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = "timezone"; + $$ = (Node *) n; + } + | RESET TRANSACTION ISOLATION LEVEL + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = "transaction_isolation"; + $$ = (Node *) n; + } + | RESET SESSION AUTHORIZATION + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET; + n->name = "session_authorization"; + $$ = (Node *) n; + } + | RESET ALL + { + VariableSetStmt *n = makeNode(VariableSetStmt); + n->kind = VAR_RESET_ALL; + $$ = (Node *) n; + } + ; + +/* SetResetClause allows SET or RESET without LOCAL */ +SetResetClause: + SET set_rest { $$ = $2; } + | VariableResetStmt { $$ = (VariableSetStmt *) $1; } + ; + + +VariableShowStmt: + SHOW var_name + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = $2; + $$ = (Node *) n; + } + | SHOW TIME ZONE + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "timezone"; + $$ = (Node *) n; + } + | SHOW TRANSACTION ISOLATION LEVEL + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "transaction_isolation"; + $$ = (Node *) n; + } + | SHOW SESSION AUTHORIZATION + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "session_authorization"; + $$ = (Node *) n; + } + | SHOW ALL + { + VariableShowStmt *n = makeNode(VariableShowStmt); + n->name = "all"; + $$ = (Node *) n; + } + ; + + +ConstraintsSetStmt: + SET CONSTRAINTS constraints_set_list constraints_set_mode + { + ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt); + n->constraints = $3; + n->deferred = $4; + $$ = (Node *) n; + } + ; + +constraints_set_list: + ALL { $$ = NIL; } + | qualified_name_list { $$ = $1; } + ; + +constraints_set_mode: + DEFERRED { $$ = TRUE; } + | IMMEDIATE { $$ = FALSE; } + ; + + +/* + * Checkpoint statement + */ +CheckPointStmt: + CHECKPOINT + { + CheckPointStmt *n = makeNode(CheckPointStmt); + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * DISCARD { ALL | TEMP | PLANS } + * + *****************************************************************************/ + +DiscardStmt: + DISCARD ALL + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_ALL; + $$ = (Node *) n; + } + | DISCARD TEMP + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_TEMP; + $$ = (Node *) n; + } + | DISCARD TEMPORARY + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_TEMP; + $$ = (Node *) n; + } + | DISCARD PLANS + { + DiscardStmt *n = makeNode(DiscardStmt); + n->target = DISCARD_PLANS; + $$ = (Node *) n; + } + ; + + +/***************************************************************************** + * + * ALTER [ TABLE | INDEX ] variations + * + *****************************************************************************/ + +AlterTableStmt: + ALTER TABLE relation_expr alter_table_cmds + { + AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; + n->cmds = $4; + n->relkind = OBJECT_TABLE; + $$ = (Node *)n; + } + | ALTER INDEX relation_expr alter_rel_cmds + { + AlterTableStmt *n = makeNode(AlterTableStmt); + n->relation = $3; + n->cmds = $4; + n->relkind = OBJECT_INDEX; + $$ = (Node *)n; + } + ; + +alter_table_cmds: + alter_table_cmd { $$ = list_make1($1); } + | alter_table_cmds ',' alter_table_cmd { $$ = lappend($1, $3); } + ; + +/* Subcommands that are for ALTER TABLE only */ +alter_table_cmd: + /* ALTER TABLE ADD [COLUMN] */ + ADD_P opt_column columnDef + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddColumn; + n->def = $3; + $$ = (Node *)n; + } + /* ALTER TABLE ALTER [COLUMN] {SET DEFAULT |DROP DEFAULT} */ + | ALTER opt_column ColId alter_column_default + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ColumnDefault; + n->name = $3; + n->def = $4; + $$ = (Node *)n; + } + /* ALTER TABLE ALTER [COLUMN] DROP NOT NULL */ + | ALTER opt_column ColId DROP NOT NULL_P + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropNotNull; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE ALTER [COLUMN] SET NOT NULL */ + | ALTER opt_column ColId SET NOT NULL_P + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetNotNull; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE ALTER [COLUMN] SET STATISTICS */ + | ALTER opt_column ColId SET STATISTICS IntegerOnly + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetStatistics; + n->name = $3; + n->def = (Node *) $6; + $$ = (Node *)n; + } + /* ALTER TABLE ALTER [COLUMN] SET STORAGE */ + | ALTER opt_column ColId SET STORAGE ColId + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetStorage; + n->name = $3; + n->def = (Node *) makeString($6); + $$ = (Node *)n; + } + /* ALTER TABLE DROP [COLUMN] [RESTRICT|CASCADE] */ + | DROP opt_column ColId opt_drop_behavior + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropColumn; + n->name = $3; + n->behavior = $4; + $$ = (Node *)n; + } + /* + * ALTER TABLE ALTER [COLUMN] TYPE + * [ USING ] + */ + | ALTER opt_column ColId TYPE_P Typename alter_using + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AlterColumnType; + n->name = $3; + n->def = (Node *) $5; + n->transform = $6; + $$ = (Node *)n; + } + /* ALTER TABLE ADD CONSTRAINT ... */ + | ADD_P TableConstraint + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddConstraint; + n->def = $2; + $$ = (Node *)n; + } + /* ALTER TABLE DROP CONSTRAINT [RESTRICT|CASCADE] */ + | DROP CONSTRAINT name opt_drop_behavior + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropConstraint; + n->name = $3; + n->behavior = $4; + $$ = (Node *)n; + } + /* ALTER TABLE SET WITHOUT OIDS */ + | SET WITHOUT OIDS + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropOids; + $$ = (Node *)n; + } + /* ALTER TABLE CLUSTER ON */ + | CLUSTER ON name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ClusterOn; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE SET WITHOUT CLUSTER */ + | SET WITHOUT CLUSTER + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropCluster; + n->name = NULL; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE TRIGGER */ + | ENABLE_P TRIGGER name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrig; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE ALWAYS TRIGGER */ + | ENABLE_P ALWAYS TRIGGER name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableAlwaysTrig; + n->name = $4; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE REPLICA TRIGGER */ + | ENABLE_P REPLICA TRIGGER name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableReplicaTrig; + n->name = $4; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE TRIGGER ALL */ + | ENABLE_P TRIGGER ALL + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrigAll; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE TRIGGER USER */ + | ENABLE_P TRIGGER USER + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableTrigUser; + $$ = (Node *)n; + } + /* ALTER TABLE DISABLE TRIGGER */ + | DISABLE_P TRIGGER name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrig; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE DISABLE TRIGGER ALL */ + | DISABLE_P TRIGGER ALL + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrigAll; + $$ = (Node *)n; + } + /* ALTER TABLE DISABLE TRIGGER USER */ + | DISABLE_P TRIGGER USER + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableTrigUser; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE RULE */ + | ENABLE_P RULE name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableRule; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE ALWAYS RULE */ + | ENABLE_P ALWAYS RULE name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableAlwaysRule; + n->name = $4; + $$ = (Node *)n; + } + /* ALTER TABLE ENABLE REPLICA RULE */ + | ENABLE_P REPLICA RULE name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_EnableReplicaRule; + n->name = $4; + $$ = (Node *)n; + } + /* ALTER TABLE DISABLE RULE */ + | DISABLE_P RULE name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DisableRule; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER TABLE INHERIT */ + | INHERIT qualified_name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_AddInherit; + n->def = (Node *) $2; + $$ = (Node *)n; + } + /* ALTER TABLE NO INHERIT */ + | NO INHERIT qualified_name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_DropInherit; + n->def = (Node *) $3; + $$ = (Node *)n; + } + | alter_rel_cmd + { + $$ = $1; + } + ; + +alter_rel_cmds: + alter_rel_cmd { $$ = list_make1($1); } + | alter_rel_cmds ',' alter_rel_cmd { $$ = lappend($1, $3); } + ; + +/* Subcommands that are for ALTER TABLE or ALTER INDEX */ +alter_rel_cmd: + /* ALTER [TABLE|INDEX] OWNER TO RoleId */ + OWNER TO RoleId + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ChangeOwner; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER [TABLE|INDEX] SET TABLESPACE */ + | SET TABLESPACE name + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetTableSpace; + n->name = $3; + $$ = (Node *)n; + } + /* ALTER [TABLE|INDEX] SET (...) */ + | SET definition + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_SetRelOptions; + n->def = (Node *)$2; + $$ = (Node *)n; + } + /* ALTER [TABLE|INDEX] RESET (...) */ + | RESET definition + { + AlterTableCmd *n = makeNode(AlterTableCmd); + n->subtype = AT_ResetRelOptions; + n->def = (Node *)$2; + $$ = (Node *)n; + } + ; + +alter_column_default: + SET DEFAULT a_expr + { + /* Treat SET DEFAULT NULL the same as DROP DEFAULT */ + if (exprIsNullConstant($3)) + $$ = NULL; + else + $$ = $3; + } + | DROP DEFAULT { $$ = NULL; } + ; + +opt_drop_behavior: + CASCADE { $$ = DROP_CASCADE; } + | RESTRICT { $$ = DROP_RESTRICT; } + | /* EMPTY */ { $$ = DROP_RESTRICT; /* default */ } + ; + +alter_using: + USING a_expr { $$ = $2; } + | /* EMPTY */ { $$ = NULL; } + ; + + + +/***************************************************************************** + * + * QUERY : + * close + * + *****************************************************************************/ + +ClosePortalStmt: + CLOSE name + { + ClosePortalStmt *n = makeNode(ClosePortalStmt); + n->portalname = $2; + $$ = (Node *)n; + } + | CLOSE ALL + { + ClosePortalStmt *n = makeNode(ClosePortalStmt); + n->portalname = NULL; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * QUERY : + * COPY relname ['(' columnList ')'] FROM/TO file [WITH options] + * + * BINARY, OIDS, and DELIMITERS kept in old locations + * for backward compatibility. 2002-06-18 + * + * COPY ( SELECT ... ) TO file [WITH options] + * This form doesn't have the backwards-compatible option + * syntax. + * + *****************************************************************************/ + +CopyStmt: COPY opt_binary qualified_name opt_column_list opt_oids + copy_from copy_file_name copy_delimiter opt_with copy_opt_list + { + CopyStmt *n = makeNode(CopyStmt); + n->relation = $3; + n->query = NULL; + n->attlist = $4; + n->is_from = $6; + n->filename = $7; + + n->options = NIL; + /* Concatenate user-supplied flags */ + if ($2) + n->options = lappend(n->options, $2); + if ($5) + n->options = lappend(n->options, $5); + if ($8) + n->options = lappend(n->options, $8); + if ($10) + n->options = list_concat(n->options, $10); + $$ = (Node *)n; + } + | COPY select_with_parens TO copy_file_name opt_with + copy_opt_list + { + CopyStmt *n = makeNode(CopyStmt); + n->relation = NULL; + n->query = $2; + n->attlist = NIL; + n->is_from = false; + n->filename = $4; + n->options = $6; + $$ = (Node *)n; + } + ; + +copy_from: + FROM { $$ = TRUE; } + | TO { $$ = FALSE; } + ; + +/* + * copy_file_name NULL indicates stdio is used. Whether stdin or stdout is + * used depends on the direction. (It really doesn't make sense to copy from + * stdout. We silently correct the "typo".) - AY 9/94 + */ +copy_file_name: + Sconst { $$ = $1; } + | STDIN { $$ = NULL; } + | STDOUT { $$ = NULL; } + ; + + + +copy_opt_list: + copy_opt_list copy_opt_item { $$ = lappend($1, $2); } + | /* EMPTY */ { $$ = NIL; } + ; + + +copy_opt_item: + BINARY + { + $$ = makeDefElem("binary", (Node *)makeInteger(TRUE)); + } + | OIDS + { + $$ = makeDefElem("oids", (Node *)makeInteger(TRUE)); + } + | DELIMITER opt_as Sconst + { + $$ = makeDefElem("delimiter", (Node *)makeString($3)); + } + | NULL_P opt_as Sconst + { + $$ = makeDefElem("null", (Node *)makeString($3)); + } + | CSV + { + $$ = makeDefElem("csv", (Node *)makeInteger(TRUE)); + } + | HEADER_P + { + $$ = makeDefElem("header", (Node *)makeInteger(TRUE)); + } + | QUOTE opt_as Sconst + { + $$ = makeDefElem("quote", (Node *)makeString($3)); + } + | ESCAPE opt_as Sconst + { + $$ = makeDefElem("escape", (Node *)makeString($3)); + } + | FORCE QUOTE columnList + { + $$ = makeDefElem("force_quote", (Node *)$3); + } + | FORCE NOT NULL_P columnList + { + $$ = makeDefElem("force_notnull", (Node *)$4); + } + ; + +/* The following exist for backward compatibility */ + +opt_binary: + BINARY + { + $$ = makeDefElem("binary", (Node *)makeInteger(TRUE)); + } + | /*EMPTY*/ { $$ = NULL; } + ; + +opt_oids: + WITH OIDS + { + $$ = makeDefElem("oids", (Node *)makeInteger(TRUE)); + } + | /*EMPTY*/ { $$ = NULL; } + ; + +copy_delimiter: + /* USING DELIMITERS kept for backward compatibility. 2002-06-15 */ + opt_using DELIMITERS Sconst + { + $$ = makeDefElem("delimiter", (Node *)makeString($3)); + } + | /*EMPTY*/ { $$ = NULL; } + ; + +opt_using: + USING {} + | /*EMPTY*/ {} + ; + + +/***************************************************************************** + * + * QUERY : + * CREATE TABLE relname + * + *****************************************************************************/ + +CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' + OptInherit OptWith OnCommitOption OptTableSpace + { + CreateStmt *n = makeNode(CreateStmt); + $4->istemp = $2; + n->relation = $4; + n->tableElts = $6; + n->inhRelations = $8; + n->constraints = NIL; + n->options = $9; + n->oncommit = $10; + n->tablespacename = $11; + $$ = (Node *)n; + } + | CREATE OptTemp TABLE qualified_name OF qualified_name + '(' OptTableElementList ')' OptWith OnCommitOption OptTableSpace + { + /* SQL99 CREATE TABLE OF (cols) seems to be satisfied + * by our inheritance capabilities. Let's try it... + */ + CreateStmt *n = makeNode(CreateStmt); + $4->istemp = $2; + n->relation = $4; + n->tableElts = $8; + n->inhRelations = list_make1($6); + n->constraints = NIL; + n->options = $10; + n->oncommit = $11; + n->tablespacename = $12; + $$ = (Node *)n; + } + ; + +/* + * Redundancy here is needed to avoid shift/reduce conflicts, + * since TEMP is not a reserved word. See also OptTempTableName. + * + * NOTE: we accept both GLOBAL and LOCAL options; since we have no modules + * the LOCAL keyword is really meaningless. + */ +OptTemp: TEMPORARY { $$ = TRUE; } + | TEMP { $$ = TRUE; } + | LOCAL TEMPORARY { $$ = TRUE; } + | LOCAL TEMP { $$ = TRUE; } + | GLOBAL TEMPORARY { $$ = TRUE; } + | GLOBAL TEMP { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +OptTableElementList: + TableElementList { $$ = $1; } + | /*EMPTY*/ { $$ = NIL; } + ; + +TableElementList: + TableElement + { + $$ = list_make1($1); + } + | TableElementList ',' TableElement + { + $$ = lappend($1, $3); + } + ; + +TableElement: + columnDef { $$ = $1; } + | TableLikeClause { $$ = $1; } + | TableConstraint { $$ = $1; } + ; + +columnDef: ColId Typename ColQualList + { + ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; + n->typename = $2; + n->constraints = $3; + n->is_local = true; + $$ = (Node *)n; + } + ; + +ColQualList: + ColQualList ColConstraint { $$ = lappend($1, $2); } + | /*EMPTY*/ { $$ = NIL; } + ; + +ColConstraint: + CONSTRAINT name ColConstraintElem + { + switch (nodeTag($3)) + { + case T_Constraint: + { + Constraint *n = (Constraint *)$3; + n->name = $2; + } + break; + case T_FkConstraint: + { + FkConstraint *n = (FkConstraint *)$3; + n->constr_name = $2; + } + break; + default: + break; + } + $$ = $3; + } + | ColConstraintElem { $$ = $1; } + | ConstraintAttr { $$ = $1; } + ; + +/* DEFAULT NULL is already the default for Postgres. + * But define it here and carry it forward into the system + * to make it explicit. + * - thomas 1998-09-13 + * + * WITH NULL and NULL are not SQL92-standard syntax elements, + * so leave them out. Use DEFAULT NULL to explicitly indicate + * that a column may have that value. WITH NULL leads to + * shift/reduce conflicts with WITH TIME ZONE anyway. + * - thomas 1999-01-08 + * + * DEFAULT expression must be b_expr not a_expr to prevent shift/reduce + * conflict on NOT (since NOT might start a subsequent NOT NULL constraint, + * or be part of a_expr NOT LIKE or similar constructs). + */ +ColConstraintElem: + NOT NULL_P + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_NOTNULL; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + $$ = (Node *)n; + } + | NULL_P + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_NULL; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + $$ = (Node *)n; + } + | UNIQUE opt_definition OptConsTableSpace + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->options = $2; + n->indexspace = $3; + $$ = (Node *)n; + } + | PRIMARY KEY opt_definition OptConsTableSpace + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = NULL; + n->options = $3; + n->indexspace = $4; + $$ = (Node *)n; + } + | CHECK '(' a_expr ')' + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_CHECK; + n->name = NULL; + n->raw_expr = $3; + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + $$ = (Node *)n; + } + | DEFAULT b_expr + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_DEFAULT; + n->name = NULL; + if (exprIsNullConstant($2)) + { + /* DEFAULT NULL should be reported as empty expr */ + n->raw_expr = NULL; + } + else + { + n->raw_expr = $2; + } + n->cooked_expr = NULL; + n->keys = NULL; + n->indexspace = NULL; + $$ = (Node *)n; + } + | REFERENCES qualified_name opt_column_list key_match key_actions + { + FkConstraint *n = makeNode(FkConstraint); + n->constr_name = NULL; + n->pktable = $2; + n->fk_attrs = NIL; + n->pk_attrs = $3; + n->fk_matchtype = $4; + n->fk_upd_action = (char) ($5 >> 8); + n->fk_del_action = (char) ($5 & 0xFF); + n->deferrable = FALSE; + n->initdeferred = FALSE; + $$ = (Node *)n; + } + ; + +/* + * ConstraintAttr represents constraint attributes, which we parse as if + * they were independent constraint clauses, in order to avoid shift/reduce + * conflicts (since NOT might start either an independent NOT NULL clause + * or an attribute). parse_utilcmd.c is responsible for attaching the + * attribute information to the preceding "real" constraint node, and for + * complaining if attribute clauses appear in the wrong place or wrong + * combinations. + * + * See also ConstraintAttributeSpec, which can be used in places where + * there is no parsing conflict. + */ +ConstraintAttr: + DEFERRABLE + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_DEFERRABLE; + $$ = (Node *)n; + } + | NOT DEFERRABLE + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_NOT_DEFERRABLE; + $$ = (Node *)n; + } + | INITIALLY DEFERRED + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_DEFERRED; + $$ = (Node *)n; + } + | INITIALLY IMMEDIATE + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_ATTR_IMMEDIATE; + $$ = (Node *)n; + } + ; + + +/* + * SQL99 supports wholesale borrowing of a table definition via the LIKE clause. + * This seems to be a poor man's inheritance capability, with the resulting + * tables completely decoupled except for the original commonality in definitions. + * + * This is very similar to CREATE TABLE AS except for the INCLUDING DEFAULTS extension + * which is a part of SQL 200N + */ +TableLikeClause: + LIKE qualified_name TableLikeOptionList + { + InhRelation *n = makeNode(InhRelation); + n->relation = $2; + n->options = $3; + $$ = (Node *)n; + } + ; + +TableLikeOptionList: + TableLikeOptionList TableLikeOption { $$ = lappend_int($1, $2); } + | /* EMPTY */ { $$ = NIL; } + ; + +TableLikeOption: + INCLUDING DEFAULTS { $$ = CREATE_TABLE_LIKE_INCLUDING_DEFAULTS; } + | EXCLUDING DEFAULTS { $$ = CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS; } + | INCLUDING CONSTRAINTS { $$ = CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS; } + | EXCLUDING CONSTRAINTS { $$ = CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS; } + | INCLUDING INDEXES { $$ = CREATE_TABLE_LIKE_INCLUDING_INDEXES; } + | EXCLUDING INDEXES { $$ = CREATE_TABLE_LIKE_EXCLUDING_INDEXES; } + ; + + +/* ConstraintElem specifies constraint syntax which is not embedded into + * a column definition. ColConstraintElem specifies the embedded form. + * - thomas 1997-12-03 + */ +TableConstraint: + CONSTRAINT name ConstraintElem + { + switch (nodeTag($3)) + { + case T_Constraint: + { + Constraint *n = (Constraint *)$3; + n->name = $2; + } + break; + case T_FkConstraint: + { + FkConstraint *n = (FkConstraint *)$3; + n->constr_name = $2; + } + break; + default: + break; + } + $$ = $3; + } + | ConstraintElem { $$ = $1; } + ; + +ConstraintElem: + CHECK '(' a_expr ')' + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_CHECK; + n->name = NULL; + n->raw_expr = $3; + n->cooked_expr = NULL; + n->indexspace = NULL; + $$ = (Node *)n; + } + | UNIQUE '(' columnList ')' opt_definition OptConsTableSpace + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_UNIQUE; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = $3; + n->options = $5; + n->indexspace = $6; + $$ = (Node *)n; + } + | PRIMARY KEY '(' columnList ')' opt_definition OptConsTableSpace + { + Constraint *n = makeNode(Constraint); + n->contype = CONSTR_PRIMARY; + n->name = NULL; + n->raw_expr = NULL; + n->cooked_expr = NULL; + n->keys = $4; + n->options = $6; + n->indexspace = $7; + $$ = (Node *)n; + } + | FOREIGN KEY '(' columnList ')' REFERENCES qualified_name + opt_column_list key_match key_actions ConstraintAttributeSpec + { + FkConstraint *n = makeNode(FkConstraint); + n->constr_name = NULL; + n->pktable = $7; + n->fk_attrs = $4; + n->pk_attrs = $8; + n->fk_matchtype = $9; + n->fk_upd_action = (char) ($10 >> 8); + n->fk_del_action = (char) ($10 & 0xFF); + n->deferrable = ($11 & 1) != 0; + n->initdeferred = ($11 & 2) != 0; + $$ = (Node *)n; + } + ; + +opt_column_list: + '(' columnList ')' { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +columnList: + columnElem { $$ = list_make1($1); } + | columnList ',' columnElem { $$ = lappend($1, $3); } + ; + +columnElem: ColId + { + $$ = (Node *) makeString($1); + } + ; + +key_match: MATCH FULL + { + $$ = FKCONSTR_MATCH_FULL; + } + | MATCH PARTIAL + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("MATCH PARTIAL not yet implemented"))); + $$ = FKCONSTR_MATCH_PARTIAL; + } + | MATCH SIMPLE + { + $$ = FKCONSTR_MATCH_UNSPECIFIED; + } + | /*EMPTY*/ + { + $$ = FKCONSTR_MATCH_UNSPECIFIED; + } + ; + +/* + * We combine the update and delete actions into one value temporarily + * for simplicity of parsing, and then break them down again in the + * calling production. update is in the left 8 bits, delete in the right. + * Note that NOACTION is the default. + */ +key_actions: + key_update + { $$ = ($1 << 8) | (FKCONSTR_ACTION_NOACTION & 0xFF); } + | key_delete + { $$ = (FKCONSTR_ACTION_NOACTION << 8) | ($1 & 0xFF); } + | key_update key_delete + { $$ = ($1 << 8) | ($2 & 0xFF); } + | key_delete key_update + { $$ = ($2 << 8) | ($1 & 0xFF); } + | /*EMPTY*/ + { $$ = (FKCONSTR_ACTION_NOACTION << 8) | (FKCONSTR_ACTION_NOACTION & 0xFF); } + ; + +key_update: ON UPDATE key_action { $$ = $3; } + ; + +key_delete: ON DELETE_P key_action { $$ = $3; } + ; + +key_action: + NO ACTION { $$ = FKCONSTR_ACTION_NOACTION; } + | RESTRICT { $$ = FKCONSTR_ACTION_RESTRICT; } + | CASCADE { $$ = FKCONSTR_ACTION_CASCADE; } + | SET NULL_P { $$ = FKCONSTR_ACTION_SETNULL; } + | SET DEFAULT { $$ = FKCONSTR_ACTION_SETDEFAULT; } + ; + +OptInherit: INHERITS '(' qualified_name_list ')' { $$ = $3; } + | /*EMPTY*/ { $$ = NIL; } + ; + +/* WITH (options) is preferred, WITH OIDS and WITHOUT OIDS are legacy forms */ +OptWith: + WITH definition { $$ = $2; } + | WITH OIDS { $$ = list_make1(defWithOids(true)); } + | WITHOUT OIDS { $$ = list_make1(defWithOids(false)); } + | /*EMPTY*/ { $$ = NIL; } + ; + +OnCommitOption: ON COMMIT DROP { $$ = ONCOMMIT_DROP; } + | ON COMMIT DELETE_P ROWS { $$ = ONCOMMIT_DELETE_ROWS; } + | ON COMMIT PRESERVE ROWS { $$ = ONCOMMIT_PRESERVE_ROWS; } + | /*EMPTY*/ { $$ = ONCOMMIT_NOOP; } + ; + +OptTableSpace: TABLESPACE name { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + +OptConsTableSpace: USING INDEX TABLESPACE name { $$ = $4; } + | /*EMPTY*/ { $$ = NULL; } + ; + + +/* + * Note: CREATE TABLE ... AS SELECT ... is just another spelling for + * SELECT ... INTO. + */ + +CreateAsStmt: + CREATE OptTemp TABLE create_as_target AS SelectStmt + { + /* + * When the SelectStmt is a set-operation tree, we must + * stuff the INTO information into the leftmost component + * Select, because that's where analyze.c will expect + * to find it. Similarly, the output column names must + * be attached to that Select's target list. + */ + SelectStmt *n = findLeftmostSelect((SelectStmt *) $6); + if (n->intoClause != NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("CREATE TABLE AS cannot specify INTO"))); + $4->rel->istemp = $2; + n->intoClause = $4; + $$ = $6; + } + ; + +create_as_target: + qualified_name OptCreateAs OptWith OnCommitOption OptTableSpace + { + $$ = makeNode(IntoClause); + $$->rel = $1; + $$->colNames = $2; + $$->options = $3; + $$->onCommit = $4; + $$->tableSpaceName = $5; + } + ; + +OptCreateAs: + '(' CreateAsList ')' { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +CreateAsList: + CreateAsElement { $$ = list_make1($1); } + | CreateAsList ',' CreateAsElement { $$ = lappend($1, $3); } + ; + +CreateAsElement: + ColId + { + ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; + n->typename = NULL; + n->inhcount = 0; + n->is_local = true; + n->is_not_null = false; + n->raw_default = NULL; + n->cooked_default = NULL; + n->constraints = NIL; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * QUERY : + * CREATE SEQUENCE seqname + * ALTER SEQUENCE seqname + * + *****************************************************************************/ + +CreateSeqStmt: + CREATE OptTemp SEQUENCE qualified_name OptSeqList + { + CreateSeqStmt *n = makeNode(CreateSeqStmt); + $4->istemp = $2; + n->sequence = $4; + n->options = $5; + $$ = (Node *)n; + } + ; + +AlterSeqStmt: + ALTER SEQUENCE qualified_name OptSeqList + { + AlterSeqStmt *n = makeNode(AlterSeqStmt); + n->sequence = $3; + n->options = $4; + $$ = (Node *)n; + } + ; + +OptSeqList: OptSeqList OptSeqElem { $$ = lappend($1, $2); } + | /*EMPTY*/ { $$ = NIL; } + ; + +OptSeqElem: CACHE NumericOnly + { + $$ = makeDefElem("cache", (Node *)$2); + } + | CYCLE + { + $$ = makeDefElem("cycle", (Node *)makeInteger(TRUE)); + } + | NO CYCLE + { + $$ = makeDefElem("cycle", (Node *)makeInteger(FALSE)); + } + | INCREMENT opt_by NumericOnly + { + $$ = makeDefElem("increment", (Node *)$3); + } + | MAXVALUE NumericOnly + { + $$ = makeDefElem("maxvalue", (Node *)$2); + } + | MINVALUE NumericOnly + { + $$ = makeDefElem("minvalue", (Node *)$2); + } + | NO MAXVALUE + { + $$ = makeDefElem("maxvalue", NULL); + } + | NO MINVALUE + { + $$ = makeDefElem("minvalue", NULL); + } + | OWNED BY any_name + { + $$ = makeDefElem("owned_by", (Node *)$3); + } + | START opt_with NumericOnly + { + $$ = makeDefElem("start", (Node *)$3); + } + | RESTART opt_with NumericOnly + { + $$ = makeDefElem("restart", (Node *)$3); + } + ; + +opt_by: BY {} + | /* empty */ {} + ; + +NumericOnly: + FloatOnly { $$ = $1; } + | IntegerOnly { $$ = $1; } + ; + +FloatOnly: FCONST { $$ = makeFloat($1); } + | '-' FCONST + { + $$ = makeFloat($2); + doNegateFloat($$); + } + ; + +IntegerOnly: SignedIconst { $$ = makeInteger($1); }; + + +/***************************************************************************** + * + * QUERIES : + * CREATE PROCEDURAL LANGUAGE ... + * DROP PROCEDURAL LANGUAGE ... + * + *****************************************************************************/ + +CreatePLangStmt: + CREATE opt_trusted opt_procedural LANGUAGE ColId_or_Sconst + { + CreatePLangStmt *n = makeNode(CreatePLangStmt); + n->plname = $5; + /* parameters are all to be supplied by system */ + n->plhandler = NIL; + n->plvalidator = NIL; + n->pltrusted = false; + $$ = (Node *)n; + } + | CREATE opt_trusted opt_procedural LANGUAGE ColId_or_Sconst + HANDLER handler_name opt_validator opt_lancompiler + { + CreatePLangStmt *n = makeNode(CreatePLangStmt); + n->plname = $5; + n->plhandler = $7; + n->plvalidator = $8; + n->pltrusted = $2; + /* LANCOMPILER is now ignored entirely */ + $$ = (Node *)n; + } + ; + +opt_trusted: + TRUSTED { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +/* This ought to be just func_name, but that causes reduce/reduce conflicts + * (CREATE LANGUAGE is the only place where func_name isn't followed by '('). + * Work around by using simple names, instead. + */ +handler_name: + name { $$ = list_make1(makeString($1)); } + | name attrs { $$ = lcons(makeString($1), $2); } + ; + +opt_validator: + VALIDATOR handler_name { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +opt_lancompiler: + LANCOMPILER Sconst { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + +DropPLangStmt: + DROP opt_procedural LANGUAGE ColId_or_Sconst opt_drop_behavior + { + DropPLangStmt *n = makeNode(DropPLangStmt); + n->plname = $4; + n->behavior = $5; + n->missing_ok = false; + $$ = (Node *)n; + } + | DROP opt_procedural LANGUAGE IF_P EXISTS ColId_or_Sconst opt_drop_behavior + { + DropPLangStmt *n = makeNode(DropPLangStmt); + n->plname = $6; + n->behavior = $7; + n->missing_ok = true; + $$ = (Node *)n; + } + ; + +opt_procedural: + PROCEDURAL {} + | /*EMPTY*/ {} + ; + +/***************************************************************************** + * + * QUERY: + * CREATE TABLESPACE tablespace LOCATION '/path/to/tablespace/' + * + *****************************************************************************/ + +CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst + { + CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt); + n->tablespacename = $3; + n->owner = $4; + n->location = $6; + $$ = (Node *) n; + } + ; + +OptTableSpaceOwner: OWNER name { $$ = $2; } + | /*EMPTY */ { $$ = NULL; } + ; + +/***************************************************************************** + * + * QUERY : + * DROP TABLESPACE + * + * No need for drop behaviour as we cannot implement dependencies for + * objects in other databases; we can only support RESTRICT. + * + ****************************************************************************/ + +DropTableSpaceStmt: DROP TABLESPACE name + { + DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); + n->tablespacename = $3; + n->missing_ok = false; + $$ = (Node *) n; + } + | DROP TABLESPACE IF_P EXISTS name + { + DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt); + n->tablespacename = $5; + n->missing_ok = true; + $$ = (Node *) n; + } + ; + +/***************************************************************************** + * + * QUERIES : + * CREATE TRIGGER ... + * DROP TRIGGER ... + * + *****************************************************************************/ + +CreateTrigStmt: + CREATE TRIGGER name TriggerActionTime TriggerEvents ON + qualified_name TriggerForSpec EXECUTE PROCEDURE + func_name '(' TriggerFuncArgs ')' + { + CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->trigname = $3; + n->relation = $7; + n->funcname = $11; + n->args = $13; + n->before = $4; + n->row = $8; + memcpy(n->actions, $5, 4); + n->isconstraint = FALSE; + n->deferrable = FALSE; + n->initdeferred = FALSE; + n->constrrel = NULL; + $$ = (Node *)n; + } + | CREATE CONSTRAINT TRIGGER name AFTER TriggerEvents ON + qualified_name OptConstrFromTable + ConstraintAttributeSpec + FOR EACH ROW EXECUTE PROCEDURE + func_name '(' TriggerFuncArgs ')' + { + CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->trigname = $4; + n->relation = $8; + n->funcname = $16; + n->args = $18; + n->before = FALSE; + n->row = TRUE; + memcpy(n->actions, $6, 4); + n->isconstraint = TRUE; + n->deferrable = ($10 & 1) != 0; + n->initdeferred = ($10 & 2) != 0; + + n->constrrel = $9; + $$ = (Node *)n; + } + ; + +TriggerActionTime: + BEFORE { $$ = TRUE; } + | AFTER { $$ = FALSE; } + ; + +TriggerEvents: + TriggerOneEvent + { + char *e = palloc(4); + e[0] = $1; e[1] = '\0'; + $$ = e; + } + | TriggerOneEvent OR TriggerOneEvent + { + char *e = palloc(4); + e[0] = $1; e[1] = $3; e[2] = '\0'; + $$ = e; + } + | TriggerOneEvent OR TriggerOneEvent OR TriggerOneEvent + { + char *e = palloc(4); + e[0] = $1; e[1] = $3; e[2] = $5; e[3] = '\0'; + $$ = e; + } + ; + +TriggerOneEvent: + INSERT { $$ = 'i'; } + | DELETE_P { $$ = 'd'; } + | UPDATE { $$ = 'u'; } + ; + +TriggerForSpec: + FOR TriggerForOpt TriggerForType + { + $$ = $3; + } + | /* EMPTY */ + { + /* + * If ROW/STATEMENT not specified, default to + * STATEMENT, per SQL + */ + $$ = FALSE; + } + ; + +TriggerForOpt: + EACH {} + | /*EMPTY*/ {} + ; + +TriggerForType: + ROW { $$ = TRUE; } + | STATEMENT { $$ = FALSE; } + ; + +TriggerFuncArgs: + TriggerFuncArg { $$ = list_make1($1); } + | TriggerFuncArgs ',' TriggerFuncArg { $$ = lappend($1, $3); } + | /*EMPTY*/ { $$ = NIL; } + ; + +TriggerFuncArg: + ICONST + { + char buf[64]; + snprintf(buf, sizeof(buf), "%d", $1); + $$ = makeString(pstrdup(buf)); + } + | FCONST { $$ = makeString($1); } + | Sconst { $$ = makeString($1); } + | BCONST { $$ = makeString($1); } + | XCONST { $$ = makeString($1); } + | ColId { $$ = makeString($1); } + ; + +OptConstrFromTable: + FROM qualified_name { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + +ConstraintAttributeSpec: + ConstraintDeferrabilitySpec + { $$ = $1; } + | ConstraintDeferrabilitySpec ConstraintTimeSpec + { + if ($1 == 0 && $2 != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("constraint declared INITIALLY DEFERRED must be DEFERRABLE"))); + $$ = $1 | $2; + } + | ConstraintTimeSpec + { + if ($1 != 0) + $$ = 3; + else + $$ = 0; + } + | ConstraintTimeSpec ConstraintDeferrabilitySpec + { + if ($2 == 0 && $1 != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("constraint declared INITIALLY DEFERRED must be DEFERRABLE"))); + $$ = $1 | $2; + } + | /*EMPTY*/ + { $$ = 0; } + ; + +ConstraintDeferrabilitySpec: + NOT DEFERRABLE { $$ = 0; } + | DEFERRABLE { $$ = 1; } + ; + +ConstraintTimeSpec: + INITIALLY IMMEDIATE { $$ = 0; } + | INITIALLY DEFERRED { $$ = 2; } + ; + + +DropTrigStmt: + DROP TRIGGER name ON qualified_name opt_drop_behavior + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = $5; + n->property = $3; + n->behavior = $6; + n->removeType = OBJECT_TRIGGER; + n->missing_ok = false; + $$ = (Node *) n; + } + | DROP TRIGGER IF_P EXISTS name ON qualified_name opt_drop_behavior + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = $7; + n->property = $5; + n->behavior = $8; + n->removeType = OBJECT_TRIGGER; + n->missing_ok = true; + $$ = (Node *) n; + } + ; + + +/***************************************************************************** + * + * QUERIES : + * CREATE ASSERTION ... + * DROP ASSERTION ... + * + *****************************************************************************/ + +CreateAssertStmt: + CREATE ASSERTION name CHECK '(' a_expr ')' + ConstraintAttributeSpec + { + CreateTrigStmt *n = makeNode(CreateTrigStmt); + n->trigname = $3; + n->args = list_make1($6); + n->isconstraint = TRUE; + n->deferrable = ($8 & 1) != 0; + n->initdeferred = ($8 & 2) != 0; + + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("CREATE ASSERTION is not yet implemented"))); + + $$ = (Node *)n; + } + ; + +DropAssertStmt: + DROP ASSERTION name opt_drop_behavior + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = NULL; + n->property = $3; + n->behavior = $4; + n->removeType = OBJECT_TRIGGER; /* XXX */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("DROP ASSERTION is not yet implemented"))); + $$ = (Node *) n; + } + ; + + +/***************************************************************************** + * + * QUERY : + * define (aggregate,operator,type) + * + *****************************************************************************/ + +DefineStmt: + CREATE AGGREGATE func_name aggr_args definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_AGGREGATE; + n->oldstyle = false; + n->defnames = $3; + n->args = $4; + n->definition = $5; + $$ = (Node *)n; + } + | CREATE AGGREGATE func_name old_aggr_definition + { + /* old-style (pre-8.2) syntax for CREATE AGGREGATE */ + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_AGGREGATE; + n->oldstyle = true; + n->defnames = $3; + n->args = NIL; + n->definition = $4; + $$ = (Node *)n; + } + | CREATE OPERATOR any_operator definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_OPERATOR; + n->oldstyle = false; + n->defnames = $3; + n->args = NIL; + n->definition = $4; + $$ = (Node *)n; + } + | CREATE TYPE_P any_name definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TYPE; + n->oldstyle = false; + n->defnames = $3; + n->args = NIL; + n->definition = $4; + $$ = (Node *)n; + } + | CREATE TYPE_P any_name + { + /* Shell type (identified by lack of definition) */ + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TYPE; + n->oldstyle = false; + n->defnames = $3; + n->args = NIL; + n->definition = NIL; + $$ = (Node *)n; + } + | CREATE TYPE_P any_name AS '(' TableFuncElementList ')' + { + CompositeTypeStmt *n = makeNode(CompositeTypeStmt); + RangeVar *r = makeNode(RangeVar); + + /* can't use qualified_name, sigh */ + switch (list_length($3)) + { + case 1: + r->catalogname = NULL; + r->schemaname = NULL; + r->relname = strVal(linitial($3)); + break; + case 2: + r->catalogname = NULL; + r->schemaname = strVal(linitial($3)); + r->relname = strVal(lsecond($3)); + break; + case 3: + r->catalogname = strVal(linitial($3)); + r->schemaname = strVal(lsecond($3)); + r->relname = strVal(lthird($3)); + break; + default: + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("improper qualified name (too many dotted names): %s", + NameListToString($3)))); + break; + } + n->typevar = r; + n->coldeflist = $6; + $$ = (Node *)n; + } + | CREATE TYPE_P any_name AS ENUM_P '(' enum_val_list ')' + { + CreateEnumStmt *n = makeNode(CreateEnumStmt); + n->typename = $3; + n->vals = $7; + $$ = (Node *)n; + } + | CREATE TEXT_P SEARCH PARSER any_name definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSPARSER; + n->args = NIL; + n->defnames = $5; + n->definition = $6; + $$ = (Node *)n; + } + | CREATE TEXT_P SEARCH DICTIONARY any_name definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSDICTIONARY; + n->args = NIL; + n->defnames = $5; + n->definition = $6; + $$ = (Node *)n; + } + | CREATE TEXT_P SEARCH TEMPLATE any_name definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSTEMPLATE; + n->args = NIL; + n->defnames = $5; + n->definition = $6; + $$ = (Node *)n; + } + | CREATE TEXT_P SEARCH CONFIGURATION any_name definition + { + DefineStmt *n = makeNode(DefineStmt); + n->kind = OBJECT_TSCONFIGURATION; + n->args = NIL; + n->defnames = $5; + n->definition = $6; + $$ = (Node *)n; + } + ; + +definition: '(' def_list ')' { $$ = $2; } + ; + +def_list: def_elem { $$ = list_make1($1); } + | def_list ',' def_elem { $$ = lappend($1, $3); } + ; + +def_elem: ColLabel '=' def_arg + { + $$ = makeDefElem($1, (Node *)$3); + } + | ColLabel + { + $$ = makeDefElem($1, NULL); + } + ; + +/* Note: any simple identifier will be returned as a type name! */ +def_arg: func_type { $$ = (Node *)$1; } + | reserved_keyword { $$ = (Node *)makeString(pstrdup($1)); } + | qual_all_Op { $$ = (Node *)$1; } + | NumericOnly { $$ = (Node *)$1; } + | Sconst { $$ = (Node *)makeString($1); } + ; + +aggr_args: '(' type_list ')' { $$ = $2; } + | '(' '*' ')' { $$ = NIL; } + ; + +old_aggr_definition: '(' old_aggr_list ')' { $$ = $2; } + ; + +old_aggr_list: old_aggr_elem { $$ = list_make1($1); } + | old_aggr_list ',' old_aggr_elem { $$ = lappend($1, $3); } + ; + +old_aggr_elem: IDENT '=' def_arg + { + $$ = makeDefElem($1, (Node *)$3); + } + ; + +enum_val_list: Sconst + { $$ = list_make1(makeString($1)); } + | enum_val_list ',' Sconst + { $$ = lappend($1, makeString($3)); } + ; + + +/***************************************************************************** + * + * QUERIES : + * CREATE OPERATOR CLASS ... + * CREATE OPERATOR FAMILY ... + * ALTER OPERATOR FAMILY ... + * DROP OPERATOR CLASS ... + * DROP OPERATOR FAMILY ... + * + *****************************************************************************/ + +CreateOpClassStmt: + CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename + USING access_method opt_opfamily AS opclass_item_list + { + CreateOpClassStmt *n = makeNode(CreateOpClassStmt); + n->opclassname = $4; + n->isDefault = $5; + n->datatype = $8; + n->amname = $10; + n->opfamilyname = $11; + n->items = $13; + $$ = (Node *) n; + } + ; + +opclass_item_list: + opclass_item { $$ = list_make1($1); } + | opclass_item_list ',' opclass_item { $$ = lappend($1, $3); } + ; + +opclass_item: + OPERATOR Iconst any_operator opt_recheck + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; + n->name = $3; + n->args = NIL; + n->number = $2; + n->recheck = $4; + $$ = (Node *) n; + } + | OPERATOR Iconst any_operator '(' oper_argtypes ')' opt_recheck + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; + n->name = $3; + n->args = $5; + n->number = $2; + n->recheck = $7; + $$ = (Node *) n; + } + | FUNCTION Iconst func_name func_args + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; + n->name = $3; + n->args = extractArgTypes($4); + n->number = $2; + $$ = (Node *) n; + } + | FUNCTION Iconst '(' type_list ')' func_name func_args + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; + n->name = $6; + n->args = extractArgTypes($7); + n->number = $2; + n->class_args = $4; + $$ = (Node *) n; + } + | STORAGE Typename + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_STORAGETYPE; + n->storedtype = $2; + $$ = (Node *) n; + } + ; + +opt_default: DEFAULT { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_opfamily: FAMILY any_name { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +opt_recheck: RECHECK { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + + +CreateOpFamilyStmt: + CREATE OPERATOR FAMILY any_name USING access_method + { + CreateOpFamilyStmt *n = makeNode(CreateOpFamilyStmt); + n->opfamilyname = $4; + n->amname = $6; + $$ = (Node *) n; + } + ; + +AlterOpFamilyStmt: + ALTER OPERATOR FAMILY any_name USING access_method ADD_P opclass_item_list + { + AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt); + n->opfamilyname = $4; + n->amname = $6; + n->isDrop = false; + n->items = $8; + $$ = (Node *) n; + } + | ALTER OPERATOR FAMILY any_name USING access_method DROP opclass_drop_list + { + AlterOpFamilyStmt *n = makeNode(AlterOpFamilyStmt); + n->opfamilyname = $4; + n->amname = $6; + n->isDrop = true; + n->items = $8; + $$ = (Node *) n; + } + ; + +opclass_drop_list: + opclass_drop { $$ = list_make1($1); } + | opclass_drop_list ',' opclass_drop { $$ = lappend($1, $3); } + ; + +opclass_drop: + OPERATOR Iconst '(' type_list ')' + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_OPERATOR; + n->number = $2; + n->args = $4; + $$ = (Node *) n; + } + | FUNCTION Iconst '(' type_list ')' + { + CreateOpClassItem *n = makeNode(CreateOpClassItem); + n->itemtype = OPCLASS_ITEM_FUNCTION; + n->number = $2; + n->args = $4; + $$ = (Node *) n; + } + ; + + +DropOpClassStmt: + DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior + { + RemoveOpClassStmt *n = makeNode(RemoveOpClassStmt); + n->opclassname = $4; + n->amname = $6; + n->behavior = $7; + n->missing_ok = false; + $$ = (Node *) n; + } + | DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior + { + RemoveOpClassStmt *n = makeNode(RemoveOpClassStmt); + n->opclassname = $6; + n->amname = $8; + n->behavior = $9; + n->missing_ok = true; + $$ = (Node *) n; + } + ; + +DropOpFamilyStmt: + DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior + { + RemoveOpFamilyStmt *n = makeNode(RemoveOpFamilyStmt); + n->opfamilyname = $4; + n->amname = $6; + n->behavior = $7; + n->missing_ok = false; + $$ = (Node *) n; + } + | DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior + { + RemoveOpFamilyStmt *n = makeNode(RemoveOpFamilyStmt); + n->opfamilyname = $6; + n->amname = $8; + n->behavior = $9; + n->missing_ok = true; + $$ = (Node *) n; + } + ; + + +/***************************************************************************** + * + * QUERY: + * + * DROP OWNED BY username [, username ...] [ RESTRICT | CASCADE ] + * REASSIGN OWNED BY username [, username ...] TO username + * + *****************************************************************************/ +DropOwnedStmt: + DROP OWNED BY name_list opt_drop_behavior + { + DropOwnedStmt *n = makeNode(DropOwnedStmt); + n->roles = $4; + n->behavior = $5; + $$ = (Node *)n; + } + ; + +ReassignOwnedStmt: + REASSIGN OWNED BY name_list TO name + { + ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt); + n->roles = $4; + n->newrole = $6; + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * + * QUERY: + * + * DROP itemtype [ IF EXISTS ] itemname [, itemname ...] + * [ RESTRICT | CASCADE ] + * + *****************************************************************************/ + +DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior + { + DropStmt *n = makeNode(DropStmt); + n->removeType = $2; + n->missing_ok = TRUE; + n->objects = $5; + n->behavior = $6; + $$ = (Node *)n; + } + | DROP drop_type any_name_list opt_drop_behavior + { + DropStmt *n = makeNode(DropStmt); + n->removeType = $2; + n->missing_ok = FALSE; + n->objects = $3; + n->behavior = $4; + $$ = (Node *)n; + } + ; + + +drop_type: TABLE { $$ = OBJECT_TABLE; } + | SEQUENCE { $$ = OBJECT_SEQUENCE; } + | VIEW { $$ = OBJECT_VIEW; } + | INDEX { $$ = OBJECT_INDEX; } + | TYPE_P { $$ = OBJECT_TYPE; } + | DOMAIN_P { $$ = OBJECT_DOMAIN; } + | CONVERSION_P { $$ = OBJECT_CONVERSION; } + | SCHEMA { $$ = OBJECT_SCHEMA; } + | TEXT_P SEARCH PARSER { $$ = OBJECT_TSPARSER; } + | TEXT_P SEARCH DICTIONARY { $$ = OBJECT_TSDICTIONARY; } + | TEXT_P SEARCH TEMPLATE { $$ = OBJECT_TSTEMPLATE; } + | TEXT_P SEARCH CONFIGURATION { $$ = OBJECT_TSCONFIGURATION; } + ; + +any_name_list: + any_name { $$ = list_make1($1); } + | any_name_list ',' any_name { $$ = lappend($1, $3); } + ; + +any_name: ColId { $$ = list_make1(makeString($1)); } + | ColId attrs { $$ = lcons(makeString($1), $2); } + ; + +attrs: '.' attr_name + { $$ = list_make1(makeString($2)); } + | attrs '.' attr_name + { $$ = lappend($1, makeString($3)); } + ; + + +/***************************************************************************** + * + * QUERY: + * truncate table relname1, relname2, ... + * + *****************************************************************************/ + +TruncateStmt: + TRUNCATE opt_table qualified_name_list opt_drop_behavior + { + TruncateStmt *n = makeNode(TruncateStmt); + n->relations = $3; + n->behavior = $4; + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * + * The COMMENT ON statement can take different forms based upon the type of + * the object associated with the comment. The form of the statement is: + * + * COMMENT ON [ [ DATABASE | DOMAIN | INDEX | SEQUENCE | TABLE | TYPE | VIEW | + * CONVERSION | LANGUAGE | OPERATOR CLASS | LARGE OBJECT | + * CAST | COLUMN | SCHEMA | TABLESPACE | ROLE | + * TEXT SEARCH PARSER | TEXT SEARCH DICTIONARY | + * TEXT SEARCH TEMPLATE | + * TEXT SEARCH CONFIGURATION ] | + * AGGREGATE (arg1, ...) | + * FUNCTION (arg1, arg2, ...) | + * OPERATOR (leftoperand_typ, rightoperand_typ) | + * TRIGGER ON | + * CONSTRAINT ON | + * RULE ON ] + * IS 'text' + * + *****************************************************************************/ + +CommentStmt: + COMMENT ON comment_type any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; + n->objname = $4; + n->objargs = NIL; + n->comment = $6; + $$ = (Node *) n; + } + | COMMENT ON AGGREGATE func_name aggr_args IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_AGGREGATE; + n->objname = $4; + n->objargs = $5; + n->comment = $7; + $$ = (Node *) n; + } + | COMMENT ON FUNCTION func_name func_args IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_FUNCTION; + n->objname = $4; + n->objargs = extractArgTypes($5); + n->comment = $7; + $$ = (Node *) n; + } + | COMMENT ON OPERATOR any_operator '(' oper_argtypes ')' + IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPERATOR; + n->objname = $4; + n->objargs = $6; + n->comment = $9; + $$ = (Node *) n; + } + | COMMENT ON CONSTRAINT name ON any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_CONSTRAINT; + n->objname = lappend($6, makeString($4)); + n->objargs = NIL; + n->comment = $8; + $$ = (Node *) n; + } + | COMMENT ON RULE name ON any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_RULE; + n->objname = lappend($6, makeString($4)); + n->objargs = NIL; + n->comment = $8; + $$ = (Node *) n; + } + | COMMENT ON RULE name IS comment_text + { + /* Obsolete syntax supported for awhile for compatibility */ + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_RULE; + n->objname = list_make1(makeString($4)); + n->objargs = NIL; + n->comment = $6; + $$ = (Node *) n; + } + | COMMENT ON TRIGGER name ON any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TRIGGER; + n->objname = lappend($6, makeString($4)); + n->objargs = NIL; + n->comment = $8; + $$ = (Node *) n; + } + | COMMENT ON OPERATOR CLASS any_name USING access_method IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPCLASS; + n->objname = $5; + n->objargs = list_make1(makeString($7)); + n->comment = $9; + $$ = (Node *) n; + } + | COMMENT ON OPERATOR FAMILY any_name USING access_method IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_OPFAMILY; + n->objname = $5; + n->objargs = list_make1(makeString($7)); + n->comment = $9; + $$ = (Node *) n; + } + | COMMENT ON LARGE_P OBJECT_P NumericOnly IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_LARGEOBJECT; + n->objname = list_make1($5); + n->objargs = NIL; + n->comment = $7; + $$ = (Node *) n; + } + | COMMENT ON CAST '(' Typename AS Typename ')' IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_CAST; + n->objname = list_make1($5); + n->objargs = list_make1($7); + n->comment = $10; + $$ = (Node *) n; + } + | COMMENT ON opt_procedural LANGUAGE any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_LANGUAGE; + n->objname = $5; + n->objargs = NIL; + n->comment = $7; + $$ = (Node *) n; + } + | COMMENT ON TEXT_P SEARCH PARSER any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSPARSER; + n->objname = $6; + n->comment = $8; + $$ = (Node *) n; + } + | COMMENT ON TEXT_P SEARCH DICTIONARY any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSDICTIONARY; + n->objname = $6; + n->comment = $8; + $$ = (Node *) n; + } + | COMMENT ON TEXT_P SEARCH TEMPLATE any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSTEMPLATE; + n->objname = $6; + n->comment = $8; + $$ = (Node *) n; + } + | COMMENT ON TEXT_P SEARCH CONFIGURATION any_name IS comment_text + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = OBJECT_TSCONFIGURATION; + n->objname = $6; + n->comment = $8; + $$ = (Node *) n; + } + ; + +comment_type: + COLUMN { $$ = OBJECT_COLUMN; } + | DATABASE { $$ = OBJECT_DATABASE; } + | SCHEMA { $$ = OBJECT_SCHEMA; } + | INDEX { $$ = OBJECT_INDEX; } + | SEQUENCE { $$ = OBJECT_SEQUENCE; } + | TABLE { $$ = OBJECT_TABLE; } + | DOMAIN_P { $$ = OBJECT_TYPE; } + | TYPE_P { $$ = OBJECT_TYPE; } + | VIEW { $$ = OBJECT_VIEW; } + | CONVERSION_P { $$ = OBJECT_CONVERSION; } + | TABLESPACE { $$ = OBJECT_TABLESPACE; } + | ROLE { $$ = OBJECT_ROLE; } + ; + +comment_text: + Sconst { $$ = $1; } + | NULL_P { $$ = NULL; } + ; + +/***************************************************************************** + * + * QUERY: + * fetch/move + * + *****************************************************************************/ + +FetchStmt: FETCH fetch_direction from_in name + { + FetchStmt *n = (FetchStmt *) $2; + n->portalname = $4; + n->ismove = FALSE; + $$ = (Node *)n; + } + | FETCH name + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + n->portalname = $2; + n->ismove = FALSE; + $$ = (Node *)n; + } + | MOVE fetch_direction from_in name + { + FetchStmt *n = (FetchStmt *) $2; + n->portalname = $4; + n->ismove = TRUE; + $$ = (Node *)n; + } + | MOVE name + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + n->portalname = $2; + n->ismove = TRUE; + $$ = (Node *)n; + } + ; + +fetch_direction: + /*EMPTY*/ + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + $$ = (Node *)n; + } + | NEXT + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + $$ = (Node *)n; + } + | PRIOR + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = 1; + $$ = (Node *)n; + } + | FIRST_P + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_ABSOLUTE; + n->howMany = 1; + $$ = (Node *)n; + } + | LAST_P + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_ABSOLUTE; + n->howMany = -1; + $$ = (Node *)n; + } + | ABSOLUTE_P SignedIconst + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_ABSOLUTE; + n->howMany = $2; + $$ = (Node *)n; + } + | RELATIVE_P SignedIconst + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_RELATIVE; + n->howMany = $2; + $$ = (Node *)n; + } + | SignedIconst + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = $1; + $$ = (Node *)n; + } + | ALL + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = FETCH_ALL; + $$ = (Node *)n; + } + | FORWARD + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = 1; + $$ = (Node *)n; + } + | FORWARD SignedIconst + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = $2; + $$ = (Node *)n; + } + | FORWARD ALL + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_FORWARD; + n->howMany = FETCH_ALL; + $$ = (Node *)n; + } + | BACKWARD + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = 1; + $$ = (Node *)n; + } + | BACKWARD SignedIconst + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = $2; + $$ = (Node *)n; + } + | BACKWARD ALL + { + FetchStmt *n = makeNode(FetchStmt); + n->direction = FETCH_BACKWARD; + n->howMany = FETCH_ALL; + $$ = (Node *)n; + } + ; + +from_in: FROM {} + | IN_P {} + ; + + +/***************************************************************************** + * + * GRANT and REVOKE statements + * + *****************************************************************************/ + +GrantStmt: GRANT privileges ON privilege_target TO grantee_list + opt_grant_grant_option + { + GrantStmt *n = makeNode(GrantStmt); + n->is_grant = true; + n->privileges = $2; + n->objtype = ($4)->objtype; + n->objects = ($4)->objs; + n->grantees = $6; + n->grant_option = $7; + $$ = (Node*)n; + } + ; + +RevokeStmt: + REVOKE privileges ON privilege_target + FROM grantee_list opt_drop_behavior + { + GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; + n->grant_option = false; + n->privileges = $2; + n->objtype = ($4)->objtype; + n->objects = ($4)->objs; + n->grantees = $6; + n->behavior = $7; + $$ = (Node *)n; + } + | REVOKE GRANT OPTION FOR privileges ON privilege_target + FROM grantee_list opt_drop_behavior + { + GrantStmt *n = makeNode(GrantStmt); + n->is_grant = false; + n->grant_option = true; + n->privileges = $5; + n->objtype = ($7)->objtype; + n->objects = ($7)->objs; + n->grantees = $9; + n->behavior = $10; + $$ = (Node *)n; + } + ; + + +/* + * A privilege list is represented as a list of strings; the validity of + * the privilege names gets checked at execution. This is a bit annoying + * but we have little choice because of the syntactic conflict with lists + * of role names in GRANT/REVOKE. What's more, we have to call out in + * the "privilege" production any reserved keywords that need to be usable + * as privilege names. + */ + +/* either ALL [PRIVILEGES] or a list of individual privileges */ +privileges: privilege_list + { $$ = $1; } + | ALL + { $$ = NIL; } + | ALL PRIVILEGES + { $$ = NIL; } + ; + +privilege_list: privilege + { $$ = list_make1(makeString($1)); } + | privilege_list ',' privilege + { $$ = lappend($1, makeString($3)); } + ; + +privilege: SELECT { $$ = pstrdup($1); } + | REFERENCES { $$ = pstrdup($1); } + | CREATE { $$ = pstrdup($1); } + | ColId { $$ = $1; } + ; + + +/* Don't bother trying to fold the first two rules into one using + * opt_table. You're going to get conflicts. + */ +privilege_target: + qualified_name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_RELATION; + n->objs = $1; + $$ = n; + } + | TABLE qualified_name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_RELATION; + n->objs = $2; + $$ = n; + } + | SEQUENCE qualified_name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_SEQUENCE; + n->objs = $2; + $$ = n; + } + | FUNCTION function_with_argtypes_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_FUNCTION; + n->objs = $2; + $$ = n; + } + | DATABASE name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_DATABASE; + n->objs = $2; + $$ = n; + } + | LANGUAGE name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_LANGUAGE; + n->objs = $2; + $$ = n; + } + | SCHEMA name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_NAMESPACE; + n->objs = $2; + $$ = n; + } + | TABLESPACE name_list + { + PrivTarget *n = makeNode(PrivTarget); + n->objtype = ACL_OBJECT_TABLESPACE; + n->objs = $2; + $$ = n; + } + ; + + +grantee_list: + grantee { $$ = list_make1($1); } + | grantee_list ',' grantee { $$ = lappend($1, $3); } + ; + +grantee: RoleId + { + PrivGrantee *n = makeNode(PrivGrantee); + /* This hack lets us avoid reserving PUBLIC as a keyword*/ + if (strcmp($1, "public") == 0) + n->rolname = NULL; + else + n->rolname = $1; + $$ = (Node *)n; + } + | GROUP_P RoleId + { + PrivGrantee *n = makeNode(PrivGrantee); + /* Treat GROUP PUBLIC as a synonym for PUBLIC */ + if (strcmp($2, "public") == 0) + n->rolname = NULL; + else + n->rolname = $2; + $$ = (Node *)n; + } + ; + + +opt_grant_grant_option: + WITH GRANT OPTION { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +function_with_argtypes_list: + function_with_argtypes { $$ = list_make1($1); } + | function_with_argtypes_list ',' function_with_argtypes + { $$ = lappend($1, $3); } + ; + +function_with_argtypes: + func_name func_args + { + FuncWithArgs *n = makeNode(FuncWithArgs); + n->funcname = $1; + n->funcargs = extractArgTypes($2); + $$ = n; + } + ; + +/***************************************************************************** + * + * GRANT and REVOKE ROLE statements + * + *****************************************************************************/ + +GrantRoleStmt: + GRANT privilege_list TO name_list opt_grant_admin_option opt_granted_by + { + GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = true; + n->granted_roles = $2; + n->grantee_roles = $4; + n->admin_opt = $5; + n->grantor = $6; + $$ = (Node*)n; + } + ; + +RevokeRoleStmt: + REVOKE privilege_list FROM name_list opt_granted_by opt_drop_behavior + { + GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = false; + n->admin_opt = false; + n->granted_roles = $2; + n->grantee_roles = $4; + n->behavior = $6; + $$ = (Node*)n; + } + | REVOKE ADMIN OPTION FOR privilege_list FROM name_list opt_granted_by opt_drop_behavior + { + GrantRoleStmt *n = makeNode(GrantRoleStmt); + n->is_grant = false; + n->admin_opt = true; + n->granted_roles = $5; + n->grantee_roles = $7; + n->behavior = $9; + $$ = (Node*)n; + } + ; + +opt_grant_admin_option: WITH ADMIN OPTION { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_granted_by: GRANTED BY RoleId { $$ = $3; } + | /*EMPTY*/ { $$ = NULL; } + ; + + +/***************************************************************************** + * + * QUERY: CREATE INDEX + * + * Note: we can't factor CONCURRENTLY into a separate production without + * making it a reserved word. + * + * Note: we cannot put TABLESPACE clause after WHERE clause unless we are + * willing to make TABLESPACE a fully reserved word. + *****************************************************************************/ + +IndexStmt: CREATE index_opt_unique INDEX index_name + ON qualified_name access_method_clause '(' index_params ')' + opt_definition OptTableSpace where_clause + { + IndexStmt *n = makeNode(IndexStmt); + n->unique = $2; + n->concurrent = false; + n->idxname = $4; + n->relation = $6; + n->accessMethod = $7; + n->indexParams = $9; + n->options = $11; + n->tableSpace = $12; + n->whereClause = $13; + $$ = (Node *)n; + } + | CREATE index_opt_unique INDEX CONCURRENTLY index_name + ON qualified_name access_method_clause '(' index_params ')' + opt_definition OptTableSpace where_clause + { + IndexStmt *n = makeNode(IndexStmt); + n->unique = $2; + n->concurrent = true; + n->idxname = $5; + n->relation = $7; + n->accessMethod = $8; + n->indexParams = $10; + n->options = $12; + n->tableSpace = $13; + n->whereClause = $14; + $$ = (Node *)n; + } + ; + +index_opt_unique: + UNIQUE { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +access_method_clause: + USING access_method { $$ = $2; } + | /*EMPTY*/ { $$ = DEFAULT_INDEX_TYPE; } + ; + +index_params: index_elem { $$ = list_make1($1); } + | index_params ',' index_elem { $$ = lappend($1, $3); } + ; + +/* + * Index attributes can be either simple column references, or arbitrary + * expressions in parens. For backwards-compatibility reasons, we allow + * an expression that's just a function call to be written without parens. + */ +index_elem: ColId opt_class opt_asc_desc opt_nulls_order + { + $$ = makeNode(IndexElem); + $$->name = $1; + $$->expr = NULL; + $$->opclass = $2; + $$->ordering = $3; + $$->nulls_ordering = $4; + } + | func_expr opt_class opt_asc_desc opt_nulls_order + { + $$ = makeNode(IndexElem); + $$->name = NULL; + $$->expr = $1; + $$->opclass = $2; + $$->ordering = $3; + $$->nulls_ordering = $4; + } + | '(' a_expr ')' opt_class opt_asc_desc opt_nulls_order + { + $$ = makeNode(IndexElem); + $$->name = NULL; + $$->expr = $2; + $$->opclass = $4; + $$->ordering = $5; + $$->nulls_ordering = $6; + } + ; + +opt_class: any_name { $$ = $1; } + | USING any_name { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +opt_asc_desc: ASC { $$ = SORTBY_ASC; } + | DESC { $$ = SORTBY_DESC; } + | /*EMPTY*/ { $$ = SORTBY_DEFAULT; } + ; + +opt_nulls_order: NULLS_FIRST { $$ = SORTBY_NULLS_FIRST; } + | NULLS_LAST { $$ = SORTBY_NULLS_LAST; } + | /*EMPTY*/ { $$ = SORTBY_NULLS_DEFAULT; } + ; + + +/***************************************************************************** + * + * QUERY: + * create [or replace] function + * [( { , })] + * returns + * as + * language [with parameters] + * + *****************************************************************************/ + +CreateFunctionStmt: + CREATE opt_or_replace FUNCTION func_name func_args + RETURNS func_return createfunc_opt_list opt_definition + { + CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->replace = $2; + n->funcname = $4; + n->parameters = $5; + n->returnType = $7; + n->options = $8; + n->withClause = $9; + $$ = (Node *)n; + } + | CREATE opt_or_replace FUNCTION func_name func_args + createfunc_opt_list opt_definition + { + CreateFunctionStmt *n = makeNode(CreateFunctionStmt); + n->replace = $2; + n->funcname = $4; + n->parameters = $5; + n->returnType = NULL; + n->options = $6; + n->withClause = $7; + $$ = (Node *)n; + } + ; + +opt_or_replace: + OR REPLACE { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +func_args: '(' func_args_list ')' { $$ = $2; } + | '(' ')' { $$ = NIL; } + ; + +func_args_list: + func_arg { $$ = list_make1($1); } + | func_args_list ',' func_arg { $$ = lappend($1, $3); } + ; + +/* + * The style with arg_class first is SQL99 standard, but Oracle puts + * param_name first; accept both since it's likely people will try both + * anyway. Don't bother trying to save productions by letting arg_class + * have an empty alternative ... you'll get shift/reduce conflicts. + * + * We can catch over-specified arguments here if we want to, + * but for now better to silently swallow typmod, etc. + * - thomas 2000-03-22 + */ +func_arg: + arg_class param_name func_type + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = $2; + n->argType = $3; + n->mode = $1; + $$ = n; + } + | param_name arg_class func_type + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = $1; + n->argType = $3; + n->mode = $2; + $$ = n; + } + | param_name func_type + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = $1; + n->argType = $2; + n->mode = FUNC_PARAM_IN; + $$ = n; + } + | arg_class func_type + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = NULL; + n->argType = $2; + n->mode = $1; + $$ = n; + } + | func_type + { + FunctionParameter *n = makeNode(FunctionParameter); + n->name = NULL; + n->argType = $1; + n->mode = FUNC_PARAM_IN; + $$ = n; + } + ; + +/* INOUT is SQL99 standard, IN OUT is for Oracle compatibility */ +arg_class: IN_P { $$ = FUNC_PARAM_IN; } + | OUT_P { $$ = FUNC_PARAM_OUT; } + | INOUT { $$ = FUNC_PARAM_INOUT; } + | IN_P OUT_P { $$ = FUNC_PARAM_INOUT; } + ; + +/* + * Ideally param_name should be ColId, but that causes too many conflicts. + */ +param_name: type_function_name + ; + +func_return: + func_type + { + /* We can catch over-specified results here if we want to, + * but for now better to silently swallow typmod, etc. + * - thomas 2000-03-22 + */ + $$ = $1; + } + ; + +/* + * We would like to make the %TYPE productions here be ColId attrs etc, + * but that causes reduce/reduce conflicts. type_function_name + * is next best choice. + */ +func_type: Typename { $$ = $1; } + | type_function_name attrs '%' TYPE_P + { + $$ = makeTypeNameFromNameList(lcons(makeString($1), $2)); + $$->pct_type = true; + $$->location = @1; + } + | SETOF type_function_name attrs '%' TYPE_P + { + $$ = makeTypeNameFromNameList(lcons(makeString($2), $3)); + $$->pct_type = true; + $$->setof = TRUE; + $$->location = @2; + } + ; + + +createfunc_opt_list: + /* Must be at least one to prevent conflict */ + createfunc_opt_item { $$ = list_make1($1); } + | createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); } + ; + +/* + * Options common to both CREATE FUNCTION and ALTER FUNCTION + */ +common_func_opt_item: + CALLED ON NULL_P INPUT_P + { + $$ = makeDefElem("strict", (Node *)makeInteger(FALSE)); + } + | RETURNS NULL_P ON NULL_P INPUT_P + { + $$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); + } + | STRICT_P + { + $$ = makeDefElem("strict", (Node *)makeInteger(TRUE)); + } + | IMMUTABLE + { + $$ = makeDefElem("volatility", (Node *)makeString("immutable")); + } + | STABLE + { + $$ = makeDefElem("volatility", (Node *)makeString("stable")); + } + | VOLATILE + { + $$ = makeDefElem("volatility", (Node *)makeString("volatile")); + } + | EXTERNAL SECURITY DEFINER + { + $$ = makeDefElem("security", (Node *)makeInteger(TRUE)); + } + | EXTERNAL SECURITY INVOKER + { + $$ = makeDefElem("security", (Node *)makeInteger(FALSE)); + } + | SECURITY DEFINER + { + $$ = makeDefElem("security", (Node *)makeInteger(TRUE)); + } + | SECURITY INVOKER + { + $$ = makeDefElem("security", (Node *)makeInteger(FALSE)); + } + | COST NumericOnly + { + $$ = makeDefElem("cost", (Node *)$2); + } + | ROWS NumericOnly + { + $$ = makeDefElem("rows", (Node *)$2); + } + | SetResetClause + { + /* we abuse the normal content of a DefElem here */ + $$ = makeDefElem("set", (Node *)$1); + } + ; + +createfunc_opt_item: + AS func_as + { + $$ = makeDefElem("as", (Node *)$2); + } + | LANGUAGE ColId_or_Sconst + { + $$ = makeDefElem("language", (Node *)makeString($2)); + } + | common_func_opt_item + { + $$ = $1; + } + ; + +func_as: Sconst { $$ = list_make1(makeString($1)); } + | Sconst ',' Sconst + { + $$ = list_make2(makeString($1), makeString($3)); + } + ; + +opt_definition: + WITH definition { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +/***************************************************************************** + * ALTER FUNCTION + * + * RENAME and OWNER subcommands are already provided by the generic + * ALTER infrastructure, here we just specify alterations that can + * only be applied to functions. + * + *****************************************************************************/ +AlterFunctionStmt: + ALTER FUNCTION function_with_argtypes alterfunc_opt_list opt_restrict + { + AlterFunctionStmt *n = makeNode(AlterFunctionStmt); + n->func = $3; + n->actions = $4; + $$ = (Node *) n; + } + ; + +alterfunc_opt_list: + /* At least one option must be specified */ + common_func_opt_item { $$ = list_make1($1); } + | alterfunc_opt_list common_func_opt_item { $$ = lappend($1, $2); } + ; + +/* Ignored, merely for SQL compliance */ +opt_restrict: + RESTRICT + | /* EMPTY */ + ; + + +/***************************************************************************** + * + * QUERY: + * + * DROP FUNCTION funcname (arg1, arg2, ...) [ RESTRICT | CASCADE ] + * DROP AGGREGATE aggname (arg1, ...) [ RESTRICT | CASCADE ] + * DROP OPERATOR opname (leftoperand_typ, rightoperand_typ) [ RESTRICT | CASCADE ] + * + *****************************************************************************/ + +RemoveFuncStmt: + DROP FUNCTION func_name func_args opt_drop_behavior + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_FUNCTION; + n->name = $3; + n->args = extractArgTypes($4); + n->behavior = $5; + n->missing_ok = false; + $$ = (Node *)n; + } + | DROP FUNCTION IF_P EXISTS func_name func_args opt_drop_behavior + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_FUNCTION; + n->name = $5; + n->args = extractArgTypes($6); + n->behavior = $7; + n->missing_ok = true; + $$ = (Node *)n; + } + ; + +RemoveAggrStmt: + DROP AGGREGATE func_name aggr_args opt_drop_behavior + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_AGGREGATE; + n->name = $3; + n->args = $4; + n->behavior = $5; + n->missing_ok = false; + $$ = (Node *)n; + } + | DROP AGGREGATE IF_P EXISTS func_name aggr_args opt_drop_behavior + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_AGGREGATE; + n->name = $5; + n->args = $6; + n->behavior = $7; + n->missing_ok = true; + $$ = (Node *)n; + } + ; + +RemoveOperStmt: + DROP OPERATOR any_operator '(' oper_argtypes ')' opt_drop_behavior + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_OPERATOR; + n->name = $3; + n->args = $5; + n->behavior = $7; + n->missing_ok = false; + $$ = (Node *)n; + } + | DROP OPERATOR IF_P EXISTS any_operator '(' oper_argtypes ')' opt_drop_behavior + { + RemoveFuncStmt *n = makeNode(RemoveFuncStmt); + n->kind = OBJECT_OPERATOR; + n->name = $5; + n->args = $7; + n->behavior = $9; + n->missing_ok = true; + $$ = (Node *)n; + } + ; + +oper_argtypes: + Typename + { + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("missing argument"), + errhint("Use NONE to denote the missing argument of a unary operator."))); + } + | Typename ',' Typename + { $$ = list_make2($1, $3); } + | NONE ',' Typename /* left unary */ + { $$ = list_make2(NULL, $3); } + | Typename ',' NONE /* right unary */ + { $$ = list_make2($1, NULL); } + ; + +any_operator: + all_Op + { $$ = list_make1(makeString($1)); } + | ColId '.' any_operator + { $$ = lcons(makeString($1), $3); } + ; + + +/***************************************************************************** + * + * CREATE CAST / DROP CAST + * + *****************************************************************************/ + +CreateCastStmt: CREATE CAST '(' Typename AS Typename ')' + WITH FUNCTION function_with_argtypes cast_context + { + CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = $4; + n->targettype = $6; + n->func = $10; + n->context = (CoercionContext) $11; + $$ = (Node *)n; + } + | CREATE CAST '(' Typename AS Typename ')' + WITHOUT FUNCTION cast_context + { + CreateCastStmt *n = makeNode(CreateCastStmt); + n->sourcetype = $4; + n->targettype = $6; + n->func = NULL; + n->context = (CoercionContext) $10; + $$ = (Node *)n; + } + ; + +cast_context: AS IMPLICIT_P { $$ = COERCION_IMPLICIT; } + | AS ASSIGNMENT { $$ = COERCION_ASSIGNMENT; } + | /*EMPTY*/ { $$ = COERCION_EXPLICIT; } + ; + + +DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_behavior + { + DropCastStmt *n = makeNode(DropCastStmt); + n->sourcetype = $5; + n->targettype = $7; + n->behavior = $9; + n->missing_ok = $3; + $$ = (Node *)n; + } + ; + +opt_if_exists: IF_P EXISTS { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + + +/***************************************************************************** + * + * QUERY: + * + * REINDEX type [FORCE] + * + * FORCE no longer does anything, but we accept it for backwards compatibility + *****************************************************************************/ + +ReindexStmt: + REINDEX reindex_type qualified_name opt_force + { + ReindexStmt *n = makeNode(ReindexStmt); + n->kind = $2; + n->relation = $3; + n->name = NULL; + $$ = (Node *)n; + } + | REINDEX SYSTEM_P name opt_force + { + ReindexStmt *n = makeNode(ReindexStmt); + n->kind = OBJECT_DATABASE; + n->name = $3; + n->relation = NULL; + n->do_system = true; + n->do_user = false; + $$ = (Node *)n; + } + | REINDEX DATABASE name opt_force + { + ReindexStmt *n = makeNode(ReindexStmt); + n->kind = OBJECT_DATABASE; + n->name = $3; + n->relation = NULL; + n->do_system = true; + n->do_user = true; + $$ = (Node *)n; + } + ; + +reindex_type: + INDEX { $$ = OBJECT_INDEX; } + | TABLE { $$ = OBJECT_TABLE; } + ; + +opt_force: FORCE { $$ = TRUE; } + | /* EMPTY */ { $$ = FALSE; } + ; + + +/***************************************************************************** + * + * ALTER THING name RENAME TO newname + * + *****************************************************************************/ + +RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_AGGREGATE; + n->object = $3; + n->objarg = $4; + n->newname = $7; + $$ = (Node *)n; + } + | ALTER CONVERSION_P any_name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_CONVERSION; + n->object = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER DATABASE database_name RENAME TO database_name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_DATABASE; + n->subname = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER FUNCTION function_with_argtypes RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_FUNCTION; + n->object = $3->funcname; + n->objarg = $3->funcargs; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER GROUP_P RoleId RENAME TO RoleId + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; + n->subname = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER opt_procedural LANGUAGE name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_LANGUAGE; + n->subname = $4; + n->newname = $7; + $$ = (Node *)n; + } + | ALTER OPERATOR CLASS any_name USING access_method RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_OPCLASS; + n->object = $4; + n->subname = $6; + n->newname = $9; + $$ = (Node *)n; + } + | ALTER OPERATOR FAMILY any_name USING access_method RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_OPFAMILY; + n->object = $4; + n->subname = $6; + n->newname = $9; + $$ = (Node *)n; + } + | ALTER SCHEMA name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SCHEMA; + n->subname = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER TABLE relation_expr RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLE; + n->relation = $3; + n->subname = NULL; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER SEQUENCE relation_expr RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_SEQUENCE; + n->relation = $3; + n->subname = NULL; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER VIEW relation_expr RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_VIEW; + n->relation = $3; + n->subname = NULL; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER INDEX relation_expr RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_INDEX; + n->relation = $3; + n->subname = NULL; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER TABLE relation_expr RENAME opt_column name TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_COLUMN; + n->relation = $3; + n->subname = $6; + n->newname = $8; + $$ = (Node *)n; + } + | ALTER TRIGGER name ON relation_expr RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TRIGGER; + n->relation = $5; + n->subname = $3; + n->newname = $8; + $$ = (Node *)n; + } + | ALTER ROLE RoleId RENAME TO RoleId + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; + n->subname = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER USER RoleId RENAME TO RoleId + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_ROLE; + n->subname = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER TABLESPACE name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TABLESPACE; + n->subname = $3; + n->newname = $6; + $$ = (Node *)n; + } + | ALTER TEXT_P SEARCH PARSER any_name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSPARSER; + n->object = $5; + n->newname = $8; + $$ = (Node *)n; + } + | ALTER TEXT_P SEARCH DICTIONARY any_name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSDICTIONARY; + n->object = $5; + n->newname = $8; + $$ = (Node *)n; + } + | ALTER TEXT_P SEARCH TEMPLATE any_name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSTEMPLATE; + n->object = $5; + n->newname = $8; + $$ = (Node *)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name RENAME TO name + { + RenameStmt *n = makeNode(RenameStmt); + n->renameType = OBJECT_TSCONFIGURATION; + n->object = $5; + n->newname = $8; + $$ = (Node *)n; + } + ; + +opt_column: COLUMN { $$ = COLUMN; } + | /*EMPTY*/ { $$ = 0; } + ; + +/***************************************************************************** + * + * ALTER THING name SET SCHEMA name + * + *****************************************************************************/ + +AlterObjectSchemaStmt: + ALTER AGGREGATE func_name aggr_args SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_AGGREGATE; + n->object = $3; + n->objarg = $4; + n->newschema = $7; + $$ = (Node *)n; + } + | ALTER DOMAIN_P any_name SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_DOMAIN; + n->object = $3; + n->newschema = $6; + $$ = (Node *)n; + } + | ALTER FUNCTION function_with_argtypes SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_FUNCTION; + n->object = $3->funcname; + n->objarg = $3->funcargs; + n->newschema = $6; + $$ = (Node *)n; + } + | ALTER SEQUENCE relation_expr SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_SEQUENCE; + n->relation = $3; + n->newschema = $6; + $$ = (Node *)n; + } + | ALTER TABLE relation_expr SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TABLE; + n->relation = $3; + n->newschema = $6; + $$ = (Node *)n; + } + | ALTER TYPE_P any_name SET SCHEMA name + { + AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); + n->objectType = OBJECT_TYPE; + n->object = $3; + n->newschema = $6; + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * + * ALTER THING name OWNER TO newname + * + *****************************************************************************/ + +AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_AGGREGATE; + n->object = $3; + n->objarg = $4; + n->newowner = $7; + $$ = (Node *)n; + } + | ALTER CONVERSION_P any_name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_CONVERSION; + n->object = $3; + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER DATABASE database_name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_DATABASE; + n->object = list_make1($3); + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER DOMAIN_P any_name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_DOMAIN; + n->object = $3; + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER FUNCTION function_with_argtypes OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_FUNCTION; + n->object = $3->funcname; + n->objarg = $3->funcargs; + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER opt_procedural LANGUAGE name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_LANGUAGE; + n->object = list_make1($4); + n->newowner = $7; + $$ = (Node *)n; + } + | ALTER OPERATOR any_operator '(' oper_argtypes ')' OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPERATOR; + n->object = $3; + n->objarg = $5; + n->newowner = $9; + $$ = (Node *)n; + } + | ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPCLASS; + n->object = $4; + n->addname = $6; + n->newowner = $9; + $$ = (Node *)n; + } + | ALTER OPERATOR FAMILY any_name USING access_method OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_OPFAMILY; + n->object = $4; + n->addname = $6; + n->newowner = $9; + $$ = (Node *)n; + } + | ALTER SCHEMA name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_SCHEMA; + n->object = list_make1($3); + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER TYPE_P any_name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TYPE; + n->object = $3; + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER TABLESPACE name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TABLESPACE; + n->object = list_make1($3); + n->newowner = $6; + $$ = (Node *)n; + } + | ALTER TEXT_P SEARCH DICTIONARY any_name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TSDICTIONARY; + n->object = $5; + n->newowner = $8; + $$ = (Node *)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name OWNER TO RoleId + { + AlterOwnerStmt *n = makeNode(AlterOwnerStmt); + n->objectType = OBJECT_TSCONFIGURATION; + n->object = $5; + n->newowner = $8; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * QUERY: Define Rewrite Rule + * + *****************************************************************************/ + +RuleStmt: CREATE opt_or_replace RULE name AS + { QueryIsRule=TRUE; } + ON event TO qualified_name where_clause + DO opt_instead RuleActionList + { + RuleStmt *n = makeNode(RuleStmt); + n->replace = $2; + n->relation = $10; + n->rulename = $4; + n->whereClause = $11; + n->event = $8; + n->instead = $13; + n->actions = $14; + $$ = (Node *)n; + QueryIsRule=FALSE; + } + ; + +RuleActionList: + NOTHING { $$ = NIL; } + | RuleActionStmt { $$ = list_make1($1); } + | '(' RuleActionMulti ')' { $$ = $2; } + ; + +/* the thrashing around here is to discard "empty" statements... */ +RuleActionMulti: + RuleActionMulti ';' RuleActionStmtOrEmpty + { if ($3 != NULL) + $$ = lappend($1, $3); + else + $$ = $1; + } + | RuleActionStmtOrEmpty + { if ($1 != NULL) + $$ = list_make1($1); + else + $$ = NIL; + } + ; + +RuleActionStmt: + SelectStmt + | InsertStmt + | UpdateStmt + | DeleteStmt + | NotifyStmt + ; + +RuleActionStmtOrEmpty: + RuleActionStmt { $$ = $1; } + | /*EMPTY*/ { $$ = NULL; } + ; + +event: SELECT { $$ = CMD_SELECT; } + | UPDATE { $$ = CMD_UPDATE; } + | DELETE_P { $$ = CMD_DELETE; } + | INSERT { $$ = CMD_INSERT; } + ; + +opt_instead: + INSTEAD { $$ = TRUE; } + | ALSO { $$ = FALSE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + + +DropRuleStmt: + DROP RULE name ON qualified_name opt_drop_behavior + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = $5; + n->property = $3; + n->behavior = $6; + n->removeType = OBJECT_RULE; + n->missing_ok = false; + $$ = (Node *) n; + } + | DROP RULE IF_P EXISTS name ON qualified_name opt_drop_behavior + { + DropPropertyStmt *n = makeNode(DropPropertyStmt); + n->relation = $7; + n->property = $5; + n->behavior = $8; + n->removeType = OBJECT_RULE; + n->missing_ok = true; + $$ = (Node *) n; + } + ; + + +/***************************************************************************** + * + * QUERY: + * NOTIFY can appear both in rule bodies and + * as a query-level command + * + *****************************************************************************/ + +NotifyStmt: NOTIFY ColId + { + NotifyStmt *n = makeNode(NotifyStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = $2; + n->relation->schemaname = NULL; + $$ = (Node *)n; + } + ; + +ListenStmt: LISTEN ColId + { + ListenStmt *n = makeNode(ListenStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = $2; + n->relation->schemaname = NULL; + $$ = (Node *)n; + } + ; + +UnlistenStmt: + UNLISTEN ColId + { + UnlistenStmt *n = makeNode(UnlistenStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = $2; + n->relation->schemaname = NULL; + $$ = (Node *)n; + } + | UNLISTEN '*' + { + UnlistenStmt *n = makeNode(UnlistenStmt); + n->relation = makeNode(RangeVar); + n->relation->relname = "*"; + n->relation->schemaname = NULL; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Transactions: + * + * BEGIN / COMMIT / ROLLBACK + * (also older versions END / ABORT) + * + *****************************************************************************/ + +TransactionStmt: + ABORT_P opt_transaction + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK; + n->options = NIL; + $$ = (Node *)n; + } + | BEGIN_P opt_transaction transaction_mode_list_or_empty + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_BEGIN; + n->options = $3; + $$ = (Node *)n; + } + | START TRANSACTION transaction_mode_list_or_empty + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_START; + n->options = $3; + $$ = (Node *)n; + } + | COMMIT opt_transaction + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT; + n->options = NIL; + $$ = (Node *)n; + } + | END_P opt_transaction + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT; + n->options = NIL; + $$ = (Node *)n; + } + | ROLLBACK opt_transaction + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK; + n->options = NIL; + $$ = (Node *)n; + } + | SAVEPOINT ColId + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_SAVEPOINT; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString($2))); + $$ = (Node *)n; + } + | RELEASE SAVEPOINT ColId + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_RELEASE; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString($3))); + $$ = (Node *)n; + } + | RELEASE ColId + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_RELEASE; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString($2))); + $$ = (Node *)n; + } + | ROLLBACK opt_transaction TO SAVEPOINT ColId + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_TO; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString($5))); + $$ = (Node *)n; + } + | ROLLBACK opt_transaction TO ColId + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_TO; + n->options = list_make1(makeDefElem("savepoint_name", + (Node *)makeString($4))); + $$ = (Node *)n; + } + | PREPARE TRANSACTION Sconst + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_PREPARE; + n->gid = $3; + $$ = (Node *)n; + } + | COMMIT PREPARED Sconst + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_COMMIT_PREPARED; + n->gid = $3; + $$ = (Node *)n; + } + | ROLLBACK PREPARED Sconst + { + TransactionStmt *n = makeNode(TransactionStmt); + n->kind = TRANS_STMT_ROLLBACK_PREPARED; + n->gid = $3; + $$ = (Node *)n; + } + ; + +opt_transaction: WORK {} + | TRANSACTION {} + | /*EMPTY*/ {} + ; + +transaction_mode_item: + ISOLATION LEVEL iso_level + { $$ = makeDefElem("transaction_isolation", + makeStringConst($3, NULL)); } + | READ ONLY + { $$ = makeDefElem("transaction_read_only", + makeIntConst(TRUE)); } + | READ WRITE + { $$ = makeDefElem("transaction_read_only", + makeIntConst(FALSE)); } + ; + +/* Syntax with commas is SQL-spec, without commas is Postgres historical */ +transaction_mode_list: + transaction_mode_item + { $$ = list_make1($1); } + | transaction_mode_list ',' transaction_mode_item + { $$ = lappend($1, $3); } + | transaction_mode_list transaction_mode_item + { $$ = lappend($1, $2); } + ; + +transaction_mode_list_or_empty: + transaction_mode_list + | /* EMPTY */ + { $$ = NIL; } + ; + + +/***************************************************************************** + * + * QUERY: + * CREATE [ OR REPLACE ] [ TEMP ] VIEW '('target-list ')' + * AS [ WITH [ CASCADED | LOCAL ] CHECK OPTION ] + * + *****************************************************************************/ + +ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list + AS SelectStmt opt_check_option + { + ViewStmt *n = makeNode(ViewStmt); + n->view = $4; + n->view->istemp = $2; + n->aliases = $5; + n->query = $7; + n->replace = false; + $$ = (Node *) n; + } + | CREATE OR REPLACE OptTemp VIEW qualified_name opt_column_list + AS SelectStmt opt_check_option + { + ViewStmt *n = makeNode(ViewStmt); + n->view = $6; + n->view->istemp = $4; + n->aliases = $7; + n->query = $9; + n->replace = true; + $$ = (Node *) n; + } + ; + +/* + * We use merged tokens here to avoid creating shift/reduce conflicts against + * a whole lot of other uses of WITH. + */ +opt_check_option: + WITH_CHECK OPTION + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH CHECK OPTION is not implemented"))); + } + | WITH_CASCADED CHECK OPTION + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH CHECK OPTION is not implemented"))); + } + | WITH_LOCAL CHECK OPTION + { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("WITH CHECK OPTION is not implemented"))); + } + | /* EMPTY */ { $$ = NIL; } + ; + +/***************************************************************************** + * + * QUERY: + * LOAD "filename" + * + *****************************************************************************/ + +LoadStmt: LOAD file_name + { + LoadStmt *n = makeNode(LoadStmt); + n->filename = $2; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * CREATE DATABASE + * + *****************************************************************************/ + +CreatedbStmt: + CREATE DATABASE database_name opt_with createdb_opt_list + { + CreatedbStmt *n = makeNode(CreatedbStmt); + n->dbname = $3; + n->options = $5; + $$ = (Node *)n; + } + ; + +createdb_opt_list: + createdb_opt_list createdb_opt_item { $$ = lappend($1, $2); } + | /* EMPTY */ { $$ = NIL; } + ; + +createdb_opt_item: + TABLESPACE opt_equal name + { + $$ = makeDefElem("tablespace", (Node *)makeString($3)); + } + | TABLESPACE opt_equal DEFAULT + { + $$ = makeDefElem("tablespace", NULL); + } + | LOCATION opt_equal Sconst + { + $$ = makeDefElem("location", (Node *)makeString($3)); + } + | LOCATION opt_equal DEFAULT + { + $$ = makeDefElem("location", NULL); + } + | TEMPLATE opt_equal name + { + $$ = makeDefElem("template", (Node *)makeString($3)); + } + | TEMPLATE opt_equal DEFAULT + { + $$ = makeDefElem("template", NULL); + } + | ENCODING opt_equal Sconst + { + $$ = makeDefElem("encoding", (Node *)makeString($3)); + } + | ENCODING opt_equal Iconst + { + $$ = makeDefElem("encoding", (Node *)makeInteger($3)); + } + | ENCODING opt_equal DEFAULT + { + $$ = makeDefElem("encoding", NULL); + } + | CONNECTION LIMIT opt_equal SignedIconst + { + $$ = makeDefElem("connectionlimit", (Node *)makeInteger($4)); + } + | OWNER opt_equal name + { + $$ = makeDefElem("owner", (Node *)makeString($3)); + } + | OWNER opt_equal DEFAULT + { + $$ = makeDefElem("owner", NULL); + } + ; + +/* + * Though the equals sign doesn't match other WITH options, pg_dump uses + * equals for backward compatibility, and it doesn't seem worth removing it. + */ +opt_equal: '=' {} + | /*EMPTY*/ {} + ; + + +/***************************************************************************** + * + * ALTER DATABASE + * + *****************************************************************************/ + +AlterDatabaseStmt: + ALTER DATABASE database_name opt_with alterdb_opt_list + { + AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt); + n->dbname = $3; + n->options = $5; + $$ = (Node *)n; + } + ; + +AlterDatabaseSetStmt: + ALTER DATABASE database_name SetResetClause + { + AlterDatabaseSetStmt *n = makeNode(AlterDatabaseSetStmt); + n->dbname = $3; + n->setstmt = $4; + $$ = (Node *)n; + } + ; + + +alterdb_opt_list: + alterdb_opt_list alterdb_opt_item { $$ = lappend($1, $2); } + | /* EMPTY */ { $$ = NIL; } + ; + +alterdb_opt_item: + CONNECTION LIMIT opt_equal SignedIconst + { + $$ = makeDefElem("connectionlimit", (Node *)makeInteger($4)); + } + ; + + +/***************************************************************************** + * + * DROP DATABASE [ IF EXISTS ] + * + * This is implicitly CASCADE, no need for drop behavior + *****************************************************************************/ + +DropdbStmt: DROP DATABASE database_name + { + DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = $3; + n->missing_ok = FALSE; + $$ = (Node *)n; + } + | DROP DATABASE IF_P EXISTS database_name + { + DropdbStmt *n = makeNode(DropdbStmt); + n->dbname = $5; + n->missing_ok = TRUE; + $$ = (Node *)n; + } + ; + + +/***************************************************************************** + * + * Manipulate a domain + * + *****************************************************************************/ + +CreateDomainStmt: + CREATE DOMAIN_P any_name opt_as Typename ColQualList + { + CreateDomainStmt *n = makeNode(CreateDomainStmt); + n->domainname = $3; + n->typename = $5; + n->constraints = $6; + $$ = (Node *)n; + } + ; + +AlterDomainStmt: + /* ALTER DOMAIN {SET DEFAULT |DROP DEFAULT} */ + ALTER DOMAIN_P any_name alter_column_default + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'T'; + n->typename = $3; + n->def = $4; + $$ = (Node *)n; + } + /* ALTER DOMAIN DROP NOT NULL */ + | ALTER DOMAIN_P any_name DROP NOT NULL_P + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'N'; + n->typename = $3; + $$ = (Node *)n; + } + /* ALTER DOMAIN SET NOT NULL */ + | ALTER DOMAIN_P any_name SET NOT NULL_P + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'O'; + n->typename = $3; + $$ = (Node *)n; + } + /* ALTER DOMAIN ADD CONSTRAINT ... */ + | ALTER DOMAIN_P any_name ADD_P TableConstraint + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'C'; + n->typename = $3; + n->def = $5; + $$ = (Node *)n; + } + /* ALTER DOMAIN DROP CONSTRAINT [RESTRICT|CASCADE] */ + | ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior + { + AlterDomainStmt *n = makeNode(AlterDomainStmt); + n->subtype = 'X'; + n->typename = $3; + n->name = $6; + n->behavior = $7; + $$ = (Node *)n; + } + ; + +opt_as: AS {} + | /* EMPTY */ {} + ; + + +/***************************************************************************** + * + * Manipulate a text search dictionary or configuration + * + *****************************************************************************/ + +AlterTSDictionaryStmt: + ALTER TEXT_P SEARCH DICTIONARY any_name definition + { + AlterTSDictionaryStmt *n = makeNode(AlterTSDictionaryStmt); + n->dictname = $5; + n->options = $6; + $$ = (Node *)n; + } + ; + +AlterTSConfigurationStmt: + ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list WITH any_name_list + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = $5; + n->tokentype = $9; + n->dicts = $11; + n->override = false; + n->replace = false; + $$ = (Node*)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list WITH any_name_list + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = $5; + n->tokentype = $9; + n->dicts = $11; + n->override = true; + n->replace = false; + $$ = (Node*)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name WITH any_name + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = $5; + n->tokentype = NIL; + n->dicts = list_make2($9,$11); + n->override = false; + n->replace = true; + $$ = (Node*)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name WITH any_name + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = $5; + n->tokentype = $9; + n->dicts = list_make2($11,$13); + n->override = false; + n->replace = true; + $$ = (Node*)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = $5; + n->tokentype = $9; + n->missing_ok = false; + $$ = (Node*)n; + } + | ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list + { + AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt); + n->cfgname = $5; + n->tokentype = $11; + n->missing_ok = true; + $$ = (Node*)n; + } + ; + + +/***************************************************************************** + * + * Manipulate a conversion + * + * CREATE [DEFAULT] CONVERSION + * FOR TO FROM + * + *****************************************************************************/ + +CreateConversionStmt: + CREATE opt_default CONVERSION_P any_name FOR Sconst + TO Sconst FROM any_name + { + CreateConversionStmt *n = makeNode(CreateConversionStmt); + n->conversion_name = $4; + n->for_encoding_name = $6; + n->to_encoding_name = $8; + n->func_name = $10; + n->def = $2; + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * + * QUERY: + * CLUSTER [ USING ] + * CLUSTER + * CLUSTER ON (for pre-8.3) + * + *****************************************************************************/ + +ClusterStmt: + CLUSTER qualified_name cluster_index_specification + { + ClusterStmt *n = makeNode(ClusterStmt); + n->relation = $2; + n->indexname = $3; + $$ = (Node*)n; + } + | CLUSTER + { + ClusterStmt *n = makeNode(ClusterStmt); + n->relation = NULL; + n->indexname = NULL; + $$ = (Node*)n; + } + /* kept for pre-8.3 compatibility */ + | CLUSTER index_name ON qualified_name + { + ClusterStmt *n = makeNode(ClusterStmt); + n->relation = $4; + n->indexname = $2; + $$ = (Node*)n; + } + ; + +cluster_index_specification: + USING index_name { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + + +/***************************************************************************** + * + * QUERY: + * VACUUM + * ANALYZE + * + *****************************************************************************/ + +VacuumStmt: VACUUM opt_full opt_freeze opt_verbose + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = true; + n->analyze = false; + n->full = $2; + n->freeze_min_age = $3 ? 0 : -1; + n->verbose = $4; + n->relation = NULL; + n->va_cols = NIL; + $$ = (Node *)n; + } + | VACUUM opt_full opt_freeze opt_verbose qualified_name + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = true; + n->analyze = false; + n->full = $2; + n->freeze_min_age = $3 ? 0 : -1; + n->verbose = $4; + n->relation = $5; + n->va_cols = NIL; + $$ = (Node *)n; + } + | VACUUM opt_full opt_freeze opt_verbose AnalyzeStmt + { + VacuumStmt *n = (VacuumStmt *) $5; + n->vacuum = true; + n->full = $2; + n->freeze_min_age = $3 ? 0 : -1; + n->verbose |= $4; + $$ = (Node *)n; + } + ; + +AnalyzeStmt: + analyze_keyword opt_verbose + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = false; + n->analyze = true; + n->full = false; + n->freeze_min_age = -1; + n->verbose = $2; + n->relation = NULL; + n->va_cols = NIL; + $$ = (Node *)n; + } + | analyze_keyword opt_verbose qualified_name opt_name_list + { + VacuumStmt *n = makeNode(VacuumStmt); + n->vacuum = false; + n->analyze = true; + n->full = false; + n->freeze_min_age = -1; + n->verbose = $2; + n->relation = $3; + n->va_cols = $4; + $$ = (Node *)n; + } + ; + +analyze_keyword: + ANALYZE {} + | ANALYSE /* British */ {} + ; + +opt_verbose: + VERBOSE { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_full: FULL { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_freeze: FREEZE { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_name_list: + '(' name_list ')' { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + + +/***************************************************************************** + * + * QUERY: + * EXPLAIN [ANALYZE] [VERBOSE] query + * + *****************************************************************************/ + +ExplainStmt: EXPLAIN opt_analyze opt_verbose ExplainableStmt + { + ExplainStmt *n = makeNode(ExplainStmt); + n->analyze = $2; + n->verbose = $3; + n->query = $4; + $$ = (Node *)n; + } + ; + +ExplainableStmt: + SelectStmt + | InsertStmt + | UpdateStmt + | DeleteStmt + | DeclareCursorStmt + | ExecuteStmt /* by default all are $$=$1 */ + ; + +opt_analyze: + analyze_keyword { $$ = TRUE; } + | /* EMPTY */ { $$ = FALSE; } + ; + +/***************************************************************************** + * + * QUERY: + * PREPARE [(args, ...)] AS + * + *****************************************************************************/ + +PrepareStmt: PREPARE name prep_type_clause AS PreparableStmt + { + PrepareStmt *n = makeNode(PrepareStmt); + n->name = $2; + n->argtypes = $3; + n->query = $5; + $$ = (Node *) n; + } + ; + +prep_type_clause: '(' type_list ')' { $$ = $2; } + | /* EMPTY */ { $$ = NIL; } + ; + +PreparableStmt: + SelectStmt + | InsertStmt + | UpdateStmt + | DeleteStmt /* by default all are $$=$1 */ + ; + +/***************************************************************************** + * + * EXECUTE [(params, ...)] + * CREATE TABLE AS EXECUTE [(params, ...)] + * + *****************************************************************************/ + +ExecuteStmt: EXECUTE name execute_param_clause + { + ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = $2; + n->params = $3; + n->into = NULL; + $$ = (Node *) n; + } + | CREATE OptTemp TABLE create_as_target AS + EXECUTE name execute_param_clause + { + ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = $7; + n->params = $8; + $4->rel->istemp = $2; + n->into = $4; + if ($4->colNames) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("column name list not allowed in CREATE TABLE / AS EXECUTE"))); + /* ... because it's not implemented, but it could be */ + $$ = (Node *) n; + } + ; + +execute_param_clause: '(' expr_list ')' { $$ = $2; } + | /* EMPTY */ { $$ = NIL; } + ; + +/***************************************************************************** + * + * QUERY: + * DEALLOCATE [PREPARE] + * + *****************************************************************************/ + +DeallocateStmt: DEALLOCATE name + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = $2; + $$ = (Node *) n; + } + | DEALLOCATE PREPARE name + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = $3; + $$ = (Node *) n; + } + | DEALLOCATE ALL + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = NULL; + $$ = (Node *) n; + } + | DEALLOCATE PREPARE ALL + { + DeallocateStmt *n = makeNode(DeallocateStmt); + n->name = NULL; + $$ = (Node *) n; + } + ; + +/***************************************************************************** + * + * QUERY: + * INSERT STATEMENTS + * + *****************************************************************************/ + +InsertStmt: + INSERT INTO qualified_name insert_rest returning_clause + { + $4->relation = $3; + $4->returningList = $5; + $$ = (Node *) $4; + } + ; + +insert_rest: + SelectStmt + { + $$ = makeNode(InsertStmt); + $$->cols = NIL; + $$->selectStmt = $1; + } + | '(' insert_column_list ')' SelectStmt + { + $$ = makeNode(InsertStmt); + $$->cols = $2; + $$->selectStmt = $4; + } + | DEFAULT VALUES + { + $$ = makeNode(InsertStmt); + $$->cols = NIL; + $$->selectStmt = NULL; + } + ; + +insert_column_list: + insert_column_item + { $$ = list_make1($1); } + | insert_column_list ',' insert_column_item + { $$ = lappend($1, $3); } + ; + +insert_column_item: + ColId opt_indirection + { + $$ = makeNode(ResTarget); + $$->name = $1; + $$->indirection = $2; + $$->val = NULL; + $$->location = @1; + } + ; + +returning_clause: + RETURNING target_list { $$ = $2; } + | /* EMPTY */ { $$ = NIL; } + ; + + +/***************************************************************************** + * + * QUERY: + * DELETE STATEMENTS + * + *****************************************************************************/ + +DeleteStmt: DELETE_P FROM relation_expr_opt_alias + using_clause where_or_current_clause returning_clause + { + DeleteStmt *n = makeNode(DeleteStmt); + n->relation = $3; + n->usingClause = $4; + n->whereClause = $5; + n->returningList = $6; + $$ = (Node *)n; + } + ; + +using_clause: + USING from_list { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +LockStmt: LOCK_P opt_table qualified_name_list opt_lock opt_nowait + { + LockStmt *n = makeNode(LockStmt); + + n->relations = $3; + n->mode = $4; + n->nowait = $5; + $$ = (Node *)n; + } + ; + +opt_lock: IN_P lock_type MODE { $$ = $2; } + | /*EMPTY*/ { $$ = AccessExclusiveLock; } + ; + +lock_type: ACCESS SHARE { $$ = AccessShareLock; } + | ROW SHARE { $$ = RowShareLock; } + | ROW EXCLUSIVE { $$ = RowExclusiveLock; } + | SHARE UPDATE EXCLUSIVE { $$ = ShareUpdateExclusiveLock; } + | SHARE { $$ = ShareLock; } + | SHARE ROW EXCLUSIVE { $$ = ShareRowExclusiveLock; } + | EXCLUSIVE { $$ = ExclusiveLock; } + | ACCESS EXCLUSIVE { $$ = AccessExclusiveLock; } + ; + +opt_nowait: NOWAIT { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + + +/***************************************************************************** + * + * QUERY: + * UpdateStmt (UPDATE) + * + *****************************************************************************/ + +UpdateStmt: UPDATE relation_expr_opt_alias + SET set_clause_list + from_clause + where_or_current_clause + returning_clause + { + UpdateStmt *n = makeNode(UpdateStmt); + n->relation = $2; + n->targetList = $4; + n->fromClause = $5; + n->whereClause = $6; + n->returningList = $7; + $$ = (Node *)n; + } + ; + +set_clause_list: + set_clause { $$ = $1; } + | set_clause_list ',' set_clause { $$ = list_concat($1,$3); } + ; + +set_clause: + single_set_clause { $$ = list_make1($1); } + | multiple_set_clause { $$ = $1; } + ; + +single_set_clause: + set_target '=' ctext_expr + { + $$ = $1; + $$->val = (Node *) $3; + } + ; + +multiple_set_clause: + '(' set_target_list ')' '=' ctext_row + { + ListCell *col_cell; + ListCell *val_cell; + + /* + * Break the ctext_row apart, merge individual expressions + * into the destination ResTargets. XXX this approach + * cannot work for general row expressions as sources. + */ + if (list_length($2) != list_length($5)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("number of columns does not match number of values"))); + forboth(col_cell, $2, val_cell, $5) + { + ResTarget *res_col = (ResTarget *) lfirst(col_cell); + Node *res_val = (Node *) lfirst(val_cell); + + res_col->val = res_val; + } + + $$ = $2; + } + ; + +set_target: + ColId opt_indirection + { + $$ = makeNode(ResTarget); + $$->name = $1; + $$->indirection = $2; + $$->val = NULL; /* upper production sets this */ + $$->location = @1; + } + ; + +set_target_list: + set_target { $$ = list_make1($1); } + | set_target_list ',' set_target { $$ = lappend($1,$3); } + ; + + +/***************************************************************************** + * + * QUERY: + * CURSOR STATEMENTS + * + *****************************************************************************/ +DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt + { + DeclareCursorStmt *n = makeNode(DeclareCursorStmt); + n->portalname = $2; + /* currently we always set FAST_PLAN option */ + n->options = $3 | $5 | CURSOR_OPT_FAST_PLAN; + n->query = $7; + $$ = (Node *)n; + } + ; + +cursor_options: /*EMPTY*/ { $$ = 0; } + | cursor_options NO SCROLL { $$ = $1 | CURSOR_OPT_NO_SCROLL; } + | cursor_options SCROLL { $$ = $1 | CURSOR_OPT_SCROLL; } + | cursor_options BINARY { $$ = $1 | CURSOR_OPT_BINARY; } + | cursor_options INSENSITIVE { $$ = $1 | CURSOR_OPT_INSENSITIVE; } + ; + +opt_hold: /* EMPTY */ { $$ = 0; } + | WITH HOLD { $$ = CURSOR_OPT_HOLD; } + | WITHOUT HOLD { $$ = 0; } + ; + +/***************************************************************************** + * + * QUERY: + * SELECT STATEMENTS + * + *****************************************************************************/ + +/* A complete SELECT statement looks like this. + * + * The rule returns either a single SelectStmt node or a tree of them, + * representing a set-operation tree. + * + * There is an ambiguity when a sub-SELECT is within an a_expr and there + * are excess parentheses: do the parentheses belong to the sub-SELECT or + * to the surrounding a_expr? We don't really care, but yacc wants to know. + * To resolve the ambiguity, we are careful to define the grammar so that + * the decision is staved off as long as possible: as long as we can keep + * absorbing parentheses into the sub-SELECT, we will do so, and only when + * it's no longer possible to do that will we decide that parens belong to + * the expression. For example, in "SELECT (((SELECT 2)) + 3)" the extra + * parentheses are treated as part of the sub-select. The necessity of doing + * it that way is shown by "SELECT (((SELECT 2)) UNION SELECT 2)". Had we + * parsed "((SELECT 2))" as an a_expr, it'd be too late to go back to the + * SELECT viewpoint when we see the UNION. + * + * This approach is implemented by defining a nonterminal select_with_parens, + * which represents a SELECT with at least one outer layer of parentheses, + * and being careful to use select_with_parens, never '(' SelectStmt ')', + * in the expression grammar. We will then have shift-reduce conflicts + * which we can resolve in favor of always treating '(' nonterminal to something else. We use UMINUS + * precedence for this, which is a fairly arbitrary choice. + * + * To be able to define select_with_parens itself without ambiguity, we need + * a nonterminal select_no_parens that represents a SELECT structure with no + * outermost parentheses. This is a little bit tedious, but it works. + * + * In non-expression contexts, we use SelectStmt which can represent a SELECT + * with or without outer parentheses. + */ + +SelectStmt: select_no_parens %prec UMINUS + | select_with_parens %prec UMINUS + ; + +select_with_parens: + '(' select_no_parens ')' { $$ = $2; } + | '(' select_with_parens ')' { $$ = $2; } + ; + +/* + * FOR UPDATE/SHARE may be before or after LIMIT/OFFSET. + * In <=7.2.X, LIMIT/OFFSET had to be after FOR UPDATE + * We now support both orderings, but prefer LIMIT/OFFSET before FOR UPDATE/SHARE + * 2002-08-28 bjm + */ +select_no_parens: + simple_select { $$ = $1; } + | select_clause sort_clause + { + insertSelectOptions((SelectStmt *) $1, $2, NIL, + NULL, NULL); + $$ = $1; + } + | select_clause opt_sort_clause for_locking_clause opt_select_limit + { + insertSelectOptions((SelectStmt *) $1, $2, $3, + list_nth($4, 0), list_nth($4, 1)); + $$ = $1; + } + | select_clause opt_sort_clause select_limit opt_for_locking_clause + { + insertSelectOptions((SelectStmt *) $1, $2, $4, + list_nth($3, 0), list_nth($3, 1)); + $$ = $1; + } + ; + +select_clause: + simple_select { $$ = $1; } + | select_with_parens { $$ = $1; } + ; + +/* + * This rule parses SELECT statements that can appear within set operations, + * including UNION, INTERSECT and EXCEPT. '(' and ')' can be used to specify + * the ordering of the set operations. Without '(' and ')' we want the + * operations to be ordered per the precedence specs at the head of this file. + * + * As with select_no_parens, simple_select cannot have outer parentheses, + * but can have parenthesized subclauses. + * + * Note that sort clauses cannot be included at this level --- SQL92 requires + * SELECT foo UNION SELECT bar ORDER BY baz + * to be parsed as + * (SELECT foo UNION SELECT bar) ORDER BY baz + * not + * SELECT foo UNION (SELECT bar ORDER BY baz) + * Likewise FOR UPDATE and LIMIT. Therefore, those clauses are described + * as part of the select_no_parens production, not simple_select. + * This does not limit functionality, because you can reintroduce sort and + * limit clauses inside parentheses. + * + * NOTE: only the leftmost component SelectStmt should have INTO. + * However, this is not checked by the grammar; parse analysis must check it. + */ +simple_select: + SELECT opt_distinct target_list + into_clause from_clause where_clause + group_clause having_clause + { + SelectStmt *n = makeNode(SelectStmt); + n->distinctClause = $2; + n->targetList = $3; + n->intoClause = $4; + n->fromClause = $5; + n->whereClause = $6; + n->groupClause = $7; + n->havingClause = $8; + $$ = (Node *)n; + } + | values_clause { $$ = $1; } + | select_clause UNION opt_all select_clause + { + $$ = makeSetOp(SETOP_UNION, $3, $1, $4); + } + | select_clause INTERSECT opt_all select_clause + { + $$ = makeSetOp(SETOP_INTERSECT, $3, $1, $4); + } + | select_clause EXCEPT opt_all select_clause + { + $$ = makeSetOp(SETOP_EXCEPT, $3, $1, $4); + } + ; + +into_clause: + INTO OptTempTableName + { + $$ = makeNode(IntoClause); + $$->rel = $2; + $$->colNames = NIL; + $$->options = NIL; + $$->onCommit = ONCOMMIT_NOOP; + $$->tableSpaceName = NULL; + } + | /*EMPTY*/ + { $$ = NULL; } + ; + +/* + * Redundancy here is needed to avoid shift/reduce conflicts, + * since TEMP is not a reserved word. See also OptTemp. + */ +OptTempTableName: + TEMPORARY opt_table qualified_name + { + $$ = $3; + $$->istemp = true; + } + | TEMP opt_table qualified_name + { + $$ = $3; + $$->istemp = true; + } + | LOCAL TEMPORARY opt_table qualified_name + { + $$ = $4; + $$->istemp = true; + } + | LOCAL TEMP opt_table qualified_name + { + $$ = $4; + $$->istemp = true; + } + | GLOBAL TEMPORARY opt_table qualified_name + { + $$ = $4; + $$->istemp = true; + } + | GLOBAL TEMP opt_table qualified_name + { + $$ = $4; + $$->istemp = true; + } + | TABLE qualified_name + { + $$ = $2; + $$->istemp = false; + } + | qualified_name + { + $$ = $1; + $$->istemp = false; + } + ; + +opt_table: TABLE {} + | /*EMPTY*/ {} + ; + +opt_all: ALL { $$ = TRUE; } + | DISTINCT { $$ = FALSE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +/* We use (NIL) as a placeholder to indicate that all target expressions + * should be placed in the DISTINCT list during parsetree analysis. + */ +opt_distinct: + DISTINCT { $$ = list_make1(NIL); } + | DISTINCT ON '(' expr_list ')' { $$ = $4; } + | ALL { $$ = NIL; } + | /*EMPTY*/ { $$ = NIL; } + ; + +opt_sort_clause: + sort_clause { $$ = $1;} + | /*EMPTY*/ { $$ = NIL; } + ; + +sort_clause: + ORDER BY sortby_list { $$ = $3; } + ; + +sortby_list: + sortby { $$ = list_make1($1); } + | sortby_list ',' sortby { $$ = lappend($1, $3); } + ; + +sortby: a_expr USING qual_all_Op opt_nulls_order + { + $$ = makeNode(SortBy); + $$->node = $1; + $$->sortby_dir = SORTBY_USING; + $$->sortby_nulls = $4; + $$->useOp = $3; + } + | a_expr opt_asc_desc opt_nulls_order + { + $$ = makeNode(SortBy); + $$->node = $1; + $$->sortby_dir = $2; + $$->sortby_nulls = $3; + $$->useOp = NIL; + } + ; + + +select_limit: + LIMIT select_limit_value OFFSET select_offset_value + { $$ = list_make2($4, $2); } + | OFFSET select_offset_value LIMIT select_limit_value + { $$ = list_make2($2, $4); } + | LIMIT select_limit_value + { $$ = list_make2(NULL, $2); } + | OFFSET select_offset_value + { $$ = list_make2($2, NULL); } + | LIMIT select_limit_value ',' select_offset_value + { + /* Disabled because it was too confusing, bjm 2002-02-18 */ + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("LIMIT #,# syntax is not supported"), + errhint("Use separate LIMIT and OFFSET clauses."))); + } + ; + +opt_select_limit: + select_limit { $$ = $1; } + | /* EMPTY */ + { $$ = list_make2(NULL,NULL); } + ; + +select_limit_value: + a_expr { $$ = $1; } + | ALL + { + /* LIMIT ALL is represented as a NULL constant */ + A_Const *n = makeNode(A_Const); + n->val.type = T_Null; + $$ = (Node *)n; + } + ; + +select_offset_value: + a_expr { $$ = $1; } + ; + +group_clause: + GROUP_P BY expr_list { $$ = $3; } + | /*EMPTY*/ { $$ = NIL; } + ; + +having_clause: + HAVING a_expr { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + +for_locking_clause: + for_locking_items { $$ = $1; } + | FOR READ ONLY { $$ = NIL; } + ; + +opt_for_locking_clause: + for_locking_clause { $$ = $1; } + | /* EMPTY */ { $$ = NIL; } + ; + +for_locking_items: + for_locking_item { $$ = list_make1($1); } + | for_locking_items for_locking_item { $$ = lappend($1, $2); } + ; + +for_locking_item: + FOR UPDATE locked_rels_list opt_nowait + { + LockingClause *n = makeNode(LockingClause); + n->lockedRels = $3; + n->forUpdate = TRUE; + n->noWait = $4; + $$ = (Node *) n; + } + | FOR SHARE locked_rels_list opt_nowait + { + LockingClause *n = makeNode(LockingClause); + n->lockedRels = $3; + n->forUpdate = FALSE; + n->noWait = $4; + $$ = (Node *) n; + } + ; + +locked_rels_list: + OF name_list { $$ = $2; } + | /* EMPTY */ { $$ = NIL; } + ; + + +values_clause: + VALUES ctext_row + { + SelectStmt *n = makeNode(SelectStmt); + n->valuesLists = list_make1($2); + $$ = (Node *) n; + } + | values_clause ',' ctext_row + { + SelectStmt *n = (SelectStmt *) $1; + n->valuesLists = lappend(n->valuesLists, $3); + $$ = (Node *) n; + } + ; + + +/***************************************************************************** + * + * clauses common to all Optimizable Stmts: + * from_clause - allow list of both JOIN expressions and table names + * where_clause - qualifications for joins or restrictions + * + *****************************************************************************/ + +from_clause: + FROM from_list { $$ = $2; } + | /*EMPTY*/ { $$ = NIL; } + ; + +from_list: + table_ref { $$ = list_make1($1); } + | from_list ',' table_ref { $$ = lappend($1, $3); } + ; + +/* + * table_ref is where an alias clause can be attached. Note we cannot make + * alias_clause have an empty production because that causes parse conflicts + * between table_ref := '(' joined_table ')' alias_clause + * and joined_table := '(' joined_table ')'. So, we must have the + * redundant-looking productions here instead. + */ +table_ref: relation_expr + { + $$ = (Node *) $1; + } + | relation_expr alias_clause + { + $1->alias = $2; + $$ = (Node *) $1; + } + | func_table + { + RangeFunction *n = makeNode(RangeFunction); + n->funccallnode = $1; + n->coldeflist = NIL; + $$ = (Node *) n; + } + | func_table alias_clause + { + RangeFunction *n = makeNode(RangeFunction); + n->funccallnode = $1; + n->alias = $2; + n->coldeflist = NIL; + $$ = (Node *) n; + } + | func_table AS '(' TableFuncElementList ')' + { + RangeFunction *n = makeNode(RangeFunction); + n->funccallnode = $1; + n->coldeflist = $4; + $$ = (Node *) n; + } + | func_table AS ColId '(' TableFuncElementList ')' + { + RangeFunction *n = makeNode(RangeFunction); + Alias *a = makeNode(Alias); + n->funccallnode = $1; + a->aliasname = $3; + n->alias = a; + n->coldeflist = $5; + $$ = (Node *) n; + } + | func_table ColId '(' TableFuncElementList ')' + { + RangeFunction *n = makeNode(RangeFunction); + Alias *a = makeNode(Alias); + n->funccallnode = $1; + a->aliasname = $2; + n->alias = a; + n->coldeflist = $4; + $$ = (Node *) n; + } + | select_with_parens + { + /* + * The SQL spec does not permit a subselect + * () without an alias clause, + * so we don't either. This avoids the problem + * of needing to invent a unique refname for it. + * That could be surmounted if there's sufficient + * popular demand, but for now let's just implement + * the spec and see if anyone complains. + * However, it does seem like a good idea to emit + * an error message that's better than "syntax error". + */ + if (IsA($1, SelectStmt) && + ((SelectStmt *) $1)->valuesLists) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("VALUES in FROM must have an alias"), + errhint("For example, FROM (VALUES ...) [AS] foo."))); + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("subquery in FROM must have an alias"), + errhint("For example, FROM (SELECT ...) [AS] foo."))); + $$ = NULL; + } + | select_with_parens alias_clause + { + RangeSubselect *n = makeNode(RangeSubselect); + n->subquery = $1; + n->alias = $2; + $$ = (Node *) n; + } + | joined_table + { + $$ = (Node *) $1; + } + | '(' joined_table ')' alias_clause + { + $2->alias = $4; + $$ = (Node *) $2; + } + ; + + +/* + * It may seem silly to separate joined_table from table_ref, but there is + * method in SQL92's madness: if you don't do it this way you get reduce- + * reduce conflicts, because it's not clear to the parser generator whether + * to expect alias_clause after ')' or not. For the same reason we must + * treat 'JOIN' and 'join_type JOIN' separately, rather than allowing + * join_type to expand to empty; if we try it, the parser generator can't + * figure out when to reduce an empty join_type right after table_ref. + * + * Note that a CROSS JOIN is the same as an unqualified + * INNER JOIN, and an INNER JOIN/ON has the same shape + * but a qualification expression to limit membership. + * A NATURAL JOIN implicitly matches column names between + * tables and the shape is determined by which columns are + * in common. We'll collect columns during the later transformations. + */ + +joined_table: + '(' joined_table ')' + { + $$ = $2; + } + | table_ref CROSS JOIN table_ref + { + /* CROSS JOIN is same as unqualified inner join */ + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; + n->isNatural = FALSE; + n->larg = $1; + n->rarg = $4; + n->using = NIL; + n->quals = NULL; + $$ = n; + } + | table_ref join_type JOIN table_ref join_qual + { + JoinExpr *n = makeNode(JoinExpr); + n->jointype = $2; + n->isNatural = FALSE; + n->larg = $1; + n->rarg = $4; + if ($5 != NULL && IsA($5, List)) + n->using = (List *) $5; /* USING clause */ + else + n->quals = $5; /* ON clause */ + $$ = n; + } + | table_ref JOIN table_ref join_qual + { + /* letting join_type reduce to empty doesn't work */ + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; + n->isNatural = FALSE; + n->larg = $1; + n->rarg = $3; + if ($4 != NULL && IsA($4, List)) + n->using = (List *) $4; /* USING clause */ + else + n->quals = $4; /* ON clause */ + $$ = n; + } + | table_ref NATURAL join_type JOIN table_ref + { + JoinExpr *n = makeNode(JoinExpr); + n->jointype = $3; + n->isNatural = TRUE; + n->larg = $1; + n->rarg = $5; + n->using = NIL; /* figure out which columns later... */ + n->quals = NULL; /* fill later */ + $$ = n; + } + | table_ref NATURAL JOIN table_ref + { + /* letting join_type reduce to empty doesn't work */ + JoinExpr *n = makeNode(JoinExpr); + n->jointype = JOIN_INNER; + n->isNatural = TRUE; + n->larg = $1; + n->rarg = $4; + n->using = NIL; /* figure out which columns later... */ + n->quals = NULL; /* fill later */ + $$ = n; + } + ; + +alias_clause: + AS ColId '(' name_list ')' + { + $$ = makeNode(Alias); + $$->aliasname = $2; + $$->colnames = $4; + } + | AS ColId + { + $$ = makeNode(Alias); + $$->aliasname = $2; + } + | ColId '(' name_list ')' + { + $$ = makeNode(Alias); + $$->aliasname = $1; + $$->colnames = $3; + } + | ColId + { + $$ = makeNode(Alias); + $$->aliasname = $1; + } + ; + +join_type: FULL join_outer { $$ = JOIN_FULL; } + | LEFT join_outer { $$ = JOIN_LEFT; } + | RIGHT join_outer { $$ = JOIN_RIGHT; } + | INNER_P { $$ = JOIN_INNER; } + ; + +/* OUTER is just noise... */ +join_outer: OUTER_P { $$ = NULL; } + | /*EMPTY*/ { $$ = NULL; } + ; + +/* JOIN qualification clauses + * Possibilities are: + * USING ( column list ) allows only unqualified column names, + * which must match between tables. + * ON expr allows more general qualifications. + * + * We return USING as a List node, while an ON-expr will not be a List. + */ + +join_qual: USING '(' name_list ')' { $$ = (Node *) $3; } + | ON a_expr { $$ = $2; } + ; + + +relation_expr: + qualified_name + { + /* default inheritance */ + $$ = $1; + $$->inhOpt = INH_DEFAULT; + $$->alias = NULL; + } + | qualified_name '*' + { + /* inheritance query */ + $$ = $1; + $$->inhOpt = INH_YES; + $$->alias = NULL; + } + | ONLY qualified_name + { + /* no inheritance */ + $$ = $2; + $$->inhOpt = INH_NO; + $$->alias = NULL; + } + | ONLY '(' qualified_name ')' + { + /* no inheritance, SQL99-style syntax */ + $$ = $3; + $$->inhOpt = INH_NO; + $$->alias = NULL; + } + ; + + +/* + * Given "UPDATE foo set set ...", we have to decide without looking any + * further ahead whether the first "set" is an alias or the UPDATE's SET + * keyword. Since "set" is allowed as a column name both interpretations + * are feasible. We resolve the shift/reduce conflict by giving the first + * relation_expr_opt_alias production a higher precedence than the SET token + * has, causing the parser to prefer to reduce, in effect assuming that the + * SET is not an alias. + */ +relation_expr_opt_alias: relation_expr %prec UMINUS + { + $$ = $1; + } + | relation_expr ColId + { + Alias *alias = makeNode(Alias); + alias->aliasname = $2; + $1->alias = alias; + $$ = $1; + } + | relation_expr AS ColId + { + Alias *alias = makeNode(Alias); + alias->aliasname = $3; + $1->alias = alias; + $$ = $1; + } + ; + + +func_table: func_expr { $$ = $1; } + ; + + +where_clause: + WHERE a_expr { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + +/* variant for UPDATE and DELETE */ +where_or_current_clause: + WHERE a_expr { $$ = $2; } + | WHERE CURRENT_P OF name + { + CurrentOfExpr *n = makeNode(CurrentOfExpr); + /* cvarno is filled in by parse analysis */ + n->cursor_name = $4; + n->cursor_param = 0; + $$ = (Node *) n; + } + | WHERE CURRENT_P OF PARAM + { + CurrentOfExpr *n = makeNode(CurrentOfExpr); + /* cvarno is filled in by parse analysis */ + n->cursor_name = NULL; + n->cursor_param = $4; + $$ = (Node *) n; + } + | /*EMPTY*/ { $$ = NULL; } + ; + + +TableFuncElementList: + TableFuncElement + { + $$ = list_make1($1); + } + | TableFuncElementList ',' TableFuncElement + { + $$ = lappend($1, $3); + } + ; + +TableFuncElement: ColId Typename + { + ColumnDef *n = makeNode(ColumnDef); + n->colname = $1; + n->typename = $2; + n->constraints = NIL; + n->is_local = true; + $$ = (Node *)n; + } + ; + +/***************************************************************************** + * + * Type syntax + * SQL92 introduces a large amount of type-specific syntax. + * Define individual clauses to handle these cases, and use + * the generic case to handle regular type-extensible Postgres syntax. + * - thomas 1997-10-10 + * + *****************************************************************************/ + +Typename: SimpleTypename opt_array_bounds + { + $$ = $1; + $$->arrayBounds = $2; + } + | SETOF SimpleTypename opt_array_bounds + { + $$ = $2; + $$->arrayBounds = $3; + $$->setof = TRUE; + } + | SimpleTypename ARRAY '[' Iconst ']' + { + /* SQL99's redundant syntax */ + $$ = $1; + $$->arrayBounds = list_make1(makeInteger($4)); + } + | SETOF SimpleTypename ARRAY '[' Iconst ']' + { + /* SQL99's redundant syntax */ + $$ = $2; + $$->arrayBounds = list_make1(makeInteger($5)); + $$->setof = TRUE; + } + ; + +opt_array_bounds: + opt_array_bounds '[' ']' + { $$ = lappend($1, makeInteger(-1)); } + | opt_array_bounds '[' Iconst ']' + { $$ = lappend($1, makeInteger($3)); } + | /*EMPTY*/ + { $$ = NIL; } + ; + +SimpleTypename: + GenericType { $$ = $1; } + | Numeric { $$ = $1; } + | Bit { $$ = $1; } + | Character { $$ = $1; } + | ConstDatetime { $$ = $1; } + | ConstInterval opt_interval + { + $$ = $1; + if ($2 != INTERVAL_FULL_RANGE) + $$->typmods = list_make1(makeIntConst($2)); + } + | ConstInterval '(' Iconst ')' opt_interval + { + $$ = $1; + $$->typmods = list_make2(makeIntConst($5), + makeIntConst($3)); + } + ; + +/* We have a separate ConstTypename to allow defaulting fixed-length + * types such as CHAR() and BIT() to an unspecified length. + * SQL9x requires that these default to a length of one, but this + * makes no sense for constructs like CHAR 'hi' and BIT '0101', + * where there is an obvious better choice to make. + * Note that ConstInterval is not included here since it must + * be pushed up higher in the rules to accomodate the postfix + * options (e.g. INTERVAL '1' YEAR). Likewise, we have to handle + * the generic-type-name case in AExprConst to avoid premature + * reduce/reduce conflicts against function names. + */ +ConstTypename: + Numeric { $$ = $1; } + | ConstBit { $$ = $1; } + | ConstCharacter { $$ = $1; } + | ConstDatetime { $$ = $1; } + ; + +/* + * GenericType covers all type names that don't have special syntax mandated + * by the standard, including qualified names. We also allow type modifiers. + * To avoid parsing conflicts against function invocations, the modifiers + * have to be shown as expr_list here, but parse analysis will only accept + * constants for them. + */ +GenericType: + type_function_name opt_type_modifiers + { + $$ = makeTypeName($1); + $$->typmods = $2; + $$->location = @1; + } + | type_function_name attrs opt_type_modifiers + { + $$ = makeTypeNameFromNameList(lcons(makeString($1), $2)); + $$->typmods = $3; + $$->location = @1; + } + ; + +opt_type_modifiers: '(' expr_list ')' { $$ = $2; } + | /* EMPTY */ { $$ = NIL; } + ; + +/* + * SQL92 numeric data types + */ +Numeric: INT_P + { + $$ = SystemTypeName("int4"); + $$->location = @1; + } + | INTEGER + { + $$ = SystemTypeName("int4"); + $$->location = @1; + } + | SMALLINT + { + $$ = SystemTypeName("int2"); + $$->location = @1; + } + | BIGINT + { + $$ = SystemTypeName("int8"); + $$->location = @1; + } + | REAL + { + $$ = SystemTypeName("float4"); + $$->location = @1; + } + | FLOAT_P opt_float + { + $$ = $2; + $$->location = @1; + } + | DOUBLE_P PRECISION + { + $$ = SystemTypeName("float8"); + $$->location = @1; + } + | DECIMAL_P opt_type_modifiers + { + $$ = SystemTypeName("numeric"); + $$->typmods = $2; + $$->location = @1; + } + | DEC opt_type_modifiers + { + $$ = SystemTypeName("numeric"); + $$->typmods = $2; + $$->location = @1; + } + | NUMERIC opt_type_modifiers + { + $$ = SystemTypeName("numeric"); + $$->typmods = $2; + $$->location = @1; + } + | BOOLEAN_P + { + $$ = SystemTypeName("bool"); + $$->location = @1; + } + ; + +opt_float: '(' Iconst ')' + { + /* + * Check FLOAT() precision limits assuming IEEE floating + * types - thomas 1997-09-18 + */ + if ($2 < 1) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("precision for type float must be at least 1 bit"))); + else if ($2 <= 24) + $$ = SystemTypeName("float4"); + else if ($2 <= 53) + $$ = SystemTypeName("float8"); + else + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("precision for type float must be less than 54 bits"))); + } + | /*EMPTY*/ + { + $$ = SystemTypeName("float8"); + } + ; + +/* + * SQL92 bit-field data types + * The following implements BIT() and BIT VARYING(). + */ +Bit: BitWithLength + { + $$ = $1; + } + | BitWithoutLength + { + $$ = $1; + } + ; + +/* ConstBit is like Bit except "BIT" defaults to unspecified length */ +/* See notes for ConstCharacter, which addresses same issue for "CHAR" */ +ConstBit: BitWithLength + { + $$ = $1; + } + | BitWithoutLength + { + $$ = $1; + $$->typmods = NIL; + } + ; + +BitWithLength: + BIT opt_varying '(' expr_list ')' + { + char *typname; + + typname = $2 ? "varbit" : "bit"; + $$ = SystemTypeName(typname); + $$->typmods = $4; + $$->location = @1; + } + ; + +BitWithoutLength: + BIT opt_varying + { + /* bit defaults to bit(1), varbit to no limit */ + if ($2) + { + $$ = SystemTypeName("varbit"); + } + else + { + $$ = SystemTypeName("bit"); + $$->typmods = list_make1(makeIntConst(1)); + } + $$->location = @1; + } + ; + + +/* + * SQL92 character data types + * The following implements CHAR() and VARCHAR(). + */ +Character: CharacterWithLength + { + $$ = $1; + } + | CharacterWithoutLength + { + $$ = $1; + } + ; + +ConstCharacter: CharacterWithLength + { + $$ = $1; + } + | CharacterWithoutLength + { + /* Length was not specified so allow to be unrestricted. + * This handles problems with fixed-length (bpchar) strings + * which in column definitions must default to a length + * of one, but should not be constrained if the length + * was not specified. + */ + $$ = $1; + $$->typmods = NIL; + } + ; + +CharacterWithLength: character '(' Iconst ')' opt_charset + { + if (($5 != NULL) && (strcmp($5, "sql_text") != 0)) + { + char *type; + + type = palloc(strlen($1) + 1 + strlen($5) + 1); + strcpy(type, $1); + strcat(type, "_"); + strcat(type, $5); + $1 = type; + } + + $$ = SystemTypeName($1); + $$->typmods = list_make1(makeIntConst($3)); + $$->location = @1; + } + ; + +CharacterWithoutLength: character opt_charset + { + if (($2 != NULL) && (strcmp($2, "sql_text") != 0)) + { + char *type; + + type = palloc(strlen($1) + 1 + strlen($2) + 1); + strcpy(type, $1); + strcat(type, "_"); + strcat(type, $2); + $1 = type; + } + + $$ = SystemTypeName($1); + + /* char defaults to char(1), varchar to no limit */ + if (strcmp($1, "char") == 0) + $$->typmods = list_make1(makeIntConst(1)); + + $$->location = @1; + } + ; + +character: CHARACTER opt_varying + { $$ = $2 ? "varchar": "char"; } + | CHAR_P opt_varying + { $$ = $2 ? "varchar": "char"; } + | VARCHAR + { $$ = "varchar"; } + | NATIONAL CHARACTER opt_varying + { $$ = $3 ? "varchar": "char"; } + | NATIONAL CHAR_P opt_varying + { $$ = $3 ? "varchar": "char"; } + | NCHAR opt_varying + { $$ = $2 ? "varchar": "char"; } + ; + +opt_varying: + VARYING { $$ = TRUE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_charset: + CHARACTER SET ColId { $$ = $3; } + | /*EMPTY*/ { $$ = NULL; } + ; + +/* + * SQL92 date/time types + */ +ConstDatetime: + TIMESTAMP '(' Iconst ')' opt_timezone + { + if ($5) + $$ = SystemTypeName("timestamptz"); + else + $$ = SystemTypeName("timestamp"); + /* XXX the timezone field seems to be unused + * - thomas 2001-09-06 + */ + $$->timezone = $5; + $$->typmods = list_make1(makeIntConst($3)); + $$->location = @1; + } + | TIMESTAMP opt_timezone + { + if ($2) + $$ = SystemTypeName("timestamptz"); + else + $$ = SystemTypeName("timestamp"); + /* XXX the timezone field seems to be unused + * - thomas 2001-09-06 + */ + $$->timezone = $2; + $$->location = @1; + } + | TIME '(' Iconst ')' opt_timezone + { + if ($5) + $$ = SystemTypeName("timetz"); + else + $$ = SystemTypeName("time"); + $$->typmods = list_make1(makeIntConst($3)); + $$->location = @1; + } + | TIME opt_timezone + { + if ($2) + $$ = SystemTypeName("timetz"); + else + $$ = SystemTypeName("time"); + $$->location = @1; + } + ; + +ConstInterval: + INTERVAL + { + $$ = SystemTypeName("interval"); + $$->location = @1; + } + ; + +opt_timezone: + WITH TIME ZONE { $$ = TRUE; } + | WITHOUT TIME ZONE { $$ = FALSE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +opt_interval: + YEAR_P { $$ = INTERVAL_MASK(YEAR); } + | MONTH_P { $$ = INTERVAL_MASK(MONTH); } + | DAY_P { $$ = INTERVAL_MASK(DAY); } + | HOUR_P { $$ = INTERVAL_MASK(HOUR); } + | MINUTE_P { $$ = INTERVAL_MASK(MINUTE); } + | SECOND_P { $$ = INTERVAL_MASK(SECOND); } + | YEAR_P TO MONTH_P + { $$ = INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH); } + | DAY_P TO HOUR_P + { $$ = INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR); } + | DAY_P TO MINUTE_P + { $$ = INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE); } + | DAY_P TO SECOND_P + { $$ = INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND); } + | HOUR_P TO MINUTE_P + { $$ = INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE); } + | HOUR_P TO SECOND_P + { $$ = INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) + | INTERVAL_MASK(SECOND); } + | MINUTE_P TO SECOND_P + { $$ = INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND); } + | /*EMPTY*/ { $$ = INTERVAL_FULL_RANGE; } + ; + + +/***************************************************************************** + * + * expression grammar + * + *****************************************************************************/ + +/* + * General expressions + * This is the heart of the expression syntax. + * + * We have two expression types: a_expr is the unrestricted kind, and + * b_expr is a subset that must be used in some places to avoid shift/reduce + * conflicts. For example, we can't do BETWEEN as "BETWEEN a_expr AND a_expr" + * because that use of AND conflicts with AND as a boolean operator. So, + * b_expr is used in BETWEEN and we remove boolean keywords from b_expr. + * + * Note that '(' a_expr ')' is a b_expr, so an unrestricted expression can + * always be used by surrounding it with parens. + * + * c_expr is all the productions that are common to a_expr and b_expr; + * it's factored out just to eliminate redundant coding. + */ +a_expr: c_expr { $$ = $1; } + | a_expr TYPECAST Typename + { $$ = makeTypeCast($1, $3); } + | a_expr AT TIME ZONE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("timezone"); + n->args = list_make2($5, $1); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @2; + $$ = (Node *) n; + } + /* + * These operators must be called out explicitly in order to make use + * of yacc/bison's automatic operator-precedence handling. All other + * operator names are handled by the generic productions using "Op", + * below; and all those operators will have the same precedence. + * + * If you add more explicitly-known operators, be sure to add them + * also to b_expr and to the MathOp list above. + */ + | '+' a_expr %prec UMINUS + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); } + | '-' a_expr %prec UMINUS + { $$ = doNegate($2, @1); } + | a_expr '+' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", $1, $3, @2); } + | a_expr '-' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", $1, $3, @2); } + | a_expr '*' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", $1, $3, @2); } + | a_expr '/' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", $1, $3, @2); } + | a_expr '%' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", $1, $3, @2); } + | a_expr '^' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", $1, $3, @2); } + | a_expr '<' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2); } + | a_expr '>' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $3, @2); } + | a_expr '=' a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", $1, $3, @2); } + + | a_expr qual_Op a_expr %prec Op + { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, $3, @2); } + | qual_Op a_expr %prec Op + { $$ = (Node *) makeA_Expr(AEXPR_OP, $1, NULL, $2, @1); } + | a_expr qual_Op %prec POSTFIXOP + { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, NULL, @2); } + + | a_expr AND a_expr + { $$ = (Node *) makeA_Expr(AEXPR_AND, NIL, $1, $3, @2); } + | a_expr OR a_expr + { $$ = (Node *) makeA_Expr(AEXPR_OR, NIL, $1, $3, @2); } + | NOT a_expr + { $$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, $2, @1); } + + | a_expr LIKE a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, $3, @2); } + | a_expr LIKE a_expr ESCAPE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2($3, $5); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @4; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, (Node *) n, @2); + } + | a_expr NOT LIKE a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, $4, @2); } + | a_expr NOT LIKE a_expr ESCAPE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2($4, $6); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @5; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, (Node *) n, @2); + } + | a_expr ILIKE a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, $3, @2); } + | a_expr ILIKE a_expr ESCAPE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2($3, $5); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @4; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, (Node *) n, @2); + } + | a_expr NOT ILIKE a_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, $4, @2); } + | a_expr NOT ILIKE a_expr ESCAPE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("like_escape"); + n->args = list_make2($4, $6); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @5; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, (Node *) n, @2); + } + + | a_expr SIMILAR TO a_expr %prec SIMILAR + { + A_Const *c = makeNode(A_Const); + FuncCall *n = makeNode(FuncCall); + c->val.type = T_Null; + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2($4, (Node *) c); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @2; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n, @2); + } + | a_expr SIMILAR TO a_expr ESCAPE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2($4, $6); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @5; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n, @2); + } + | a_expr NOT SIMILAR TO a_expr %prec SIMILAR + { + A_Const *c = makeNode(A_Const); + FuncCall *n = makeNode(FuncCall); + c->val.type = T_Null; + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2($5, (Node *) c); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @5; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n, @2); + } + | a_expr NOT SIMILAR TO a_expr ESCAPE a_expr + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("similar_escape"); + n->args = list_make2($5, $7); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @6; + $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n, @2); + } + + /* NullTest clause + * Define SQL92-style Null test clause. + * Allow two forms described in the standard: + * a IS NULL + * a IS NOT NULL + * Allow two SQL extensions + * a ISNULL + * a NOTNULL + */ + | a_expr IS NULL_P + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; + n->nulltesttype = IS_NULL; + $$ = (Node *)n; + } + | a_expr ISNULL + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; + n->nulltesttype = IS_NULL; + $$ = (Node *)n; + } + | a_expr IS NOT NULL_P + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; + n->nulltesttype = IS_NOT_NULL; + $$ = (Node *)n; + } + | a_expr NOTNULL + { + NullTest *n = makeNode(NullTest); + n->arg = (Expr *) $1; + n->nulltesttype = IS_NOT_NULL; + $$ = (Node *)n; + } + | row OVERLAPS row + { + $$ = (Node *)makeOverlaps($1, $3, @2); + } + | a_expr IS TRUE_P + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; + b->booltesttype = IS_TRUE; + $$ = (Node *)b; + } + | a_expr IS NOT TRUE_P + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; + b->booltesttype = IS_NOT_TRUE; + $$ = (Node *)b; + } + | a_expr IS FALSE_P + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; + b->booltesttype = IS_FALSE; + $$ = (Node *)b; + } + | a_expr IS NOT FALSE_P + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; + b->booltesttype = IS_NOT_FALSE; + $$ = (Node *)b; + } + | a_expr IS UNKNOWN + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; + b->booltesttype = IS_UNKNOWN; + $$ = (Node *)b; + } + | a_expr IS NOT UNKNOWN + { + BooleanTest *b = makeNode(BooleanTest); + b->arg = (Expr *) $1; + b->booltesttype = IS_NOT_UNKNOWN; + $$ = (Node *)b; + } + | a_expr IS DISTINCT FROM a_expr %prec IS + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2); + } + | a_expr IS NOT DISTINCT FROM a_expr %prec IS + { + $$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, + (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, + "=", $1, $6, @2), + @2); + + } + | a_expr IS OF '(' type_list ')' %prec IS + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_OF, "=", $1, (Node *) $5, @2); + } + | a_expr IS NOT OF '(' type_list ')' %prec IS + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_OF, "<>", $1, (Node *) $6, @2); + } + | a_expr BETWEEN opt_asymmetric b_expr AND b_expr %prec BETWEEN + { + $$ = (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4, @2), + (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6, @2), + @2); + } + | a_expr NOT BETWEEN opt_asymmetric b_expr AND b_expr %prec BETWEEN + { + $$ = (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $5, @2), + (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $7, @2), + @2); + } + | a_expr BETWEEN SYMMETRIC b_expr AND b_expr %prec BETWEEN + { + $$ = (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $4, @2), + (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $6, @2), + @2), + (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $6, @2), + (Node *) makeSimpleA_Expr(AEXPR_OP, "<=", $1, $4, @2), + @2), + @2); + } + | a_expr NOT BETWEEN SYMMETRIC b_expr AND b_expr %prec BETWEEN + { + $$ = (Node *) makeA_Expr(AEXPR_AND, NIL, + (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $5, @2), + (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $7, @2), + @2), + (Node *) makeA_Expr(AEXPR_OR, NIL, + (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $7, @2), + (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $5, @2), + @2), + @2); + } + | a_expr IN_P in_expr + { + /* in_expr returns a SubLink or a list of a_exprs */ + if (IsA($3, SubLink)) + { + /* generate foo = ANY (subquery) */ + SubLink *n = (SubLink *) $3; + n->subLinkType = ANY_SUBLINK; + n->testexpr = $1; + n->operName = list_make1(makeString("=")); + $$ = (Node *)n; + } + else + { + /* generate scalar IN expression */ + $$ = (Node *) makeSimpleA_Expr(AEXPR_IN, "=", $1, $3, @2); + } + } + | a_expr NOT IN_P in_expr + { + /* in_expr returns a SubLink or a list of a_exprs */ + if (IsA($4, SubLink)) + { + /* generate NOT (foo = ANY (subquery)) */ + /* Make an = ANY node */ + SubLink *n = (SubLink *) $4; + n->subLinkType = ANY_SUBLINK; + n->testexpr = $1; + n->operName = list_make1(makeString("=")); + /* Stick a NOT on top */ + $$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (Node *) n, @2); + } + else + { + /* generate scalar NOT IN expression */ + $$ = (Node *) makeSimpleA_Expr(AEXPR_IN, "<>", $1, $4, @2); + } + } + | a_expr subquery_Op sub_type select_with_parens %prec Op + { + SubLink *n = makeNode(SubLink); + n->subLinkType = $3; + n->testexpr = $1; + n->operName = $2; + n->subselect = $4; + $$ = (Node *)n; + } + | a_expr subquery_Op sub_type '(' a_expr ')' %prec Op + { + if ($3 == ANY_SUBLINK) + $$ = (Node *) makeA_Expr(AEXPR_OP_ANY, $2, $1, $5, @2); + else + $$ = (Node *) makeA_Expr(AEXPR_OP_ALL, $2, $1, $5, @2); + } + | UNIQUE select_with_parens + { + /* Not sure how to get rid of the parentheses + * but there are lots of shift/reduce errors without them. + * + * Should be able to implement this by plopping the entire + * select into a node, then transforming the target expressions + * from whatever they are into count(*), and testing the + * entire result equal to one. + * But, will probably implement a separate node in the executor. + */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("UNIQUE predicate is not yet implemented"))); + } + | a_expr IS DOCUMENT_P %prec IS + { + $$ = makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1($1)); + } + | a_expr IS NOT DOCUMENT_P %prec IS + { + $$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, + makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1($1)), + @2); + } + ; + +/* + * Restricted expressions + * + * b_expr is a subset of the complete expression syntax defined by a_expr. + * + * Presently, AND, NOT, IS, and IN are the a_expr keywords that would + * cause trouble in the places where b_expr is used. For simplicity, we + * just eliminate all the boolean-keyword-operator productions from b_expr. + */ +b_expr: c_expr + { $$ = $1; } + | b_expr TYPECAST Typename + { $$ = makeTypeCast($1, $3); } + | '+' b_expr %prec UMINUS + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", NULL, $2, @1); } + | '-' b_expr %prec UMINUS + { $$ = doNegate($2, @1); } + | b_expr '+' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "+", $1, $3, @2); } + | b_expr '-' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "-", $1, $3, @2); } + | b_expr '*' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "*", $1, $3, @2); } + | b_expr '/' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "/", $1, $3, @2); } + | b_expr '%' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "%", $1, $3, @2); } + | b_expr '^' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "^", $1, $3, @2); } + | b_expr '<' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2); } + | b_expr '>' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">", $1, $3, @2); } + | b_expr '=' b_expr + { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "=", $1, $3, @2); } + | b_expr qual_Op b_expr %prec Op + { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, $3, @2); } + | qual_Op b_expr %prec Op + { $$ = (Node *) makeA_Expr(AEXPR_OP, $1, NULL, $2, @1); } + | b_expr qual_Op %prec POSTFIXOP + { $$ = (Node *) makeA_Expr(AEXPR_OP, $2, $1, NULL, @2); } + | b_expr IS DISTINCT FROM b_expr %prec IS + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $5, @2); + } + | b_expr IS NOT DISTINCT FROM b_expr %prec IS + { + $$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, + NULL, (Node *) makeSimpleA_Expr(AEXPR_DISTINCT, "=", $1, $6, @2), @2); + } + | b_expr IS OF '(' type_list ')' %prec IS + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_OF, "=", $1, (Node *) $5, @2); + } + | b_expr IS NOT OF '(' type_list ')' %prec IS + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_OF, "<>", $1, (Node *) $6, @2); + } + | b_expr IS DOCUMENT_P %prec IS + { + $$ = makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1($1)); + } + | b_expr IS NOT DOCUMENT_P %prec IS + { + $$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, + makeXmlExpr(IS_DOCUMENT, NULL, NIL, list_make1($1)), + @2); + } + ; + +/* + * Productions that can be used in both a_expr and b_expr. + * + * Note: productions that refer recursively to a_expr or b_expr mostly + * cannot appear here. However, it's OK to refer to a_exprs that occur + * inside parentheses, such as function arguments; that cannot introduce + * ambiguity to the b_expr syntax. + */ +c_expr: columnref { $$ = $1; } + | AexprConst { $$ = $1; } + | PARAM opt_indirection + { + ParamRef *p = makeNode(ParamRef); + p->number = $1; + if ($2) + { + A_Indirection *n = makeNode(A_Indirection); + n->arg = (Node *) p; + n->indirection = $2; + $$ = (Node *) n; + } + else + $$ = (Node *) p; + } + | '(' a_expr ')' opt_indirection + { + if ($4) + { + A_Indirection *n = makeNode(A_Indirection); + n->arg = $2; + n->indirection = $4; + $$ = (Node *)n; + } + else + $$ = $2; + } + | case_expr + { $$ = $1; } + | func_expr + { $$ = $1; } + | select_with_parens %prec UMINUS + { + SubLink *n = makeNode(SubLink); + n->subLinkType = EXPR_SUBLINK; + n->testexpr = NULL; + n->operName = NIL; + n->subselect = $1; + $$ = (Node *)n; + } + | EXISTS select_with_parens + { + SubLink *n = makeNode(SubLink); + n->subLinkType = EXISTS_SUBLINK; + n->testexpr = NULL; + n->operName = NIL; + n->subselect = $2; + $$ = (Node *)n; + } + | ARRAY select_with_parens + { + SubLink *n = makeNode(SubLink); + n->subLinkType = ARRAY_SUBLINK; + n->testexpr = NULL; + n->operName = NIL; + n->subselect = $2; + $$ = (Node *)n; + } + | ARRAY array_expr + { $$ = $2; } + | row + { + RowExpr *r = makeNode(RowExpr); + r->args = $1; + r->row_typeid = 0; /* not analyzed yet */ + $$ = (Node *)r; + } + ; + +/* + * func_expr is split out from c_expr just so that we have a classification + * for "everything that is a function call or looks like one". This isn't + * very important, but it saves us having to document which variants are + * legal in the backwards-compatible functional-index syntax for CREATE INDEX. + * (Note that many of the special SQL functions wouldn't actually make any + * sense as functional index entries, but we ignore that consideration here.) + */ +func_expr: func_name '(' ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = $1; + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | func_name '(' expr_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = $1; + n->args = $3; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | func_name '(' ALL expr_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = $1; + n->args = $4; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + /* Ideally we'd mark the FuncCall node to indicate + * "must be an aggregate", but there's no provision + * for that in FuncCall at the moment. + */ + n->location = @1; + $$ = (Node *)n; + } + | func_name '(' DISTINCT expr_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = $1; + n->args = $4; + n->agg_star = FALSE; + n->agg_distinct = TRUE; + n->location = @1; + $$ = (Node *)n; + } + | func_name '(' '*' ')' + { + /* + * We consider AGGREGATE(*) to invoke a parameterless + * aggregate. This does the right thing for COUNT(*), + * and there are no other aggregates in SQL92 that accept + * '*' as parameter. + * + * The FuncCall node is also marked agg_star = true, + * so that later processing can detect what the argument + * really was. + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = $1; + n->args = NIL; + n->agg_star = TRUE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | CURRENT_DATE + { + /* + * Translate as "'now'::text::date". + * + * We cannot use "'now'::date" because coerce_type() will + * immediately reduce that to a constant representing + * today's date. We need to delay the conversion until + * runtime, else the wrong things will happen when + * CURRENT_DATE is used in a column default value or rule. + * + * This could be simplified if we had a way to generate + * an expression tree representing runtime application + * of type-input conversion functions. (As of PG 7.3 + * that is actually possible, but not clear that we want + * to rely on it.) + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("date"); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | CURRENT_TIME + { + /* + * Translate as "'now'::text::timetz". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timetz"); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | CURRENT_TIME '(' Iconst ')' + { + /* + * Translate as "'now'::text::timetz(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + d = SystemTypeName("timetz"); + d->typmods = list_make1(makeIntConst($3)); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | CURRENT_TIMESTAMP + { + /* + * Translate as "now()", since we have a function that + * does exactly what is needed. + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("now"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | CURRENT_TIMESTAMP '(' Iconst ')' + { + /* + * Translate as "'now'::text::timestamptz(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timestamptz"); + d->typmods = list_make1(makeIntConst($3)); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | LOCALTIME + { + /* + * Translate as "'now'::text::time". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("time"); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | LOCALTIME '(' Iconst ')' + { + /* + * Translate as "'now'::text::time(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + d = SystemTypeName("time"); + d->typmods = list_make1(makeIntConst($3)); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | LOCALTIMESTAMP + { + /* + * Translate as "'now'::text::timestamp". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timestamp"); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | LOCALTIMESTAMP '(' Iconst ')' + { + /* + * Translate as "'now'::text::timestamp(n)". + * See comments for CURRENT_DATE. + */ + A_Const *s = makeNode(A_Const); + TypeName *d; + + s->val.type = T_String; + s->val.val.str = "now"; + s->typename = SystemTypeName("text"); + + d = SystemTypeName("timestamp"); + d->typmods = list_make1(makeIntConst($3)); + + $$ = (Node *)makeTypeCast((Node *)s, d); + } + | CURRENT_ROLE + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("current_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | CURRENT_USER + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("current_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | SESSION_USER + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("session_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | USER + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("current_user"); + n->args = NIL; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | CAST '(' a_expr AS Typename ')' + { $$ = makeTypeCast($3, $5); } + | EXTRACT '(' extract_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("date_part"); + n->args = $3; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | OVERLAY '(' overlay_list ')' + { + /* overlay(A PLACING B FROM C FOR D) is converted to + * substring(A, 1, C-1) || B || substring(A, C+1, C+D) + * overlay(A PLACING B FROM C) is converted to + * substring(A, 1, C-1) || B || substring(A, C+1, C+char_length(B)) + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("overlay"); + n->args = $3; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | POSITION '(' position_list ')' + { + /* position(A in B) is converted to position(B, A) */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("position"); + n->args = $3; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | SUBSTRING '(' substr_list ')' + { + /* substring(A from B for C) is converted to + * substring(A, B, C) - thomas 2000-11-28 + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("substring"); + n->args = $3; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | TREAT '(' a_expr AS Typename ')' + { + /* TREAT(expr AS target) converts expr of a particular type to target, + * which is defined to be a subtype of the original expression. + * In SQL99, this is intended for use with structured UDTs, + * but let's make this a generally useful form allowing stronger + * coercions than are handled by implicit casting. + */ + FuncCall *n = makeNode(FuncCall); + /* Convert SystemTypeName() to SystemFuncName() even though + * at the moment they result in the same thing. + */ + n->funcname = SystemFuncName(((Value *)llast($5->names))->val.str); + n->args = list_make1($3); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | TRIM '(' BOTH trim_list ')' + { + /* various trim expressions are defined in SQL92 + * - thomas 1997-07-19 + */ + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("btrim"); + n->args = $4; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | TRIM '(' LEADING trim_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("ltrim"); + n->args = $4; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | TRIM '(' TRAILING trim_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("rtrim"); + n->args = $4; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | TRIM '(' trim_list ')' + { + FuncCall *n = makeNode(FuncCall); + n->funcname = SystemFuncName("btrim"); + n->args = $3; + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = @1; + $$ = (Node *)n; + } + | NULLIF '(' a_expr ',' a_expr ')' + { + $$ = (Node *) makeSimpleA_Expr(AEXPR_NULLIF, "=", $3, $5, @1); + } + | COALESCE '(' expr_list ')' + { + CoalesceExpr *c = makeNode(CoalesceExpr); + c->args = $3; + $$ = (Node *)c; + } + | GREATEST '(' expr_list ')' + { + MinMaxExpr *v = makeNode(MinMaxExpr); + v->args = $3; + v->op = IS_GREATEST; + $$ = (Node *)v; + } + | LEAST '(' expr_list ')' + { + MinMaxExpr *v = makeNode(MinMaxExpr); + v->args = $3; + v->op = IS_LEAST; + $$ = (Node *)v; + } + | XMLCONCAT '(' expr_list ')' + { + $$ = makeXmlExpr(IS_XMLCONCAT, NULL, NIL, $3); + } + | XMLELEMENT '(' NAME_P ColLabel ')' + { + $$ = makeXmlExpr(IS_XMLELEMENT, $4, NIL, NIL); + } + | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ')' + { + $$ = makeXmlExpr(IS_XMLELEMENT, $4, $6, NIL); + } + | XMLELEMENT '(' NAME_P ColLabel ',' expr_list ')' + { + $$ = makeXmlExpr(IS_XMLELEMENT, $4, NIL, $6); + } + | XMLELEMENT '(' NAME_P ColLabel ',' xml_attributes ',' expr_list ')' + { + $$ = makeXmlExpr(IS_XMLELEMENT, $4, $6, $8); + } + | XMLFOREST '(' xml_attribute_list ')' + { + $$ = makeXmlExpr(IS_XMLFOREST, NULL, $3, NIL); + } + | XMLPARSE '(' document_or_content a_expr xml_whitespace_option ')' + { + XmlExpr *x = (XmlExpr *) makeXmlExpr(IS_XMLPARSE, NULL, NIL, + list_make2($4, + makeBoolAConst($5))); + x->xmloption = $3; + $$ = (Node *)x; + } + | XMLPI '(' NAME_P ColLabel ')' + { + $$ = makeXmlExpr(IS_XMLPI, $4, NULL, NIL); + } + | XMLPI '(' NAME_P ColLabel ',' a_expr ')' + { + $$ = makeXmlExpr(IS_XMLPI, $4, NULL, list_make1($6)); + } + | XMLROOT '(' a_expr ',' xml_root_version opt_xml_root_standalone ')' + { + $$ = makeXmlExpr(IS_XMLROOT, NULL, NIL, + list_make3($3, $5, $6)); + } + | XMLSERIALIZE '(' document_or_content a_expr AS SimpleTypename ')' + { + XmlSerialize *n = makeNode(XmlSerialize); + n->xmloption = $3; + n->expr = $4; + n->typename = $6; + $$ = (Node *)n; + } + ; + +/* + * SQL/XML support + */ +xml_root_version: VERSION_P a_expr + { $$ = $2; } + | VERSION_P NO VALUE_P + { + A_Const *val = makeNode(A_Const); + val->val.type = T_Null; + $$ = (Node *) val; + } + ; + +opt_xml_root_standalone: ',' STANDALONE_P YES_P + { $$ = (Node *) makeIntConst(XML_STANDALONE_YES); } + | ',' STANDALONE_P NO + { $$ = (Node *) makeIntConst(XML_STANDALONE_NO); } + | ',' STANDALONE_P NO VALUE_P + { $$ = (Node *) makeIntConst(XML_STANDALONE_NO_VALUE); } + | /*EMPTY*/ + { $$ = (Node *) makeIntConst(XML_STANDALONE_OMITTED); } + ; + +xml_attributes: XMLATTRIBUTES '(' xml_attribute_list ')' { $$ = $3; } + ; + +xml_attribute_list: xml_attribute_el { $$ = list_make1($1); } + | xml_attribute_list ',' xml_attribute_el { $$ = lappend($1, $3); } + ; + +xml_attribute_el: a_expr AS ColLabel + { + $$ = makeNode(ResTarget); + $$->name = $3; + $$->indirection = NULL; + $$->val = (Node *) $1; + $$->location = @1; + } + | a_expr + { + $$ = makeNode(ResTarget); + $$->name = NULL; + $$->indirection = NULL; + $$->val = (Node *) $1; + $$->location = @1; + } + ; + +document_or_content: DOCUMENT_P { $$ = XMLOPTION_DOCUMENT; } + | CONTENT_P { $$ = XMLOPTION_CONTENT; } + ; + +xml_whitespace_option: PRESERVE WHITESPACE_P { $$ = TRUE; } + | STRIP_P WHITESPACE_P { $$ = FALSE; } + | /*EMPTY*/ { $$ = FALSE; } + ; + +/* + * Supporting nonterminals for expressions. + */ + +/* Explicit row production. + * + * SQL99 allows an optional ROW keyword, so we can now do single-element rows + * without conflicting with the parenthesized a_expr production. Without the + * ROW keyword, there must be more than one a_expr inside the parens. + */ +row: ROW '(' expr_list ')' { $$ = $3; } + | ROW '(' ')' { $$ = NIL; } + | '(' expr_list ',' a_expr ')' { $$ = lappend($2, $4); } + ; + +sub_type: ANY { $$ = ANY_SUBLINK; } + | SOME { $$ = ANY_SUBLINK; } + | ALL { $$ = ALL_SUBLINK; } + ; + +all_Op: Op { $$ = $1; } + | MathOp { $$ = $1; } + ; + +MathOp: '+' { $$ = "+"; } + | '-' { $$ = "-"; } + | '*' { $$ = "*"; } + | '/' { $$ = "/"; } + | '%' { $$ = "%"; } + | '^' { $$ = "^"; } + | '<' { $$ = "<"; } + | '>' { $$ = ">"; } + | '=' { $$ = "="; } + ; + +qual_Op: Op + { $$ = list_make1(makeString($1)); } + | OPERATOR '(' any_operator ')' + { $$ = $3; } + ; + +qual_all_Op: + all_Op + { $$ = list_make1(makeString($1)); } + | OPERATOR '(' any_operator ')' + { $$ = $3; } + ; + +subquery_Op: + all_Op + { $$ = list_make1(makeString($1)); } + | OPERATOR '(' any_operator ')' + { $$ = $3; } + | LIKE + { $$ = list_make1(makeString("~~")); } + | NOT LIKE + { $$ = list_make1(makeString("!~~")); } + | ILIKE + { $$ = list_make1(makeString("~~*")); } + | NOT ILIKE + { $$ = list_make1(makeString("!~~*")); } +/* cannot put SIMILAR TO here, because SIMILAR TO is a hack. + * the regular expression is preprocessed by a function (similar_escape), + * and the ~ operator for posix regular expressions is used. + * x SIMILAR TO y -> x ~ similar_escape(y) + * this transformation is made on the fly by the parser upwards. + * however the SubLink structure which handles any/some/all stuff + * is not ready for such a thing. + */ + ; + +expr_list: a_expr + { + $$ = list_make1($1); + } + | expr_list ',' a_expr + { + $$ = lappend($1, $3); + } + ; + +extract_list: + extract_arg FROM a_expr + { + A_Const *n = makeNode(A_Const); + n->val.type = T_String; + n->val.val.str = $1; + $$ = list_make2((Node *) n, $3); + } + | /*EMPTY*/ { $$ = NIL; } + ; + +type_list: Typename { $$ = list_make1($1); } + | type_list ',' Typename { $$ = lappend($1, $3); } + ; + +array_expr_list: array_expr + { $$ = list_make1($1); } + | array_expr_list ',' array_expr + { $$ = lappend($1, $3); } + ; + +array_expr: '[' expr_list ']' + { + ArrayExpr *n = makeNode(ArrayExpr); + n->elements = $2; + $$ = (Node *)n; + } + | '[' array_expr_list ']' + { + ArrayExpr *n = makeNode(ArrayExpr); + n->elements = $2; + $$ = (Node *)n; + } + ; + +/* Allow delimited string SCONST in extract_arg as an SQL extension. + * - thomas 2001-04-12 + */ + +extract_arg: + IDENT { $$ = $1; } + | YEAR_P { $$ = "year"; } + | MONTH_P { $$ = "month"; } + | DAY_P { $$ = "day"; } + | HOUR_P { $$ = "hour"; } + | MINUTE_P { $$ = "minute"; } + | SECOND_P { $$ = "second"; } + | SCONST { $$ = $1; } + ; + +/* OVERLAY() arguments + * SQL99 defines the OVERLAY() function: + * o overlay(text placing text from int for int) + * o overlay(text placing text from int) + */ +overlay_list: + a_expr overlay_placing substr_from substr_for + { + $$ = list_make4($1, $2, $3, $4); + } + | a_expr overlay_placing substr_from + { + $$ = list_make3($1, $2, $3); + } + ; + +overlay_placing: + PLACING a_expr + { $$ = $2; } + ; + +/* position_list uses b_expr not a_expr to avoid conflict with general IN */ + +position_list: + b_expr IN_P b_expr { $$ = list_make2($3, $1); } + | /*EMPTY*/ { $$ = NIL; } + ; + +/* SUBSTRING() arguments + * SQL9x defines a specific syntax for arguments to SUBSTRING(): + * o substring(text from int for int) + * o substring(text from int) get entire string from starting point "int" + * o substring(text for int) get first "int" characters of string + * o substring(text from pattern) get entire string matching pattern + * o substring(text from pattern for escape) same with specified escape char + * We also want to support generic substring functions which accept + * the usual generic list of arguments. So we will accept both styles + * here, and convert the SQL9x style to the generic list for further + * processing. - thomas 2000-11-28 + */ +substr_list: + a_expr substr_from substr_for + { + $$ = list_make3($1, $2, $3); + } + | a_expr substr_for substr_from + { + /* not legal per SQL99, but might as well allow it */ + $$ = list_make3($1, $3, $2); + } + | a_expr substr_from + { + $$ = list_make2($1, $2); + } + | a_expr substr_for + { + /* + * Since there are no cases where this syntax allows + * a textual FOR value, we forcibly cast the argument + * to int4. The possible matches in pg_proc are + * substring(text,int4) and substring(text,text), + * and we don't want the parser to choose the latter, + * which it is likely to do if the second argument + * is unknown or doesn't have an implicit cast to int4. + */ + A_Const *n = makeNode(A_Const); + n->val.type = T_Integer; + n->val.val.ival = 1; + $$ = list_make3($1, (Node *) n, + makeTypeCast($2, SystemTypeName("int4"))); + } + | expr_list + { + $$ = $1; + } + | /*EMPTY*/ + { $$ = NIL; } + ; + +substr_from: + FROM a_expr { $$ = $2; } + ; + +substr_for: FOR a_expr { $$ = $2; } + ; + +trim_list: a_expr FROM expr_list { $$ = lappend($3, $1); } + | FROM expr_list { $$ = $2; } + | expr_list { $$ = $1; } + ; + +in_expr: select_with_parens + { + SubLink *n = makeNode(SubLink); + n->subselect = $1; + /* other fields will be filled later */ + $$ = (Node *)n; + } + | '(' expr_list ')' { $$ = (Node *)$2; } + ; + +/* + * Define SQL92-style case clause. + * - Full specification + * CASE WHEN a = b THEN c ... ELSE d END + * - Implicit argument + * CASE a WHEN b THEN c ... ELSE d END + */ +case_expr: CASE case_arg when_clause_list case_default END_P + { + CaseExpr *c = makeNode(CaseExpr); + c->casetype = 0; /* not analyzed yet */ + c->arg = (Expr *) $2; + c->args = $3; + c->defresult = (Expr *) $4; + $$ = (Node *)c; + } + ; + +when_clause_list: + /* There must be at least one */ + when_clause { $$ = list_make1($1); } + | when_clause_list when_clause { $$ = lappend($1, $2); } + ; + +when_clause: + WHEN a_expr THEN a_expr + { + CaseWhen *w = makeNode(CaseWhen); + w->expr = (Expr *) $2; + w->result = (Expr *) $4; + $$ = (Node *)w; + } + ; + +case_default: + ELSE a_expr { $$ = $2; } + | /*EMPTY*/ { $$ = NULL; } + ; + +case_arg: a_expr { $$ = $1; } + | /*EMPTY*/ { $$ = NULL; } + ; + +/* + * columnref starts with relation_name not ColId, so that OLD and NEW + * references can be accepted. Note that when there are more than two + * dotted names, the first name is not actually a relation name... + */ +columnref: relation_name + { + $$ = makeColumnRef($1, NIL, @1); + } + | relation_name indirection + { + $$ = makeColumnRef($1, $2, @1); + } + ; + +indirection_el: + '.' attr_name + { + $$ = (Node *) makeString($2); + } + | '.' '*' + { + $$ = (Node *) makeString("*"); + } + | '[' a_expr ']' + { + A_Indices *ai = makeNode(A_Indices); + ai->lidx = NULL; + ai->uidx = $2; + $$ = (Node *) ai; + } + | '[' a_expr ':' a_expr ']' + { + A_Indices *ai = makeNode(A_Indices); + ai->lidx = $2; + ai->uidx = $4; + $$ = (Node *) ai; + } + ; + +indirection: + indirection_el { $$ = list_make1($1); } + | indirection indirection_el { $$ = lappend($1, $2); } + ; + +opt_indirection: + /*EMPTY*/ { $$ = NIL; } + | opt_indirection indirection_el { $$ = lappend($1, $2); } + ; + +opt_asymmetric: ASYMMETRIC + | /*EMPTY*/ + ; + +/* + * The SQL spec defines "contextually typed value expressions" and + * "contextually typed row value constructors", which for our purposes + * are the same as "a_expr" and "row" except that DEFAULT can appear at + * the top level. + */ + +ctext_expr: + a_expr { $$ = (Node *) $1; } + | DEFAULT { $$ = (Node *) makeNode(SetToDefault); } + ; + +ctext_expr_list: + ctext_expr { $$ = list_make1($1); } + | ctext_expr_list ',' ctext_expr { $$ = lappend($1, $3); } + ; + +/* + * We should allow ROW '(' ctext_expr_list ')' too, but that seems to require + * making VALUES a fully reserved word, which will probably break more apps + * than allowing the noise-word is worth. + */ +ctext_row: '(' ctext_expr_list ')' { $$ = $2; } + ; + + +/***************************************************************************** + * + * target list for SELECT + * + *****************************************************************************/ + +target_list: + target_el { $$ = list_make1($1); } + | target_list ',' target_el { $$ = lappend($1, $3); } + ; + +/* AS is not optional because shift/red conflict with unary ops */ +target_el: a_expr AS ColLabel + { + $$ = makeNode(ResTarget); + $$->name = $3; + $$->indirection = NIL; + $$->val = (Node *)$1; + $$->location = @1; + } + | a_expr + { + $$ = makeNode(ResTarget); + $$->name = NULL; + $$->indirection = NIL; + $$->val = (Node *)$1; + $$->location = @1; + } + | '*' + { + ColumnRef *n = makeNode(ColumnRef); + n->fields = list_make1(makeString("*")); + n->location = @1; + + $$ = makeNode(ResTarget); + $$->name = NULL; + $$->indirection = NIL; + $$->val = (Node *)n; + $$->location = @1; + } + ; + + +/***************************************************************************** + * + * Names and constants + * + *****************************************************************************/ + +relation_name: + SpecialRuleRelation { $$ = $1; } + | ColId { $$ = $1; } + ; + +qualified_name_list: + qualified_name { $$ = list_make1($1); } + | qualified_name_list ',' qualified_name { $$ = lappend($1, $3); } + ; + +/* + * The production for a qualified relation name has to exactly match the + * production for a qualified func_name, because in a FROM clause we cannot + * tell which we are parsing until we see what comes after it ('(' for a + * func_name, something else for a relation). Therefore we allow 'indirection' + * which may contain subscripts, and reject that case in the C code. + */ +qualified_name: + relation_name + { + $$ = makeNode(RangeVar); + $$->catalogname = NULL; + $$->schemaname = NULL; + $$->relname = $1; + } + | relation_name indirection + { + check_qualified_name($2); + $$ = makeNode(RangeVar); + switch (list_length($2)) + { + case 1: + $$->catalogname = NULL; + $$->schemaname = $1; + $$->relname = strVal(linitial($2)); + break; + case 2: + $$->catalogname = $1; + $$->schemaname = strVal(linitial($2)); + $$->relname = strVal(lsecond($2)); + break; + default: + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(lcons(makeString($1), $2))))); + break; + } + } + ; + +name_list: name + { $$ = list_make1(makeString($1)); } + | name_list ',' name + { $$ = lappend($1, makeString($3)); } + ; + + +name: ColId { $$ = $1; }; + +database_name: + ColId { $$ = $1; }; + +access_method: + ColId { $$ = $1; }; + +attr_name: ColLabel { $$ = $1; }; + +index_name: ColId { $$ = $1; }; + +file_name: Sconst { $$ = $1; }; + +/* + * The production for a qualified func_name has to exactly match the + * production for a qualified columnref, because we cannot tell which we + * are parsing until we see what comes after it ('(' or Sconst for a func_name, + * anything else for a columnref). Therefore we allow 'indirection' which + * may contain subscripts, and reject that case in the C code. (If we + * ever implement SQL99-like methods, such syntax may actually become legal!) + */ +func_name: type_function_name + { $$ = list_make1(makeString($1)); } + | relation_name indirection + { $$ = check_func_name(lcons(makeString($1), $2)); } + ; + + +/* + * Constants + */ +AexprConst: Iconst + { + A_Const *n = makeNode(A_Const); + n->val.type = T_Integer; + n->val.val.ival = $1; + $$ = (Node *)n; + } + | FCONST + { + A_Const *n = makeNode(A_Const); + n->val.type = T_Float; + n->val.val.str = $1; + $$ = (Node *)n; + } + | Sconst + { + A_Const *n = makeNode(A_Const); + n->val.type = T_String; + n->val.val.str = $1; + $$ = (Node *)n; + } + | BCONST + { + A_Const *n = makeNode(A_Const); + n->val.type = T_BitString; + n->val.val.str = $1; + $$ = (Node *)n; + } + | XCONST + { + /* This is a bit constant per SQL99: + * Without Feature F511, "BIT data type", + * a shall not be a + * or a . + */ + A_Const *n = makeNode(A_Const); + n->val.type = T_BitString; + n->val.val.str = $1; + $$ = (Node *)n; + } + | func_name Sconst + { + /* generic type 'literal' syntax */ + A_Const *n = makeNode(A_Const); + n->typename = makeTypeNameFromNameList($1); + n->typename->location = @1; + n->val.type = T_String; + n->val.val.str = $2; + $$ = (Node *)n; + } + | func_name '(' expr_list ')' Sconst + { + /* generic syntax with a type modifier */ + A_Const *n = makeNode(A_Const); + n->typename = makeTypeNameFromNameList($1); + n->typename->typmods = $3; + n->typename->location = @1; + n->val.type = T_String; + n->val.val.str = $5; + $$ = (Node *)n; + } + | ConstTypename Sconst + { + A_Const *n = makeNode(A_Const); + n->typename = $1; + n->val.type = T_String; + n->val.val.str = $2; + $$ = (Node *)n; + } + | ConstInterval Sconst opt_interval + { + A_Const *n = makeNode(A_Const); + n->typename = $1; + n->val.type = T_String; + n->val.val.str = $2; + /* precision is not specified, but fields may be... */ + if ($3 != INTERVAL_FULL_RANGE) + n->typename->typmods = list_make1(makeIntConst($3)); + $$ = (Node *)n; + } + | ConstInterval '(' Iconst ')' Sconst opt_interval + { + A_Const *n = makeNode(A_Const); + n->typename = $1; + n->val.type = T_String; + n->val.val.str = $5; + n->typename->typmods = list_make2(makeIntConst($6), + makeIntConst($3)); + $$ = (Node *)n; + } + | TRUE_P + { + $$ = (Node *)makeBoolAConst(TRUE); + } + | FALSE_P + { + $$ = (Node *)makeBoolAConst(FALSE); + } + | NULL_P + { + A_Const *n = makeNode(A_Const); + n->val.type = T_Null; + $$ = (Node *)n; + } + ; + +Iconst: ICONST { $$ = $1; }; +Sconst: SCONST { $$ = $1; }; +RoleId: ColId { $$ = $1; }; + +SignedIconst: ICONST { $$ = $1; } + | '-' ICONST { $$ = - $2; } + ; + +/* + * Name classification hierarchy. + * + * IDENT is the lexeme returned by the lexer for identifiers that match + * no known keyword. In most cases, we can accept certain keywords as + * names, not only IDENTs. We prefer to accept as many such keywords + * as possible to minimize the impact of "reserved words" on programmers. + * So, we divide names into several possible classes. The classification + * is chosen in part to make keywords acceptable as names wherever possible. + */ + +/* Column identifier --- names that can be column, table, etc names. + */ +ColId: IDENT { $$ = $1; } + | unreserved_keyword { $$ = pstrdup($1); } + | col_name_keyword { $$ = pstrdup($1); } + ; + +/* Type/function identifier --- names that can be type or function names. + */ +type_function_name: IDENT { $$ = $1; } + | unreserved_keyword { $$ = pstrdup($1); } + | type_func_name_keyword { $$ = pstrdup($1); } + ; + +/* Column label --- allowed labels in "AS" clauses. + * This presently includes *all* Postgres keywords. + */ +ColLabel: IDENT { $$ = $1; } + | unreserved_keyword { $$ = pstrdup($1); } + | col_name_keyword { $$ = pstrdup($1); } + | type_func_name_keyword { $$ = pstrdup($1); } + | reserved_keyword { $$ = pstrdup($1); } + ; + + +/* + * Keyword category lists. Generally, every keyword present in + * the Postgres grammar should appear in exactly one of these lists. + * + * Put a new keyword into the first list that it can go into without causing + * shift or reduce conflicts. The earlier lists define "less reserved" + * categories of keywords. + * + * Make sure that each keyword's category in keywords.c matches where + * it is listed here. (Someday we may be able to generate these lists and + * keywords.c's table from a common master list.) + */ + +/* "Unreserved" keywords --- available for use as any kind of name. + */ +unreserved_keyword: + ABORT_P + | ABSOLUTE_P + | ACCESS + | ACTION + | ADD_P + | ADMIN + | AFTER + | AGGREGATE + | ALSO + | ALTER + | ALWAYS + | ASSERTION + | ASSIGNMENT + | AT + | BACKWARD + | BEFORE + | BEGIN_P + | BY + | CACHE + | CALLED + | CASCADE + | CASCADED + | CHAIN + | CHARACTERISTICS + | CHECKPOINT + | CLASS + | CLOSE + | CLUSTER + | COMMENT + | COMMIT + | COMMITTED + | CONCURRENTLY + | CONFIGURATION + | CONNECTION + | CONSTRAINTS + | CONTENT_P + | CONVERSION_P + | COPY + | COST + | CREATEDB + | CREATEROLE + | CREATEUSER + | CSV + | CURRENT_P + | CURSOR + | CYCLE + | DATABASE + | DAY_P + | DEALLOCATE + | DECLARE + | DEFAULTS + | DEFERRED + | DEFINER + | DELETE_P + | DELIMITER + | DELIMITERS + | DICTIONARY + | DISABLE_P + | DISCARD + | DOCUMENT_P + | DOMAIN_P + | DOUBLE_P + | DROP + | EACH + | ENABLE_P + | ENCODING + | ENCRYPTED + | ENUM_P + | ESCAPE + | EXCLUDING + | EXCLUSIVE + | EXECUTE + | EXPLAIN + | EXTERNAL + | FAMILY + | FETCH + | FIRST_P + | FORCE + | FORWARD + | FUNCTION + | GLOBAL + | GRANTED + | HANDLER + | HEADER_P + | HOLD + | HOUR_P + | IF_P + | IMMEDIATE + | IMMUTABLE + | IMPLICIT_P + | INCLUDING + | INCREMENT + | INDEX + | INDEXES + | INHERIT + | INHERITS + | INPUT_P + | INSENSITIVE + | INSERT + | INSTEAD + | INVOKER + | ISOLATION + | KEY + | LANCOMPILER + | LANGUAGE + | LARGE_P + | LAST_P + | LEVEL + | LISTEN + | LOAD + | LOCAL + | LOCATION + | LOCK_P + | LOGIN_P + | MAPPING + | MATCH + | MAXVALUE + | MINUTE_P + | MINVALUE + | MODE + | MONTH_P + | MOVE + | NAME_P + | NAMES + | NEXT + | NO + | NOCREATEDB + | NOCREATEROLE + | NOCREATEUSER + | NOINHERIT + | NOLOGIN_P + | NOSUPERUSER + | NOTHING + | NOTIFY + | NOWAIT + | NULLS_P + | OBJECT_P + | OF + | OIDS + | OPERATOR + | OPTION + | OWNED + | OWNER + | PARSER + | PARTIAL + | PASSWORD + | PLANS + | PREPARE + | PREPARED + | PRESERVE + | PRIOR + | PRIVILEGES + | PROCEDURAL + | PROCEDURE + | QUOTE + | READ + | REASSIGN + | RECHECK + | REINDEX + | RELATIVE_P + | RELEASE + | RENAME + | REPEATABLE + | REPLACE + | REPLICA + | RESET + | RESTART + | RESTRICT + | RETURNS + | REVOKE + | ROLE + | ROLLBACK + | ROWS + | RULE + | SAVEPOINT + | SCHEMA + | SCROLL + | SEARCH + | SECOND_P + | SECURITY + | SEQUENCE + | SERIALIZABLE + | SESSION + | SET + | SHARE + | SHOW + | SIMPLE + | STABLE + | STANDALONE_P + | START + | STATEMENT + | STATISTICS + | STDIN + | STDOUT + | STORAGE + | STRICT_P + | STRIP_P + | SUPERUSER_P + | SYSID + | SYSTEM_P + | TABLESPACE + | TEMP + | TEMPLATE + | TEMPORARY + | TEXT_P + | TRANSACTION + | TRIGGER + | TRUNCATE + | TRUSTED + | TYPE_P + | UNCOMMITTED + | UNENCRYPTED + | UNKNOWN + | UNLISTEN + | UNTIL + | UPDATE + | VACUUM + | VALID + | VALIDATOR + | VALUE_P + | VARYING + | VERSION_P + | VIEW + | VOLATILE + | WHITESPACE_P + | WITH + | WITHOUT + | WORK + | WRITE + | XML_P + | YEAR_P + | YES_P + | ZONE + ; + +/* Column identifier --- keywords that can be column, table, etc names. + * + * Many of these keywords will in fact be recognized as type or function + * names too; but they have special productions for the purpose, and so + * can't be treated as "generic" type or function names. + * + * The type names appearing here are not usable as function names + * because they can be followed by '(' in typename productions, which + * looks too much like a function call for an LR(1) parser. + */ +col_name_keyword: + BIGINT + | BIT + | BOOLEAN_P + | CHAR_P + | CHARACTER + | COALESCE + | DEC + | DECIMAL_P + | EXISTS + | EXTRACT + | FLOAT_P + | GREATEST + | INOUT + | INT_P + | INTEGER + | INTERVAL + | LEAST + | NATIONAL + | NCHAR + | NONE + | NULLIF + | NUMERIC + | OUT_P + | OVERLAY + | POSITION + | PRECISION + | REAL + | ROW + | SETOF + | SMALLINT + | SUBSTRING + | TIME + | TIMESTAMP + | TREAT + | TRIM + | VALUES + | VARCHAR + | XMLATTRIBUTES + | XMLCONCAT + | XMLELEMENT + | XMLFOREST + | XMLPARSE + | XMLPI + | XMLROOT + | XMLSERIALIZE + ; + +/* Type/function identifier --- keywords that can be type or function names. + * + * Most of these are keywords that are used as operators in expressions; + * in general such keywords can't be column names because they would be + * ambiguous with variables, but they are unambiguous as function identifiers. + * + * Do not include POSITION, SUBSTRING, etc here since they have explicit + * productions in a_expr to support the goofy SQL9x argument syntax. + * - thomas 2000-11-28 + */ +type_func_name_keyword: + AUTHORIZATION + | BETWEEN + | BINARY + | CROSS + | FREEZE + | FULL + | ILIKE + | INNER_P + | IS + | ISNULL + | JOIN + | LEFT + | LIKE + | NATURAL + | NOTNULL + | OUTER_P + | OVERLAPS + | RIGHT + | SIMILAR + | VERBOSE + ; + +/* Reserved keyword --- these keywords are usable only as a ColLabel. + * + * Keywords appear here if they could not be distinguished from variable, + * type, or function names in some contexts. Don't put things here unless + * forced to. + */ +reserved_keyword: + ALL + | ANALYSE + | ANALYZE + | AND + | ANY + | ARRAY + | AS + | ASC + | ASYMMETRIC + | BOTH + | CASE + | CAST + | CHECK + | COLLATE + | COLUMN + | CONSTRAINT + | CREATE + | CURRENT_DATE + | CURRENT_ROLE + | CURRENT_TIME + | CURRENT_TIMESTAMP + | CURRENT_USER + | DEFAULT + | DEFERRABLE + | DESC + | DISTINCT + | DO + | ELSE + | END_P + | EXCEPT + | FALSE_P + | FOR + | FOREIGN + | FROM + | GRANT + | GROUP_P + | HAVING + | IN_P + | INITIALLY + | INTERSECT + | INTO + | LEADING + | LIMIT + | LOCALTIME + | LOCALTIMESTAMP + | NEW + | NOT + | NULL_P + | OFF + | OFFSET + | OLD + | ON + | ONLY + | OR + | ORDER + | PLACING + | PRIMARY + | REFERENCES + | RETURNING + | SELECT + | SESSION_USER + | SOME + | SYMMETRIC + | TABLE + | THEN + | TO + | TRAILING + | TRUE_P + | UNION + | UNIQUE + | USER + | USING + | WHEN + | WHERE + ; + + +SpecialRuleRelation: + OLD + { + if (QueryIsRule) + $$ = "*OLD*"; + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("OLD used in query that is not in a rule"))); + } + | NEW + { + if (QueryIsRule) + $$ = "*NEW*"; + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("NEW used in query that is not in a rule"))); + } + ; + +%% + +static Node * +makeColumnRef(char *relname, List *indirection, int location) +{ + /* + * Generate a ColumnRef node, with an A_Indirection node added if there + * is any subscripting in the specified indirection list. However, + * any field selection at the start of the indirection list must be + * transposed into the "fields" part of the ColumnRef node. + */ + ColumnRef *c = makeNode(ColumnRef); + int nfields = 0; + ListCell *l; + + c->location = location; + foreach(l, indirection) + { + if (IsA(lfirst(l), A_Indices)) + { + A_Indirection *i = makeNode(A_Indirection); + + if (nfields == 0) + { + /* easy case - all indirection goes to A_Indirection */ + c->fields = list_make1(makeString(relname)); + i->indirection = indirection; + } + else + { + /* got to split the list in two */ + i->indirection = list_copy_tail(indirection, nfields); + indirection = list_truncate(indirection, nfields); + c->fields = lcons(makeString(relname), indirection); + } + i->arg = (Node *) c; + return (Node *) i; + } + nfields++; + } + /* No subscripting, so all indirection gets added to field list */ + c->fields = lcons(makeString(relname), indirection); + return (Node *) c; +} + +static Node * +makeTypeCast(Node *arg, TypeName *typename) +{ + /* + * Simply generate a TypeCast node. + * + * Earlier we would determine whether an A_Const would + * be acceptable, however Domains require coerce_type() + * to process them -- applying constraints as required. + */ + TypeCast *n = makeNode(TypeCast); + n->arg = arg; + n->typename = typename; + return (Node *) n; +} + +static Node * +makeStringConst(char *str, TypeName *typename) +{ + A_Const *n = makeNode(A_Const); + + n->val.type = T_String; + n->val.val.str = str; + n->typename = typename; + + return (Node *)n; +} + +static Node * +makeIntConst(int val) +{ + A_Const *n = makeNode(A_Const); + n->val.type = T_Integer; + n->val.val.ival = val; + n->typename = SystemTypeName("int4"); + + return (Node *)n; +} + +static Node * +makeFloatConst(char *str) +{ + A_Const *n = makeNode(A_Const); + + n->val.type = T_Float; + n->val.val.str = str; + n->typename = SystemTypeName("float8"); + + return (Node *)n; +} + +static Node * +makeAConst(Value *v) +{ + Node *n; + + switch (v->type) + { + case T_Float: + n = makeFloatConst(v->val.str); + break; + + case T_Integer: + n = makeIntConst(v->val.ival); + break; + + case T_String: + default: + n = makeStringConst(v->val.str, NULL); + break; + } + + return n; +} + +/* makeBoolAConst() + * Create an A_Const node and initialize to a boolean constant. + */ +static A_Const * +makeBoolAConst(bool state) +{ + A_Const *n = makeNode(A_Const); + n->val.type = T_String; + n->val.val.str = (state? "t": "f"); + n->typename = SystemTypeName("bool"); + return n; +} + +/* makeOverlaps() + * Create and populate a FuncCall node to support the OVERLAPS operator. + */ +static FuncCall * +makeOverlaps(List *largs, List *rargs, int location) +{ + FuncCall *n = makeNode(FuncCall); + + n->funcname = SystemFuncName("overlaps"); + if (list_length(largs) == 1) + largs = lappend(largs, largs); + else if (list_length(largs) != 2) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("wrong number of parameters on left side of OVERLAPS expression"))); + if (list_length(rargs) == 1) + rargs = lappend(rargs, rargs); + else if (list_length(rargs) != 2) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("wrong number of parameters on right side of OVERLAPS expression"))); + n->args = list_concat(largs, rargs); + n->agg_star = FALSE; + n->agg_distinct = FALSE; + n->location = location; + return n; +} + +/* check_qualified_name --- check the result of qualified_name production + * + * It's easiest to let the grammar production for qualified_name allow + * subscripts and '*', which we then must reject here. + */ +static void +check_qualified_name(List *names) +{ + ListCell *i; + + foreach(i, names) + { + if (!IsA(lfirst(i), String)) + yyerror("syntax error"); + else if (strcmp(strVal(lfirst(i)), "*") == 0) + yyerror("syntax error"); + } +} + +/* check_func_name --- check the result of func_name production + * + * It's easiest to let the grammar production for func_name allow subscripts + * and '*', which we then must reject here. + */ +static List * +check_func_name(List *names) +{ + ListCell *i; + + foreach(i, names) + { + if (!IsA(lfirst(i), String)) + yyerror("syntax error"); + else if (strcmp(strVal(lfirst(i)), "*") == 0) + yyerror("syntax error"); + } + return names; +} + +/* extractArgTypes() + * Given a list of FunctionParameter nodes, extract a list of just the + * argument types (TypeNames) for input parameters only. This is what + * is needed to look up an existing function, which is what is wanted by + * the productions that use this call. + */ +static List * +extractArgTypes(List *parameters) +{ + List *result = NIL; + ListCell *i; + + foreach(i, parameters) + { + FunctionParameter *p = (FunctionParameter *) lfirst(i); + + if (p->mode != FUNC_PARAM_OUT) /* keep if IN or INOUT */ + result = lappend(result, p->argType); + } + return result; +} + +/* findLeftmostSelect() + * Find the leftmost component SelectStmt in a set-operation parsetree. + */ +static SelectStmt * +findLeftmostSelect(SelectStmt *node) +{ + while (node && node->op != SETOP_NONE) + node = node->larg; + return node; +} + +/* insertSelectOptions() + * Insert ORDER BY, etc into an already-constructed SelectStmt. + * + * This routine is just to avoid duplicating code in SelectStmt productions. + */ +static void +insertSelectOptions(SelectStmt *stmt, + List *sortClause, List *lockingClause, + Node *limitOffset, Node *limitCount) +{ + /* + * Tests here are to reject constructs like + * (SELECT foo ORDER BY bar) ORDER BY baz + */ + if (sortClause) + { + if (stmt->sortClause) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple ORDER BY clauses not allowed"))); + stmt->sortClause = sortClause; + } + /* We can handle multiple locking clauses, though */ + stmt->lockingClause = list_concat(stmt->lockingClause, lockingClause); + if (limitOffset) + { + if (stmt->limitOffset) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple OFFSET clauses not allowed"))); + stmt->limitOffset = limitOffset; + } + if (limitCount) + { + if (stmt->limitCount) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("multiple LIMIT clauses not allowed"))); + stmt->limitCount = limitCount; + } +} + +static Node * +makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg) +{ + SelectStmt *n = makeNode(SelectStmt); + + n->op = op; + n->all = all; + n->larg = (SelectStmt *) larg; + n->rarg = (SelectStmt *) rarg; + return (Node *) n; +} + +/* SystemFuncName() + * Build a properly-qualified reference to a built-in function. + */ +List * +SystemFuncName(char *name) +{ + return list_make1(makeString(name)); +} + +/* SystemTypeName() + * Build a properly-qualified reference to a built-in type. + * + * typmod is defaulted, but may be changed afterwards by caller. + */ +TypeName * +SystemTypeName(char *name) +{ + return makeTypeNameFromNameList(list_make1(makeString(name))); +} + +/* parser_init() + * Initialize to parse one query string + */ +void +parser_init(void) +{ + QueryIsRule = FALSE; +} + +/* exprIsNullConstant() + * Test whether an a_expr is a plain NULL constant or not. + */ +bool +exprIsNullConstant(Node *arg) +{ + if (arg && IsA(arg, A_Const)) + { + A_Const *con = (A_Const *) arg; + + if (con->val.type == T_Null && + con->typename == NULL) + return TRUE; + } + return FALSE; +} + +/* doNegate() + * Handle negation of a numeric constant. + * + * Formerly, we did this here because the optimizer couldn't cope with + * indexquals that looked like "var = -4" --- it wants "var = const" + * and a unary minus operator applied to a constant didn't qualify. + * As of Postgres 7.0, that problem doesn't exist anymore because there + * is a constant-subexpression simplifier in the optimizer. However, + * there's still a good reason for doing this here, which is that we can + * postpone committing to a particular internal representation for simple + * negative constants. It's better to leave "-123.456" in string form + * until we know what the desired type is. + */ +static Node * +doNegate(Node *n, int location) +{ + if (IsA(n, A_Const)) + { + A_Const *con = (A_Const *)n; + + if (con->val.type == T_Integer) + { + con->val.val.ival = -con->val.val.ival; + return n; + } + if (con->val.type == T_Float) + { + doNegateFloat(&con->val); + return n; + } + } + + return (Node *) makeSimpleA_Expr(AEXPR_OP, "-", NULL, n, location); +} + +static void +doNegateFloat(Value *v) +{ + char *oldval = v->val.str; + + if (*oldval == '+') + oldval++; + if (*oldval == '-') + v->val.str = oldval+1; /* just strip the '-' */ + else + { + char *newval = (char *) palloc(strlen(oldval) + 2); + + *newval = '-'; + strcpy(newval+1, oldval); + v->val.str = newval; + } +} + +static Node * +makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args) +{ + XmlExpr *x = makeNode(XmlExpr); + + x->op = op; + x->name = name; + /* + * named_args is a list of ResTarget; it'll be split apart into separate + * expression and name lists in transformXmlExpr(). + */ + x->named_args = named_args; + x->arg_names = NIL; + x->args = args; + return (Node *) x; +} + +/* + * Create a DefElem setting "oids" to the specified value. + */ +static DefElem * +defWithOids(bool value) +{ + DefElem *f = makeNode(DefElem); + + f->defname = "oids"; + f->arg = (Node *) makeInteger(value); + return f; +} + + + +#undef yylex + + +/* + * Must undefine base_yylex before including scan.c, since we want it + * to create the function base_yylex not filtered_base_yylex. + */ +#undef base_yylex + +#include "scan.c" diff --git a/parser/gramparse.h b/parser/gramparse.h new file mode 100644 index 0000000..a7ccd6e --- /dev/null +++ b/parser/gramparse.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + * + * gramparse.h + * Declarations for routines exported from lexer and parser files. + * + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.31 2004/12/31 22:03:38 pgsql Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef GRAMPARSE_H +#define GRAMPARSE_H + +#include "parsenodes.h" + + +/* from parser.c */ +extern int sql_yylex(void); + +/* from scan.l */ +extern void scanner_init(const char *str); +extern void scanner_finish(void); +extern int base_yylex(void); +extern void yyerror(const char *message); + +/* from gram.y */ +extern void parser_init(void); +extern int base_yyparse(void); +extern List *SystemFuncName(char *name); +extern TypeName *SystemTypeName(char *name); +extern bool exprIsNullConstant(Node *arg); + +#endif /* GRAMPARSE_H */ diff --git a/parser/keywords.c b/parser/keywords.c new file mode 100644 index 0000000..25aa0ba --- /dev/null +++ b/parser/keywords.c @@ -0,0 +1,479 @@ +/*------------------------------------------------------------------------- + * + * keywords.c + * lexical token lookup for key words in PostgreSQL + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.192 2007/09/24 01:29:29 adunstan Exp $ + * + *------------------------------------------------------------------------- + */ +#include "pool_parser.h" + +#include +#include + +#include "parsenodes.h" +#include "gramparse.h" /* required before parser/parse.h! */ +#include "keywords.h" +#include "gram.h" + +/* NB: This file is also used by pg_dump. */ + +/* + * List of keyword (name, token-value, category) entries. + * + * !!WARNING!!: This list must be sorted by ASCII name, because binary + * search is used to locate entries. + */ +static const ScanKeyword ScanKeywords[] = { + /* name, value, category */ + {"abort", ABORT_P, UNRESERVED_KEYWORD}, + {"absolute", ABSOLUTE_P, UNRESERVED_KEYWORD}, + {"access", ACCESS, UNRESERVED_KEYWORD}, + {"action", ACTION, UNRESERVED_KEYWORD}, + {"add", ADD_P, UNRESERVED_KEYWORD}, + {"admin", ADMIN, UNRESERVED_KEYWORD}, + {"after", AFTER, UNRESERVED_KEYWORD}, + {"aggregate", AGGREGATE, UNRESERVED_KEYWORD}, + {"all", ALL, RESERVED_KEYWORD}, + {"also", ALSO, UNRESERVED_KEYWORD}, + {"alter", ALTER, UNRESERVED_KEYWORD}, + {"always", ALWAYS, UNRESERVED_KEYWORD}, + {"analyse", ANALYSE, RESERVED_KEYWORD}, /* British spelling */ + {"analyze", ANALYZE, RESERVED_KEYWORD}, + {"and", AND, RESERVED_KEYWORD}, + {"any", ANY, RESERVED_KEYWORD}, + {"array", ARRAY, RESERVED_KEYWORD}, + {"as", AS, RESERVED_KEYWORD}, + {"asc", ASC, RESERVED_KEYWORD}, + {"assertion", ASSERTION, UNRESERVED_KEYWORD}, + {"assignment", ASSIGNMENT, UNRESERVED_KEYWORD}, + {"asymmetric", ASYMMETRIC, RESERVED_KEYWORD}, + {"at", AT, UNRESERVED_KEYWORD}, + {"authorization", AUTHORIZATION, TYPE_FUNC_NAME_KEYWORD}, + {"backward", BACKWARD, UNRESERVED_KEYWORD}, + {"before", BEFORE, UNRESERVED_KEYWORD}, + {"begin", BEGIN_P, UNRESERVED_KEYWORD}, + {"between", BETWEEN, TYPE_FUNC_NAME_KEYWORD}, + {"bigint", BIGINT, COL_NAME_KEYWORD}, + {"binary", BINARY, TYPE_FUNC_NAME_KEYWORD}, + {"bit", BIT, COL_NAME_KEYWORD}, + {"boolean", BOOLEAN_P, COL_NAME_KEYWORD}, + {"both", BOTH, RESERVED_KEYWORD}, + {"by", BY, UNRESERVED_KEYWORD}, + {"cache", CACHE, UNRESERVED_KEYWORD}, + {"called", CALLED, UNRESERVED_KEYWORD}, + {"cascade", CASCADE, UNRESERVED_KEYWORD}, + {"cascaded", CASCADED, UNRESERVED_KEYWORD}, + {"case", CASE, RESERVED_KEYWORD}, + {"cast", CAST, RESERVED_KEYWORD}, + {"chain", CHAIN, UNRESERVED_KEYWORD}, + {"char", CHAR_P, COL_NAME_KEYWORD}, + {"character", CHARACTER, COL_NAME_KEYWORD}, + {"characteristics", CHARACTERISTICS, UNRESERVED_KEYWORD}, + {"check", CHECK, RESERVED_KEYWORD}, + {"checkpoint", CHECKPOINT, UNRESERVED_KEYWORD}, + {"class", CLASS, UNRESERVED_KEYWORD}, + {"close", CLOSE, UNRESERVED_KEYWORD}, + {"cluster", CLUSTER, UNRESERVED_KEYWORD}, + {"coalesce", COALESCE, COL_NAME_KEYWORD}, + {"collate", COLLATE, RESERVED_KEYWORD}, + {"column", COLUMN, RESERVED_KEYWORD}, + {"comment", COMMENT, UNRESERVED_KEYWORD}, + {"commit", COMMIT, UNRESERVED_KEYWORD}, + {"committed", COMMITTED, UNRESERVED_KEYWORD}, + {"concurrently", CONCURRENTLY, UNRESERVED_KEYWORD}, + {"configuration", CONFIGURATION, UNRESERVED_KEYWORD}, + {"connection", CONNECTION, UNRESERVED_KEYWORD}, + {"constraint", CONSTRAINT, RESERVED_KEYWORD}, + {"constraints", CONSTRAINTS, UNRESERVED_KEYWORD}, + {"content", CONTENT_P, UNRESERVED_KEYWORD}, + {"conversion", CONVERSION_P, UNRESERVED_KEYWORD}, + {"copy", COPY, UNRESERVED_KEYWORD}, + {"cost", COST, UNRESERVED_KEYWORD}, + {"create", CREATE, RESERVED_KEYWORD}, + {"createdb", CREATEDB, UNRESERVED_KEYWORD}, + {"createrole", CREATEROLE, UNRESERVED_KEYWORD}, + {"createuser", CREATEUSER, UNRESERVED_KEYWORD}, + {"cross", CROSS, TYPE_FUNC_NAME_KEYWORD}, + {"csv", CSV, UNRESERVED_KEYWORD}, + {"current", CURRENT_P, UNRESERVED_KEYWORD}, + {"current_date", CURRENT_DATE, RESERVED_KEYWORD}, + {"current_role", CURRENT_ROLE, RESERVED_KEYWORD}, + {"current_time", CURRENT_TIME, RESERVED_KEYWORD}, + {"current_timestamp", CURRENT_TIMESTAMP, RESERVED_KEYWORD}, + {"current_user", CURRENT_USER, RESERVED_KEYWORD}, + {"cursor", CURSOR, UNRESERVED_KEYWORD}, + {"cycle", CYCLE, UNRESERVED_KEYWORD}, + {"database", DATABASE, UNRESERVED_KEYWORD}, + {"day", DAY_P, UNRESERVED_KEYWORD}, + {"deallocate", DEALLOCATE, UNRESERVED_KEYWORD}, + {"dec", DEC, COL_NAME_KEYWORD}, + {"decimal", DECIMAL_P, COL_NAME_KEYWORD}, + {"declare", DECLARE, UNRESERVED_KEYWORD}, + {"default", DEFAULT, RESERVED_KEYWORD}, + {"defaults", DEFAULTS, UNRESERVED_KEYWORD}, + {"deferrable", DEFERRABLE, RESERVED_KEYWORD}, + {"deferred", DEFERRED, UNRESERVED_KEYWORD}, + {"definer", DEFINER, UNRESERVED_KEYWORD}, + {"delete", DELETE_P, UNRESERVED_KEYWORD}, + {"delimiter", DELIMITER, UNRESERVED_KEYWORD}, + {"delimiters", DELIMITERS, UNRESERVED_KEYWORD}, + {"desc", DESC, RESERVED_KEYWORD}, + {"dictionary", DICTIONARY, UNRESERVED_KEYWORD}, + {"disable", DISABLE_P, UNRESERVED_KEYWORD}, + {"discard", DISCARD, UNRESERVED_KEYWORD}, + {"distinct", DISTINCT, RESERVED_KEYWORD}, + {"do", DO, RESERVED_KEYWORD}, + {"document", DOCUMENT_P, UNRESERVED_KEYWORD}, + {"domain", DOMAIN_P, UNRESERVED_KEYWORD}, + {"double", DOUBLE_P, UNRESERVED_KEYWORD}, + {"drop", DROP, UNRESERVED_KEYWORD}, + {"each", EACH, UNRESERVED_KEYWORD}, + {"else", ELSE, RESERVED_KEYWORD}, + {"enable", ENABLE_P, UNRESERVED_KEYWORD}, + {"encoding", ENCODING, UNRESERVED_KEYWORD}, + {"encrypted", ENCRYPTED, UNRESERVED_KEYWORD}, + {"end", END_P, RESERVED_KEYWORD}, + {"enum", ENUM_P, UNRESERVED_KEYWORD}, + {"escape", ESCAPE, UNRESERVED_KEYWORD}, + {"except", EXCEPT, RESERVED_KEYWORD}, + {"excluding", EXCLUDING, UNRESERVED_KEYWORD}, + {"exclusive", EXCLUSIVE, UNRESERVED_KEYWORD}, + {"execute", EXECUTE, UNRESERVED_KEYWORD}, + {"exists", EXISTS, COL_NAME_KEYWORD}, + {"explain", EXPLAIN, UNRESERVED_KEYWORD}, + {"external", EXTERNAL, UNRESERVED_KEYWORD}, + {"extract", EXTRACT, COL_NAME_KEYWORD}, + {"false", FALSE_P, RESERVED_KEYWORD}, + {"family", FAMILY, UNRESERVED_KEYWORD}, + {"fetch", FETCH, UNRESERVED_KEYWORD}, + {"first", FIRST_P, UNRESERVED_KEYWORD}, + {"float", FLOAT_P, COL_NAME_KEYWORD}, + {"for", FOR, RESERVED_KEYWORD}, + {"force", FORCE, UNRESERVED_KEYWORD}, + {"foreign", FOREIGN, RESERVED_KEYWORD}, + {"forward", FORWARD, UNRESERVED_KEYWORD}, + {"freeze", FREEZE, TYPE_FUNC_NAME_KEYWORD}, + {"from", FROM, RESERVED_KEYWORD}, + {"full", FULL, TYPE_FUNC_NAME_KEYWORD}, + {"function", FUNCTION, UNRESERVED_KEYWORD}, + {"global", GLOBAL, UNRESERVED_KEYWORD}, + {"grant", GRANT, RESERVED_KEYWORD}, + {"granted", GRANTED, UNRESERVED_KEYWORD}, + {"greatest", GREATEST, COL_NAME_KEYWORD}, + {"group", GROUP_P, RESERVED_KEYWORD}, + {"handler", HANDLER, UNRESERVED_KEYWORD}, + {"having", HAVING, RESERVED_KEYWORD}, + {"header", HEADER_P, UNRESERVED_KEYWORD}, + {"hold", HOLD, UNRESERVED_KEYWORD}, + {"hour", HOUR_P, UNRESERVED_KEYWORD}, + {"if", IF_P, UNRESERVED_KEYWORD}, + {"ilike", ILIKE, TYPE_FUNC_NAME_KEYWORD}, + {"immediate", IMMEDIATE, UNRESERVED_KEYWORD}, + {"immutable", IMMUTABLE, UNRESERVED_KEYWORD}, + {"implicit", IMPLICIT_P, UNRESERVED_KEYWORD}, + {"in", IN_P, RESERVED_KEYWORD}, + {"including", INCLUDING, UNRESERVED_KEYWORD}, + {"increment", INCREMENT, UNRESERVED_KEYWORD}, + {"index", INDEX, UNRESERVED_KEYWORD}, + {"indexes", INDEXES, UNRESERVED_KEYWORD}, + {"inherit", INHERIT, UNRESERVED_KEYWORD}, + {"inherits", INHERITS, UNRESERVED_KEYWORD}, + {"initially", INITIALLY, RESERVED_KEYWORD}, + {"inner", INNER_P, TYPE_FUNC_NAME_KEYWORD}, + {"inout", INOUT, COL_NAME_KEYWORD}, + {"input", INPUT_P, UNRESERVED_KEYWORD}, + {"insensitive", INSENSITIVE, UNRESERVED_KEYWORD}, + {"insert", INSERT, UNRESERVED_KEYWORD}, + {"instead", INSTEAD, UNRESERVED_KEYWORD}, + {"int", INT_P, COL_NAME_KEYWORD}, + {"integer", INTEGER, COL_NAME_KEYWORD}, + {"intersect", INTERSECT, RESERVED_KEYWORD}, + {"interval", INTERVAL, COL_NAME_KEYWORD}, + {"into", INTO, RESERVED_KEYWORD}, + {"invoker", INVOKER, UNRESERVED_KEYWORD}, + {"is", IS, TYPE_FUNC_NAME_KEYWORD}, + {"isnull", ISNULL, TYPE_FUNC_NAME_KEYWORD}, + {"isolation", ISOLATION, UNRESERVED_KEYWORD}, + {"join", JOIN, TYPE_FUNC_NAME_KEYWORD}, + {"key", KEY, UNRESERVED_KEYWORD}, + {"lancompiler", LANCOMPILER, UNRESERVED_KEYWORD}, + {"language", LANGUAGE, UNRESERVED_KEYWORD}, + {"large", LARGE_P, UNRESERVED_KEYWORD}, + {"last", LAST_P, UNRESERVED_KEYWORD}, + {"leading", LEADING, RESERVED_KEYWORD}, + {"least", LEAST, COL_NAME_KEYWORD}, + {"left", LEFT, TYPE_FUNC_NAME_KEYWORD}, + {"level", LEVEL, UNRESERVED_KEYWORD}, + {"like", LIKE, TYPE_FUNC_NAME_KEYWORD}, + {"limit", LIMIT, RESERVED_KEYWORD}, + {"listen", LISTEN, UNRESERVED_KEYWORD}, + {"load", LOAD, UNRESERVED_KEYWORD}, + {"local", LOCAL, UNRESERVED_KEYWORD}, + {"localtime", LOCALTIME, RESERVED_KEYWORD}, + {"localtimestamp", LOCALTIMESTAMP, RESERVED_KEYWORD}, + {"location", LOCATION, UNRESERVED_KEYWORD}, + {"lock", LOCK_P, UNRESERVED_KEYWORD}, + {"login", LOGIN_P, UNRESERVED_KEYWORD}, + {"mapping", MAPPING, UNRESERVED_KEYWORD}, + {"match", MATCH, UNRESERVED_KEYWORD}, + {"maxvalue", MAXVALUE, UNRESERVED_KEYWORD}, + {"minute", MINUTE_P, UNRESERVED_KEYWORD}, + {"minvalue", MINVALUE, UNRESERVED_KEYWORD}, + {"mode", MODE, UNRESERVED_KEYWORD}, + {"month", MONTH_P, UNRESERVED_KEYWORD}, + {"move", MOVE, UNRESERVED_KEYWORD}, + {"name", NAME_P, UNRESERVED_KEYWORD}, + {"names", NAMES, UNRESERVED_KEYWORD}, + {"national", NATIONAL, COL_NAME_KEYWORD}, + {"natural", NATURAL, TYPE_FUNC_NAME_KEYWORD}, + {"nchar", NCHAR, COL_NAME_KEYWORD}, + {"new", NEW, RESERVED_KEYWORD}, + {"next", NEXT, UNRESERVED_KEYWORD}, + {"no", NO, UNRESERVED_KEYWORD}, + {"nocreatedb", NOCREATEDB, UNRESERVED_KEYWORD}, + {"nocreaterole", NOCREATEROLE, UNRESERVED_KEYWORD}, + {"nocreateuser", NOCREATEUSER, UNRESERVED_KEYWORD}, + {"noinherit", NOINHERIT, UNRESERVED_KEYWORD}, + {"nologin", NOLOGIN_P, UNRESERVED_KEYWORD}, + {"none", NONE, COL_NAME_KEYWORD}, + {"nosuperuser", NOSUPERUSER, UNRESERVED_KEYWORD}, + {"not", NOT, RESERVED_KEYWORD}, + {"nothing", NOTHING, UNRESERVED_KEYWORD}, + {"notify", NOTIFY, UNRESERVED_KEYWORD}, + {"notnull", NOTNULL, TYPE_FUNC_NAME_KEYWORD}, + {"nowait", NOWAIT, UNRESERVED_KEYWORD}, + {"null", NULL_P, RESERVED_KEYWORD}, + {"nullif", NULLIF, COL_NAME_KEYWORD}, + {"nulls", NULLS_P, UNRESERVED_KEYWORD}, + {"numeric", NUMERIC, COL_NAME_KEYWORD}, + {"object", OBJECT_P, UNRESERVED_KEYWORD}, + {"of", OF, UNRESERVED_KEYWORD}, + {"off", OFF, RESERVED_KEYWORD}, + {"offset", OFFSET, RESERVED_KEYWORD}, + {"oids", OIDS, UNRESERVED_KEYWORD}, + {"old", OLD, RESERVED_KEYWORD}, + {"on", ON, RESERVED_KEYWORD}, + {"only", ONLY, RESERVED_KEYWORD}, + {"operator", OPERATOR, UNRESERVED_KEYWORD}, + {"option", OPTION, UNRESERVED_KEYWORD}, + {"or", OR, RESERVED_KEYWORD}, + {"order", ORDER, RESERVED_KEYWORD}, + {"out", OUT_P, COL_NAME_KEYWORD}, + {"outer", OUTER_P, TYPE_FUNC_NAME_KEYWORD}, + {"overlaps", OVERLAPS, TYPE_FUNC_NAME_KEYWORD}, + {"overlay", OVERLAY, COL_NAME_KEYWORD}, + {"owned", OWNED, UNRESERVED_KEYWORD}, + {"owner", OWNER, UNRESERVED_KEYWORD}, + {"parser", PARSER, UNRESERVED_KEYWORD}, + {"partial", PARTIAL, UNRESERVED_KEYWORD}, + {"password", PASSWORD, UNRESERVED_KEYWORD}, + {"placing", PLACING, RESERVED_KEYWORD}, + {"plans", PLANS, UNRESERVED_KEYWORD}, + {"position", POSITION, COL_NAME_KEYWORD}, + {"precision", PRECISION, COL_NAME_KEYWORD}, + {"prepare", PREPARE, UNRESERVED_KEYWORD}, + {"prepared", PREPARED, UNRESERVED_KEYWORD}, + {"preserve", PRESERVE, UNRESERVED_KEYWORD}, + {"primary", PRIMARY, RESERVED_KEYWORD}, + {"prior", PRIOR, UNRESERVED_KEYWORD}, + {"privileges", PRIVILEGES, UNRESERVED_KEYWORD}, + {"procedural", PROCEDURAL, UNRESERVED_KEYWORD}, + {"procedure", PROCEDURE, UNRESERVED_KEYWORD}, + {"quote", QUOTE, UNRESERVED_KEYWORD}, + {"read", READ, UNRESERVED_KEYWORD}, + {"real", REAL, COL_NAME_KEYWORD}, + {"reassign", REASSIGN, UNRESERVED_KEYWORD}, + {"recheck", RECHECK, UNRESERVED_KEYWORD}, + {"references", REFERENCES, RESERVED_KEYWORD}, + {"reindex", REINDEX, UNRESERVED_KEYWORD}, + {"relative", RELATIVE_P, UNRESERVED_KEYWORD}, + {"release", RELEASE, UNRESERVED_KEYWORD}, + {"rename", RENAME, UNRESERVED_KEYWORD}, + {"repeatable", REPEATABLE, UNRESERVED_KEYWORD}, + {"replace", REPLACE, UNRESERVED_KEYWORD}, + {"replica", REPLICA, UNRESERVED_KEYWORD}, + {"reset", RESET, UNRESERVED_KEYWORD}, + {"restart", RESTART, UNRESERVED_KEYWORD}, + {"restrict", RESTRICT, UNRESERVED_KEYWORD}, + {"returning", RETURNING, RESERVED_KEYWORD}, + {"returns", RETURNS, UNRESERVED_KEYWORD}, + {"revoke", REVOKE, UNRESERVED_KEYWORD}, + {"right", RIGHT, TYPE_FUNC_NAME_KEYWORD}, + {"role", ROLE, UNRESERVED_KEYWORD}, + {"rollback", ROLLBACK, UNRESERVED_KEYWORD}, + {"row", ROW, COL_NAME_KEYWORD}, + {"rows", ROWS, UNRESERVED_KEYWORD}, + {"rule", RULE, UNRESERVED_KEYWORD}, + {"savepoint", SAVEPOINT, UNRESERVED_KEYWORD}, + {"schema", SCHEMA, UNRESERVED_KEYWORD}, + {"scroll", SCROLL, UNRESERVED_KEYWORD}, + {"search", SEARCH, UNRESERVED_KEYWORD}, + {"second", SECOND_P, UNRESERVED_KEYWORD}, + {"security", SECURITY, UNRESERVED_KEYWORD}, + {"select", SELECT, RESERVED_KEYWORD}, + {"sequence", SEQUENCE, UNRESERVED_KEYWORD}, + {"serializable", SERIALIZABLE, UNRESERVED_KEYWORD}, + {"session", SESSION, UNRESERVED_KEYWORD}, + {"session_user", SESSION_USER, RESERVED_KEYWORD}, + {"set", SET, UNRESERVED_KEYWORD}, + {"setof", SETOF, COL_NAME_KEYWORD}, + {"share", SHARE, UNRESERVED_KEYWORD}, + {"show", SHOW, UNRESERVED_KEYWORD}, + {"similar", SIMILAR, TYPE_FUNC_NAME_KEYWORD}, + {"simple", SIMPLE, UNRESERVED_KEYWORD}, + {"smallint", SMALLINT, COL_NAME_KEYWORD}, + {"some", SOME, RESERVED_KEYWORD}, + {"stable", STABLE, UNRESERVED_KEYWORD}, + {"standalone", STANDALONE_P, UNRESERVED_KEYWORD}, + {"start", START, UNRESERVED_KEYWORD}, + {"statement", STATEMENT, UNRESERVED_KEYWORD}, + {"statistics", STATISTICS, UNRESERVED_KEYWORD}, + {"stdin", STDIN, UNRESERVED_KEYWORD}, + {"stdout", STDOUT, UNRESERVED_KEYWORD}, + {"storage", STORAGE, UNRESERVED_KEYWORD}, + {"strict", STRICT_P, UNRESERVED_KEYWORD}, + {"strip", STRIP_P, UNRESERVED_KEYWORD}, + {"substring", SUBSTRING, COL_NAME_KEYWORD}, + {"superuser", SUPERUSER_P, UNRESERVED_KEYWORD}, + {"symmetric", SYMMETRIC, RESERVED_KEYWORD}, + {"sysid", SYSID, UNRESERVED_KEYWORD}, + {"system", SYSTEM_P, UNRESERVED_KEYWORD}, + {"table", TABLE, RESERVED_KEYWORD}, + {"tablespace", TABLESPACE, UNRESERVED_KEYWORD}, + {"temp", TEMP, UNRESERVED_KEYWORD}, + {"template", TEMPLATE, UNRESERVED_KEYWORD}, + {"temporary", TEMPORARY, UNRESERVED_KEYWORD}, + {"text", TEXT_P, UNRESERVED_KEYWORD}, + {"then", THEN, RESERVED_KEYWORD}, + {"time", TIME, COL_NAME_KEYWORD}, + {"timestamp", TIMESTAMP, COL_NAME_KEYWORD}, + {"to", TO, RESERVED_KEYWORD}, + {"trailing", TRAILING, RESERVED_KEYWORD}, + {"transaction", TRANSACTION, UNRESERVED_KEYWORD}, + {"treat", TREAT, COL_NAME_KEYWORD}, + {"trigger", TRIGGER, UNRESERVED_KEYWORD}, + {"trim", TRIM, COL_NAME_KEYWORD}, + {"true", TRUE_P, RESERVED_KEYWORD}, + {"truncate", TRUNCATE, UNRESERVED_KEYWORD}, + {"trusted", TRUSTED, UNRESERVED_KEYWORD}, + {"type", TYPE_P, UNRESERVED_KEYWORD}, + {"uncommitted", UNCOMMITTED, UNRESERVED_KEYWORD}, + {"unencrypted", UNENCRYPTED, UNRESERVED_KEYWORD}, + {"union", UNION, RESERVED_KEYWORD}, + {"unique", UNIQUE, RESERVED_KEYWORD}, + {"unknown", UNKNOWN, UNRESERVED_KEYWORD}, + {"unlisten", UNLISTEN, UNRESERVED_KEYWORD}, + {"until", UNTIL, UNRESERVED_KEYWORD}, + {"update", UPDATE, UNRESERVED_KEYWORD}, + {"user", USER, RESERVED_KEYWORD}, + {"using", USING, RESERVED_KEYWORD}, + {"vacuum", VACUUM, UNRESERVED_KEYWORD}, + {"valid", VALID, UNRESERVED_KEYWORD}, + {"validator", VALIDATOR, UNRESERVED_KEYWORD}, + {"value", VALUE_P, UNRESERVED_KEYWORD}, + {"values", VALUES, COL_NAME_KEYWORD}, + {"varchar", VARCHAR, COL_NAME_KEYWORD}, + {"varying", VARYING, UNRESERVED_KEYWORD}, + {"verbose", VERBOSE, TYPE_FUNC_NAME_KEYWORD}, + {"version", VERSION_P, UNRESERVED_KEYWORD}, + {"view", VIEW, UNRESERVED_KEYWORD}, + {"volatile", VOLATILE, UNRESERVED_KEYWORD}, + {"when", WHEN, RESERVED_KEYWORD}, + {"where", WHERE, RESERVED_KEYWORD}, + {"whitespace", WHITESPACE_P, UNRESERVED_KEYWORD}, + /* + * XXX we mark WITH as reserved to force it to be quoted in dumps, even + * though it is currently unreserved according to gram.y. This is because + * we expect we'll have to make it reserved to implement SQL WITH clauses. + * If that patch manages to do without reserving WITH, adjust this entry + * at that time; in any case this should be back in sync with gram.y + * after WITH clauses are implemented. + */ + {"with", WITH, RESERVED_KEYWORD}, + {"without", WITHOUT, UNRESERVED_KEYWORD}, + {"work", WORK, UNRESERVED_KEYWORD}, + {"write", WRITE, UNRESERVED_KEYWORD}, + {"xml", XML_P, UNRESERVED_KEYWORD}, + {"xmlattributes", XMLATTRIBUTES, COL_NAME_KEYWORD}, + {"xmlconcat", XMLCONCAT, COL_NAME_KEYWORD}, + {"xmlelement", XMLELEMENT, COL_NAME_KEYWORD}, + {"xmlforest", XMLFOREST, COL_NAME_KEYWORD}, + {"xmlparse", XMLPARSE, COL_NAME_KEYWORD}, + {"xmlpi", XMLPI, COL_NAME_KEYWORD}, + {"xmlroot", XMLROOT, COL_NAME_KEYWORD}, + {"xmlserialize", XMLSERIALIZE, COL_NAME_KEYWORD}, + {"year", YEAR_P, UNRESERVED_KEYWORD}, + {"yes", YES_P, UNRESERVED_KEYWORD}, + {"zone", ZONE, UNRESERVED_KEYWORD}, +}; + +/* + * ScanKeywordLookup - see if a given word is a keyword + * + * Returns a pointer to the ScanKeyword table entry, or NULL if no match. + * + * The match is done case-insensitively. Note that we deliberately use a + * dumbed-down case conversion that will only translate 'A'-'Z' into 'a'-'z', + * even if we are in a locale where tolower() would produce more or different + * translations. This is to conform to the SQL99 spec, which says that + * keywords are to be matched in this way even though non-keyword identifiers + * receive a different case-normalization mapping. + */ +const ScanKeyword * +ScanKeywordLookup(const char *text) +{ + int len, + i; + char word[NAMEDATALEN]; + const ScanKeyword *low; + const ScanKeyword *high; + + len = strlen(text); + /* We assume all keywords are shorter than NAMEDATALEN. */ + if (len >= NAMEDATALEN) + return NULL; + + /* + * Apply an ASCII-only downcasing. We must not use tolower() since it may + * produce the wrong translation in some locales (eg, Turkish). + */ + for (i = 0; i < len; i++) + { + char ch = text[i]; + + if (ch >= 'A' && ch <= 'Z') + ch += 'a' - 'A'; + word[i] = ch; + } + word[len] = '\0'; + + /* + * Now do a binary search using plain strcmp() comparison. + */ + low = &ScanKeywords[0]; + high = endof(ScanKeywords) - 1; + while (low <= high) + { + const ScanKeyword *middle; + int difference; + + middle = low + (high - low) / 2; + difference = strcmp(middle->name, word); + if (difference == 0) + return middle; + else if (difference < 0) + low = middle + 1; + else + high = middle - 1; + } + + return NULL; +} diff --git a/parser/keywords.h b/parser/keywords.h new file mode 100644 index 0000000..b7e2e1c --- /dev/null +++ b/parser/keywords.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * + * keywords.h + * lexical token lookup for reserved words in postgres SQL + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/parser/keywords.h,v 1.20 2004/12/31 22:03:38 pgsql Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef KEYWORDS_H +#define KEYWORDS_H + +/* Keyword categories --- should match lists in gram.y */ +#define UNRESERVED_KEYWORD 0 +#define COL_NAME_KEYWORD 1 +#define TYPE_FUNC_NAME_KEYWORD 2 +#define RESERVED_KEYWORD 3 + + +typedef struct ScanKeyword +{ + const char *name; /* in lower case */ + short value; /* grammar's token code */ + short category; /* see codes above */ +} ScanKeyword; + +extern const ScanKeyword *ScanKeywordLookup(const char *text); + +#endif /* KEYWORDS_H */ diff --git a/parser/list.c b/parser/list.c new file mode 100644 index 0000000..7eca543 --- /dev/null +++ b/parser/list.c @@ -0,0 +1,1158 @@ +/*------------------------------------------------------------------------- + * + * list.c + * implementation for PostgreSQL generic linked list package + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.66 2005/10/15 02:49:18 momjian Exp $ + * + *------------------------------------------------------------------------- + */ +/*#include "postgres.h"*/ + +#include +#include "pool_memory.h" +#include "pg_list.h" + +#define ereport(a,b) +#define elog(a,b) + + +/* + * Routines to simplify writing assertions about the type of a list; a + * NIL list is considered to be an empty list of any type. + */ +#define IsPointerList(l) ((l) == NIL || IsA((l), List)) +#define IsIntegerList(l) ((l) == NIL || IsA((l), IntList)) +#define IsOidList(l) ((l) == NIL || IsA((l), OidList)) + +#define check_list_invariants(l) + +/* + * Return a freshly allocated List. Since empty non-NIL lists are + * invalid, new_list() also allocates the head cell of the new list: + * the caller should be sure to fill in that cell's data. + */ +static List * +new_list(NodeTag type) +{ + List *new_list; + ListCell *new_head; + + new_head = (ListCell *) palloc(sizeof(*new_head)); + new_head->next = NULL; + /* new_head->data is left undefined! */ + + new_list = (List *) palloc(sizeof(*new_list)); + new_list->type = type; + new_list->length = 1; + new_list->head = new_head; + new_list->tail = new_head; + + return new_list; +} + +/* + * Allocate a new cell and make it the head of the specified + * list. Assumes the list it is passed is non-NIL. + * + * The data in the new head cell is undefined; the caller should be + * sure to fill it in + */ +static void +new_head_cell(List *list) +{ + ListCell *new_head; + + new_head = (ListCell *) palloc(sizeof(*new_head)); + new_head->next = list->head; + + list->head = new_head; + list->length++; +} + +/* + * Allocate a new cell and make it the tail of the specified + * list. Assumes the list it is passed is non-NIL. + * + * The data in the new tail cell is undefined; the caller should be + * sure to fill it in + */ +static void +new_tail_cell(List *list) +{ + ListCell *new_tail; + + new_tail = (ListCell *) palloc(sizeof(*new_tail)); + new_tail->next = NULL; + + list->tail->next = new_tail; + list->tail = new_tail; + list->length++; +} + +/* + * Append a pointer to the list. A pointer to the modified list is + * returned. Note that this function may or may not destructively + * modify the list; callers should always use this function's return + * value, rather than continuing to use the pointer passed as the + * first argument. + */ +List * +lappend(List *list, void *datum) +{ + if (list == NIL) + list = new_list(T_List); + else + new_tail_cell(list); + + lfirst(list->tail) = datum; + check_list_invariants(list); + return list; +} + +/* + * Append an integer to the specified list. See lappend() + */ +List * +lappend_int(List *list, int datum) +{ + if (list == NIL) + list = new_list(T_IntList); + else + new_tail_cell(list); + + lfirst_int(list->tail) = datum; + check_list_invariants(list); + return list; +} + +/* + * Append an OID to the specified list. See lappend() + */ +List * +lappend_oid(List *list, Oid datum) +{ + if (list == NIL) + list = new_list(T_OidList); + else + new_tail_cell(list); + + lfirst_oid(list->tail) = datum; + check_list_invariants(list); + return list; +} + +/* + * Add a new cell to the list, in the position after 'prev_cell'. The + * data in the cell is left undefined, and must be filled in by the + * caller. 'list' is assumed to be non-NIL, and 'prev_cell' is assumed + * to be non-NULL and a member of 'list'. + */ +static ListCell * +add_new_cell(List *list, ListCell *prev_cell) +{ + ListCell *new_cell; + + new_cell = (ListCell *) palloc(sizeof(*new_cell)); + /* new_cell->data is left undefined! */ + new_cell->next = prev_cell->next; + prev_cell->next = new_cell; + + if (list->tail == prev_cell) + list->tail = new_cell; + + list->length++; + + return new_cell; +} + +/* + * Add a new cell to the specified list (which must be non-NIL); + * it will be placed after the list cell 'prev' (which must be + * non-NULL and a member of 'list'). The data placed in the new cell + * is 'datum'. The newly-constructed cell is returned. + */ +ListCell * +lappend_cell(List *list, ListCell *prev, void *datum) +{ + ListCell *new_cell; + + new_cell = add_new_cell(list, prev); + lfirst(new_cell) = datum; + check_list_invariants(list); + return new_cell; +} + +ListCell * +lappend_cell_int(List *list, ListCell *prev, int datum) +{ + ListCell *new_cell; + + new_cell = add_new_cell(list, prev); + lfirst_int(new_cell) = datum; + check_list_invariants(list); + return new_cell; +} + +ListCell * +lappend_cell_oid(List *list, ListCell *prev, Oid datum) +{ + ListCell *new_cell; + + new_cell = add_new_cell(list, prev); + lfirst_oid(new_cell) = datum; + check_list_invariants(list); + return new_cell; +} + +/* + * Prepend a new element to the list. A pointer to the modified list + * is returned. Note that this function may or may not destructively + * modify the list; callers should always use this function's return + * value, rather than continuing to use the pointer passed as the + * second argument. + * + * Caution: before Postgres 8.0, the original List was unmodified and + * could be considered to retain its separate identity. This is no longer + * the case. + */ +List * +lcons(void *datum, List *list) +{ + if (list == NIL) + list = new_list(T_List); + else + new_head_cell(list); + + lfirst(list->head) = datum; + check_list_invariants(list); + return list; +} + +/* + * Prepend an integer to the list. See lcons() + */ +List * +lcons_int(int datum, List *list) +{ + if (list == NIL) + list = new_list(T_IntList); + else + new_head_cell(list); + + lfirst_int(list->head) = datum; + check_list_invariants(list); + return list; +} + +/* + * Prepend an OID to the list. See lcons() + */ +List * +lcons_oid(Oid datum, List *list) +{ + if (list == NIL) + list = new_list(T_OidList); + else + new_head_cell(list); + + lfirst_oid(list->head) = datum; + check_list_invariants(list); + return list; +} + +/* + * Concatenate list2 to the end of list1, and return list1. list1 is + * destructively changed. Callers should be sure to use the return + * value as the new pointer to the concatenated list: the 'list1' + * input pointer may or may not be the same as the returned pointer. + * + * The nodes in list2 are merely appended to the end of list1 in-place + * (i.e. they aren't copied; the two lists will share some of the same + * storage). Therefore, invoking list_free() on list2 will also + * invalidate a portion of list1. + */ +List * +list_concat(List *list1, List *list2) +{ + if (list1 == NIL) + return list2; + if (list2 == NIL) + return list1; + if (list1 == list2) + elog(ERROR, "cannot list_concat() a list to itself"); + + list1->length += list2->length; + list1->tail->next = list2->head; + list1->tail = list2->tail; + + check_list_invariants(list1); + return list1; +} + +/* + * Truncate 'list' to contain no more than 'new_size' elements. This + * modifies the list in-place! Despite this, callers should use the + * pointer returned by this function to refer to the newly truncated + * list -- it may or may not be the same as the pointer that was + * passed. + * + * Note that any cells removed by list_truncate() are NOT pfree'd. + */ +List * +list_truncate(List *list, int new_size) +{ + ListCell *cell; + int n; + + if (new_size <= 0) + return NIL; /* truncate to zero length */ + + /* If asked to effectively extend the list, do nothing */ + if (new_size >= list_length(list)) + return list; + + n = 1; + foreach(cell, list) + { + if (n == new_size) + { + cell->next = NULL; + list->tail = cell; + list->length = new_size; + check_list_invariants(list); + return list; + } + n++; + } + + /* keep the compiler quiet; never reached */ + return list; +} + +/* + * Locate the n'th cell (counting from 0) of the list. It is an assertion + * failure if there is no such cell. + */ +static ListCell * +list_nth_cell(List *list, int n) +{ + ListCell *match; + + check_list_invariants(list); + + /* Does the caller actually mean to fetch the tail? */ + if (n == list->length - 1) + return list->tail; + + for (match = list->head; n-- > 0; match = match->next) + ; + + return match; +} + +/* + * Return the data value contained in the n'th element of the + * specified list. (List elements begin at 0.) + */ +void * +list_nth(List *list, int n) +{ + return lfirst(list_nth_cell(list, n)); +} + +/* + * Return the integer value contained in the n'th element of the + * specified list. + */ +int +list_nth_int(List *list, int n) +{ + return lfirst_int(list_nth_cell(list, n)); +} + +/* + * Return the OID value contained in the n'th element of the specified + * list. + */ +Oid +list_nth_oid(List *list, int n) +{ + return lfirst_oid(list_nth_cell(list, n)); +} + +#if 0 +/* + * Return true iff 'datum' is a member of the list. Equality is + * determined via equal(), so callers should ensure that they pass a + * Node as 'datum'. + */ +bool +list_member(List *list, void *datum) +{ + ListCell *cell; + + check_list_invariants(list); + + foreach(cell, list) + { + if (equal(lfirst(cell), datum)) + return true; + } + + return false; +} +#endif + +/* + * Return true iff 'datum' is a member of the list. Equality is + * determined by using simple pointer comparison. + */ +bool +list_member_ptr(List *list, void *datum) +{ + ListCell *cell; + + check_list_invariants(list); + + foreach(cell, list) + { + if (lfirst(cell) == datum) + return true; + } + + return false; +} + +/* + * Return true iff the integer 'datum' is a member of the list. + */ +bool +list_member_int(List *list, int datum) +{ + ListCell *cell; + + check_list_invariants(list); + + foreach(cell, list) + { + if (lfirst_int(cell) == datum) + return true; + } + + return false; +} + +/* + * Return true iff the OID 'datum' is a member of the list. + */ +bool +list_member_oid(List *list, Oid datum) +{ + ListCell *cell; + + check_list_invariants(list); + + foreach(cell, list) + { + if (lfirst_oid(cell) == datum) + return true; + } + + return false; +} + +/* + * Delete 'cell' from 'list'; 'prev' is the previous element to 'cell' + * in 'list', if any (i.e. prev == NULL iff list->head == cell) + * + * The cell is pfree'd, as is the List header if this was the last member. + */ +List * +list_delete_cell(List *list, ListCell *cell, ListCell *prev) +{ + check_list_invariants(list); + + /* + * If we're about to delete the last node from the list, free the whole + * list instead and return NIL, which is the only valid representation of + * a zero-length list. + */ + if (list->length == 1) + { + list_free(list); + return NIL; + } + + /* + * Otherwise, adjust the necessary list links, deallocate the particular + * node we have just removed, and return the list we were given. + */ + list->length--; + + if (prev) + prev->next = cell->next; + else + list->head = cell->next; + + if (list->tail == cell) + list->tail = prev; + + pfree(cell); + return list; +} + +#if 0 +/* + * Delete the first cell in list that matches datum, if any. + * Equality is determined via equal(). + */ +List * +list_delete(List *list, void *datum) +{ + ListCell *cell; + ListCell *prev; + + check_list_invariants(list); + + prev = NULL; + foreach(cell, list) + { + if (equal(lfirst(cell), datum)) + return list_delete_cell(list, cell, prev); + + prev = cell; + } + + /* Didn't find a match: return the list unmodified */ + return list; +} +#endif + +/* As above, but use simple pointer equality */ +List * +list_delete_ptr(List *list, void *datum) +{ + ListCell *cell; + ListCell *prev; + + check_list_invariants(list); + + prev = NULL; + foreach(cell, list) + { + if (lfirst(cell) == datum) + return list_delete_cell(list, cell, prev); + + prev = cell; + } + + /* Didn't find a match: return the list unmodified */ + return list; +} + +/* As above, but for integers */ +List * +list_delete_int(List *list, int datum) +{ + ListCell *cell; + ListCell *prev; + + check_list_invariants(list); + + prev = NULL; + foreach(cell, list) + { + if (lfirst_int(cell) == datum) + return list_delete_cell(list, cell, prev); + + prev = cell; + } + + /* Didn't find a match: return the list unmodified */ + return list; +} + +/* As above, but for OIDs */ +List * +list_delete_oid(List *list, Oid datum) +{ + ListCell *cell; + ListCell *prev; + + check_list_invariants(list); + + prev = NULL; + foreach(cell, list) + { + if (lfirst_oid(cell) == datum) + return list_delete_cell(list, cell, prev); + + prev = cell; + } + + /* Didn't find a match: return the list unmodified */ + return list; +} + +/* + * Delete the first element of the list. + * + * This is useful to replace the Lisp-y code "list = lnext(list);" in cases + * where the intent is to alter the list rather than just traverse it. + * Beware that the removed cell is freed, whereas the lnext() coding leaves + * the original list head intact if there's another pointer to it. + */ +List * +list_delete_first(List *list) +{ + check_list_invariants(list); + + if (list == NIL) + return NIL; /* would an error be better? */ + + return list_delete_cell(list, list_head(list), NULL); +} + +#if 0 +/* + * Generate the union of two lists. This is calculated by copying + * list1 via list_copy(), then adding to it all the members of list2 + * that aren't already in list1. + * + * Whether an element is already a member of the list is determined + * via equal(). + * + * The returned list is newly-allocated, although the content of the + * cells is the same (i.e. any pointed-to objects are not copied). + * + * NB: this function will NOT remove any duplicates that are present + * in list1 (so it only performs a "union" if list1 is known unique to + * start with). Also, if you are about to write "x = list_union(x, y)" + * you probably want to use list_concat_unique() instead to avoid wasting + * the list cells of the old x list. + * + * This function could probably be implemented a lot faster if it is a + * performance bottleneck. + */ +List * +list_union(List *list1, List *list2) +{ + List *result; + ListCell *cell; + + result = list_copy(list1); + foreach(cell, list2) + { + if (!list_member(result, lfirst(cell))) + result = lappend(result, lfirst(cell)); + } + + check_list_invariants(result); + return result; +} +#endif + +/* + * This variant of list_union() determines duplicates via simple + * pointer comparison. + */ +List * +list_union_ptr(List *list1, List *list2) +{ + List *result; + ListCell *cell; + + result = list_copy(list1); + foreach(cell, list2) + { + if (!list_member_ptr(result, lfirst(cell))) + result = lappend(result, lfirst(cell)); + } + + check_list_invariants(result); + return result; +} + +/* + * This variant of list_union() operates upon lists of integers. + */ +List * +list_union_int(List *list1, List *list2) +{ + List *result; + ListCell *cell; + + result = list_copy(list1); + foreach(cell, list2) + { + if (!list_member_int(result, lfirst_int(cell))) + result = lappend_int(result, lfirst_int(cell)); + } + + check_list_invariants(result); + return result; +} + +/* + * This variant of list_union() operates upon lists of OIDs. + */ +List * +list_union_oid(List *list1, List *list2) +{ + List *result; + ListCell *cell; + + result = list_copy(list1); + foreach(cell, list2) + { + if (!list_member_oid(result, lfirst_oid(cell))) + result = lappend_oid(result, lfirst_oid(cell)); + } + + check_list_invariants(result); + return result; +} + +#if 0 +/* + * Return a list that contains all the cells in list1 that are not in + * list2. The returned list is freshly allocated via palloc(), but the + * cells themselves point to the same objects as the cells of the + * input lists. + * + * This variant works on lists of pointers, and determines list + * membership via equal() + */ +List * +list_difference(List *list1, List *list2) +{ + ListCell *cell; + List *result = NIL; + + if (list2 == NIL) + return list_copy(list1); + + foreach(cell, list1) + { + if (!list_member(list2, lfirst(cell))) + result = lappend(result, lfirst(cell)); + } + + check_list_invariants(result); + return result; +} +#endif + +/* + * This variant of list_difference() determines list membership via + * simple pointer equality. + */ +List * +list_difference_ptr(List *list1, List *list2) +{ + ListCell *cell; + List *result = NIL; + + if (list2 == NIL) + return list_copy(list1); + + foreach(cell, list1) + { + if (!list_member_ptr(list2, lfirst(cell))) + result = lappend(result, lfirst(cell)); + } + + check_list_invariants(result); + return result; +} + +/* + * This variant of list_difference() operates upon lists of integers. + */ +List * +list_difference_int(List *list1, List *list2) +{ + ListCell *cell; + List *result = NIL; + + if (list2 == NIL) + return list_copy(list1); + + foreach(cell, list1) + { + if (!list_member_int(list2, lfirst_int(cell))) + result = lappend_int(result, lfirst_int(cell)); + } + + check_list_invariants(result); + return result; +} + +/* + * This variant of list_difference() operates upon lists of OIDs. + */ +List * +list_difference_oid(List *list1, List *list2) +{ + ListCell *cell; + List *result = NIL; + + if (list2 == NIL) + return list_copy(list1); + + foreach(cell, list1) + { + if (!list_member_oid(list2, lfirst_oid(cell))) + result = lappend_oid(result, lfirst_oid(cell)); + } + + check_list_invariants(result); + return result; +} + +#if 0 +/* + * Append datum to list, but only if it isn't already in the list. + * + * Whether an element is already a member of the list is determined + * via equal(). + */ +List * +list_append_unique(List *list, void *datum) +{ + if (list_member(list, datum)) + return list; + else + return lappend(list, datum); +} +#endif + +/* + * This variant of list_append_unique() determines list membership via + * simple pointer equality. + */ +List * +list_append_unique_ptr(List *list, void *datum) +{ + if (list_member_ptr(list, datum)) + return list; + else + return lappend(list, datum); +} + +/* + * This variant of list_append_unique() operates upon lists of integers. + */ +List * +list_append_unique_int(List *list, int datum) +{ + if (list_member_int(list, datum)) + return list; + else + return lappend_int(list, datum); +} + +/* + * This variant of list_append_unique() operates upon lists of OIDs. + */ +List * +list_append_unique_oid(List *list, Oid datum) +{ + if (list_member_oid(list, datum)) + return list; + else + return lappend_oid(list, datum); +} + +#if 0 +/* + * Append to list1 each member of list2 that isn't already in list1. + * + * Whether an element is already a member of the list is determined + * via equal(). + * + * This is almost the same functionality as list_union(), but list1 is + * modified in-place rather than being copied. Note also that list2's cells + * are not inserted in list1, so the analogy to list_concat() isn't perfect. + */ +List * +list_concat_unique(List *list1, List *list2) +{ + ListCell *cell; + + foreach(cell, list2) + { + if (!list_member(list1, lfirst(cell))) + list1 = lappend(list1, lfirst(cell)); + } + + check_list_invariants(list1); + return list1; +} +#endif + +/* + * This variant of list_concat_unique() determines list membership via + * simple pointer equality. + */ +List * +list_concat_unique_ptr(List *list1, List *list2) +{ + ListCell *cell; + + foreach(cell, list2) + { + if (!list_member_ptr(list1, lfirst(cell))) + list1 = lappend(list1, lfirst(cell)); + } + + check_list_invariants(list1); + return list1; +} + +/* + * This variant of list_concat_unique() operates upon lists of integers. + */ +List * +list_concat_unique_int(List *list1, List *list2) +{ + ListCell *cell; + + foreach(cell, list2) + { + if (!list_member_int(list1, lfirst_int(cell))) + list1 = lappend_int(list1, lfirst_int(cell)); + } + + check_list_invariants(list1); + return list1; +} + +/* + * This variant of list_concat_unique() operates upon lists of OIDs. + */ +List * +list_concat_unique_oid(List *list1, List *list2) +{ + ListCell *cell; + + foreach(cell, list2) + { + if (!list_member_oid(list1, lfirst_oid(cell))) + list1 = lappend_oid(list1, lfirst_oid(cell)); + } + + check_list_invariants(list1); + return list1; +} + +/* + * Free all storage in a list, and optionally the pointed-to elements + */ +static void +list_free_private(List *list, bool deep) +{ + ListCell *cell; + + check_list_invariants(list); + + cell = list_head(list); + while (cell != NULL) + { + ListCell *tmp = cell; + + cell = lnext(cell); + if (deep) + pfree(lfirst(tmp)); + pfree(tmp); + } + + if (list) + pfree(list); +} + +/* + * Free all the cells of the list, as well as the list itself. Any + * objects that are pointed-to by the cells of the list are NOT + * free'd. + * + * On return, the argument to this function has been freed, so the + * caller would be wise to set it to NIL for safety's sake. + */ +void +list_free(List *list) +{ + list_free_private(list, false); +} + +/* + * Free all the cells of the list, the list itself, and all the + * objects pointed-to by the cells of the list (each element in the + * list must contain a pointer to a palloc()'d region of memory!) + * + * On return, the argument to this function has been freed, so the + * caller would be wise to set it to NIL for safety's sake. + */ +void +list_free_deep(List *list) +{ + /* + * A "deep" free operation only makes sense on a list of pointers. + */ + list_free_private(list, true); +} + +/* + * Return a shallow copy of the specified list. + */ +List * +list_copy(List *oldlist) +{ + List *newlist; + ListCell *newlist_prev; + ListCell *oldlist_cur; + + if (oldlist == NIL) + return NIL; + + newlist = new_list(oldlist->type); + newlist->length = oldlist->length; + + /* + * Copy over the data in the first cell; new_list() has already allocated + * the head cell itself + */ + newlist->head->data = oldlist->head->data; + + newlist_prev = newlist->head; + oldlist_cur = oldlist->head->next; + while (oldlist_cur) + { + ListCell *newlist_cur; + + newlist_cur = (ListCell *) palloc(sizeof(*newlist_cur)); + newlist_cur->data = oldlist_cur->data; + newlist_prev->next = newlist_cur; + + newlist_prev = newlist_cur; + oldlist_cur = oldlist_cur->next; + } + + newlist_prev->next = NULL; + newlist->tail = newlist_prev; + + check_list_invariants(newlist); + return newlist; +} + +/* + * Return a shallow copy of the specified list, without the first N elements. + */ +List * +list_copy_tail(List *oldlist, int nskip) +{ + List *newlist; + ListCell *newlist_prev; + ListCell *oldlist_cur; + + if (nskip < 0) + nskip = 0; /* would it be better to elog? */ + + if (oldlist == NIL || nskip >= oldlist->length) + return NIL; + + newlist = new_list(oldlist->type); + newlist->length = oldlist->length - nskip; + + /* + * Skip over the unwanted elements. + */ + oldlist_cur = oldlist->head; + while (nskip-- > 0) + oldlist_cur = oldlist_cur->next; + + /* + * Copy over the data in the first remaining cell; new_list() has already + * allocated the head cell itself + */ + newlist->head->data = oldlist_cur->data; + + newlist_prev = newlist->head; + oldlist_cur = oldlist_cur->next; + while (oldlist_cur) + { + ListCell *newlist_cur; + + newlist_cur = (ListCell *) palloc(sizeof(*newlist_cur)); + newlist_cur->data = oldlist_cur->data; + newlist_prev->next = newlist_cur; + + newlist_prev = newlist_cur; + oldlist_cur = oldlist_cur->next; + } + + newlist_prev->next = NULL; + newlist->tail = newlist_prev; + + check_list_invariants(newlist); + return newlist; +} + +/* + * When using non-GCC compilers, we can't define these as inline + * functions in pg_list.h, so they are defined here. + * + * TODO: investigate supporting inlining for some non-GCC compilers. + */ +#ifndef __GNUC__ + +ListCell * +list_head(List *l) +{ + return l ? l->head : NULL; +} + +ListCell * +list_tail(List *l) +{ + return l ? l->tail : NULL; +} + +int +list_length(List *l) +{ + return l ? l->length : 0; +} +#endif /* ! __GNUC__ */ + +/* + * Temporary compatibility functions + * + * In order to avoid warnings for these function definitions, we need + * to include a prototype here as well as in pg_list.h. That's because + * we don't enable list API compatibility in list.c, so we + * don't see the prototypes for these functions. + */ + +/* + * Given a list, return its length. This is merely defined for the + * sake of backward compatibility: we can't afford to define a macro + * called "length", so it must be a function. New code should use the + * list_length() macro in order to avoid the overhead of a function + * call. + */ +int length(List *list); + +int +length(List *list) +{ + return list_length(list); +} diff --git a/parser/makefuncs.c b/parser/makefuncs.c new file mode 100644 index 0000000..5840162 --- /dev/null +++ b/parser/makefuncs.c @@ -0,0 +1,365 @@ +/*------------------------------------------------------------------------- + * + * makefuncs.c + * creator functions for primitive nodes. The functions here are for + * the most frequently created nodes. + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.57 2007/09/06 17:31:58 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#include "pool_parser.h" + +#include "makefuncs.h" +#include "pool_memory.h" +#include +#include + +#define ereport(a,b) +#define elog(a,b) + +#define BOOLOID 16 + + +/* + * makeA_Expr - + * makes an A_Expr node + */ +A_Expr * +makeA_Expr(A_Expr_Kind kind, List *name, + Node *lexpr, Node *rexpr, int location) +{ + A_Expr *a = makeNode(A_Expr); + + a->kind = kind; + a->name = name; + a->lexpr = lexpr; + a->rexpr = rexpr; + a->location = location; + return a; +} + +/* + * makeSimpleA_Expr - + * As above, given a simple (unqualified) operator name + */ +A_Expr * +makeSimpleA_Expr(A_Expr_Kind kind, const char *name, + Node *lexpr, Node *rexpr, int location) +{ + A_Expr *a = makeNode(A_Expr); + + a->kind = kind; + a->name = list_make1(makeString((char *) name)); + a->lexpr = lexpr; + a->rexpr = rexpr; + a->location = location; + return a; +} + +/* + * makeVar - + * creates a Var node + */ +Var * +makeVar(Index varno, + AttrNumber varattno, + Oid vartype, + int32 vartypmod, + Index varlevelsup) +{ + Var *var = makeNode(Var); + + var->varno = varno; + var->varattno = varattno; + var->vartype = vartype; + var->vartypmod = vartypmod; + var->varlevelsup = varlevelsup; + + /* + * Since few if any routines ever create Var nodes with varnoold/varoattno + * different from varno/varattno, we don't provide separate arguments for + * them, but just initialize them to the given varno/varattno. This + * reduces code clutter and chance of error for most callers. + */ + var->varnoold = varno; + var->varoattno = varattno; + + return var; +} + +/* + * makeTargetEntry - + * creates a TargetEntry node + */ +TargetEntry * +makeTargetEntry(Expr *expr, + AttrNumber resno, + char *resname, + bool resjunk) +{ + TargetEntry *tle = makeNode(TargetEntry); + + tle->expr = expr; + tle->resno = resno; + tle->resname = resname; + + /* + * We always set these fields to 0. If the caller wants to change them he + * must do so explicitly. Few callers do that, so omitting these + * arguments reduces the chance of error. + */ + tle->ressortgroupref = 0; + tle->resorigtbl = InvalidOid; + tle->resorigcol = 0; + + tle->resjunk = resjunk; + + return tle; +} + +/* + * flatCopyTargetEntry - + * duplicate a TargetEntry, but don't copy substructure + * + * This is commonly used when we just want to modify the resno or substitute + * a new expression. + */ +TargetEntry * +flatCopyTargetEntry(TargetEntry *src_tle) +{ + TargetEntry *tle = makeNode(TargetEntry); + + memcpy(tle, src_tle, sizeof(TargetEntry)); + return tle; +} + +/* + * makeFromExpr - + * creates a FromExpr node + */ +FromExpr * +makeFromExpr(List *fromlist, Node *quals) +{ + FromExpr *f = makeNode(FromExpr); + + f->fromlist = fromlist; + f->quals = quals; + return f; +} + +/* + * makeConst - + * creates a Const node + */ +Const * +makeConst(Oid consttype, + int32 consttypmod, + int constlen, + Datum constvalue, + bool constisnull, + bool constbyval) +{ + Const *cnst = makeNode(Const); + + cnst->consttype = consttype; + cnst->consttypmod = consttypmod; + cnst->constlen = constlen; + cnst->constvalue = constvalue; + cnst->constisnull = constisnull; + cnst->constbyval = constbyval; + + return cnst; +} + +#if 0 +/* + * makeNullConst - + * creates a Const node representing a NULL of the specified type/typmod + * + * This is a convenience routine that just saves a lookup of the type's + * storage properties. + */ +Const * +makeNullConst(Oid consttype, int32 consttypmod) +{ + int16 typLen; + bool typByVal; + + get_typlenbyval(consttype, &typLen, &typByVal); + return makeConst(consttype, + consttypmod, + (int) typLen, + (Datum) 0, + true, + typByVal); +} +#endif + +#if 0 +/* + * makeBoolConst - + * creates a Const node representing a boolean value (can be NULL too) + */ +Node * +makeBoolConst(bool value, bool isnull) +{ + /* note that pg_type.h hardwires size of bool as 1 ... duplicate it */ + return (Node *) makeConst(BOOLOID, -1, 1, + BoolGetDatum(value), isnull, true); +} +#endif + +/* + * makeBoolExpr - + * creates a BoolExpr node + */ +Expr * +makeBoolExpr(BoolExprType boolop, List *args) +{ + BoolExpr *b = makeNode(BoolExpr); + + b->boolop = boolop; + b->args = args; + + return (Expr *) b; +} + +/* + * makeAlias - + * creates an Alias node + * + * NOTE: the given name is copied, but the colnames list (if any) isn't. + */ +Alias * +makeAlias(const char *aliasname, List *colnames) +{ + Alias *a = makeNode(Alias); + + a->aliasname = pstrdup(aliasname); + a->colnames = colnames; + + return a; +} + +/* + * makeRelabelType - + * creates a RelabelType node + */ +RelabelType * +makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, CoercionForm rformat) +{ + RelabelType *r = makeNode(RelabelType); + + r->arg = arg; + r->resulttype = rtype; + r->resulttypmod = rtypmod; + r->relabelformat = rformat; + + return r; +} + +/* + * makeRangeVar - + * creates a RangeVar node (rather oversimplified case) + */ +RangeVar * +makeRangeVar(char *schemaname, char *relname) +{ + RangeVar *r = makeNode(RangeVar); + + r->catalogname = NULL; + r->schemaname = schemaname; + r->relname = relname; + r->inhOpt = INH_DEFAULT; + r->istemp = false; + r->alias = NULL; + + return r; +} + +/* + * makeTypeName - + * build a TypeName node for an unqualified name. + * + * typmod is defaulted, but can be changed later by caller. + */ +TypeName * +makeTypeName(char *typnam) +{ + return makeTypeNameFromNameList(list_make1(makeString(typnam))); +} + +/* + * makeTypeNameFromNameList - + * build a TypeName node for a String list representing a qualified name. + * + * typmod is defaulted, but can be changed later by caller. + */ +TypeName * +makeTypeNameFromNameList(List *names) +{ + TypeName *n = makeNode(TypeName); + + n->names = names; + n->typmods = NIL; + n->typemod = -1; + n->location = -1; + return n; +} + +/* + * makeTypeNameFromOid - + * build a TypeName node to represent a type already known by OID/typmod. + */ +TypeName * +makeTypeNameFromOid(Oid typeid, int32 typmod) +{ + TypeName *n = makeNode(TypeName); + + n->typeid = typeid; + n->typemod = typmod; + n->location = -1; + return n; +} + +/* + * makeFuncExpr - + * build an expression tree representing a function call. + * + * The argument expressions must have been transformed already. + */ +FuncExpr * +makeFuncExpr(Oid funcid, Oid rettype, List *args, CoercionForm fformat) +{ + FuncExpr *funcexpr; + + funcexpr = makeNode(FuncExpr); + funcexpr->funcid = funcid; + funcexpr->funcresulttype = rettype; + funcexpr->funcretset = false; /* only allowed case here */ + funcexpr->funcformat = fformat; + funcexpr->args = args; + + return funcexpr; +} + +/* + * makeDefElem - + * build a DefElem node + */ +DefElem * +makeDefElem(char *name, Node *arg) +{ + DefElem *res = makeNode(DefElem); + + res->defname = name; + res->arg = arg; + return res; +} diff --git a/parser/makefuncs.h b/parser/makefuncs.h new file mode 100644 index 0000000..8c49d02 --- /dev/null +++ b/parser/makefuncs.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------------------- + * + * makefuncs.h + * prototypes for the creator functions (for primitive nodes) + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.60 2007/09/06 17:31:58 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MAKEFUNC_H +#define MAKEFUNC_H + +#include "parsenodes.h" + + +extern A_Expr *makeA_Expr(A_Expr_Kind kind, List *name, + Node *lexpr, Node *rexpr, int location); + +extern A_Expr *makeSimpleA_Expr(A_Expr_Kind kind, const char *name, + Node *lexpr, Node *rexpr, int location); + +extern Var *makeVar(Index varno, + AttrNumber varattno, + Oid vartype, + int32 vartypmod, + Index varlevelsup); + +extern TargetEntry *makeTargetEntry(Expr *expr, + AttrNumber resno, + char *resname, + bool resjunk); + +extern TargetEntry *flatCopyTargetEntry(TargetEntry *src_tle); + +extern FromExpr *makeFromExpr(List *fromlist, Node *quals); + +extern Const *makeConst(Oid consttype, + int32 consttypmod, + int constlen, + Datum constvalue, + bool constisnull, + bool constbyval); + +extern Const *makeNullConst(Oid consttype, int32 consttypmod); + +extern Node *makeBoolConst(bool value, bool isnull); + +extern Expr *makeBoolExpr(BoolExprType boolop, List *args); + +extern Alias *makeAlias(const char *aliasname, List *colnames); + +extern RelabelType *makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, + CoercionForm rformat); + +extern RangeVar *makeRangeVar(char *schemaname, char *relname); + +extern TypeName *makeTypeName(char *typnam); +extern TypeName *makeTypeNameFromNameList(List *names); +extern TypeName *makeTypeNameFromOid(Oid typeid, int32 typmod); + +extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, + List *args, CoercionForm fformat); + +extern DefElem *makeDefElem(char *name, Node *arg); + +#endif /* MAKEFUNC_H */ diff --git a/parser/memnodes.h b/parser/memnodes.h new file mode 100644 index 0000000..81a869d --- /dev/null +++ b/parser/memnodes.h @@ -0,0 +1,78 @@ +/*------------------------------------------------------------------------- + * + * memnodes.h + * POSTGRES memory context node definitions. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/memnodes.h,v 1.30 2004/12/31 22:03:34 pgsql Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MEMNODES_H +#define MEMNODES_H + +#include "nodes.h" + +/* + * MemoryContext + * A logical context in which memory allocations occur. + * + * MemoryContext itself is an abstract type that can have multiple + * implementations, though for now we have only AllocSetContext. + * The function pointers in MemoryContextMethods define one specific + * implementation of MemoryContext --- they are a virtual function table + * in C++ terms. + * + * Node types that are actual implementations of memory contexts must + * begin with the same fields as MemoryContext. + * + * Note: for largely historical reasons, typedef MemoryContext is a pointer + * to the context struct rather than the struct type itself. + */ + +typedef struct MemoryContextMethods +{ + void *(*alloc) (MemoryContext context, Size size); + /* call this free_p in case someone #define's free() */ + void (*free_p) (MemoryContext context, void *pointer); + void *(*realloc) (MemoryContext context, void *pointer, Size size); + void (*init) (MemoryContext context); + void (*reset) (MemoryContext context); + void (*delete) (MemoryContext context); + Size (*get_chunk_space) (MemoryContext context, void *pointer); + bool (*is_empty) (MemoryContext context); + void (*stats) (MemoryContext context); +#ifdef MEMORY_CONTEXT_CHECKING + void (*check) (MemoryContext context); +#endif +} MemoryContextMethods; + + +typedef struct MemoryContextData +{ + NodeTag type; /* identifies exact kind of context */ + MemoryContextMethods *methods; /* virtual function table */ + MemoryContext parent; /* NULL if no parent (toplevel context) */ + MemoryContext firstchild; /* head of linked list of children */ + MemoryContext nextchild; /* next child of same parent */ + char *name; /* context name (just for debugging) */ +} MemoryContextData; + +/* utils/palloc.h contains typedef struct MemoryContextData *MemoryContext */ + + +/* + * MemoryContextIsValid + * True iff memory context is valid. + * + * Add new context types to the set accepted by this macro. + */ +#define MemoryContextIsValid(context) \ + ((context) != NULL && \ + (IsA((context), AllocSetContext))) + +#endif /* MEMNODES_H */ diff --git a/parser/nodes.c b/parser/nodes.c new file mode 100644 index 0000000..f65ec70 --- /dev/null +++ b/parser/nodes.c @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------- + * + * nodes.c + * support code for nodes (now that we have removed the home-brew + * inheritance system, our support code for nodes is much simpler) + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/nodes/nodes.c,v 1.25 2004/12/31 21:59:55 pgsql Exp $ + * + * HISTORY + * Andrew Yu Oct 20, 1994 file creation + * + *------------------------------------------------------------------------- + */ +/*#include "postgres.h"*/ + +#include "nodes.h" + +/* + * Support for newNode() macro + */ + +Node *newNodeMacroHolder; diff --git a/parser/nodes.h b/parser/nodes.h new file mode 100644 index 0000000..a41461b --- /dev/null +++ b/parser/nodes.h @@ -0,0 +1,504 @@ +/*------------------------------------------------------------------------- + * + * nodes.h + * Definitions for tagged nodes. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.204 2007/09/03 18:46:30 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef NODES_H +#define NODES_H + +/* + * The first field of every node is NodeTag. Each node created (with makeNode) + * will have one of the following tags as the value of its first field. + * + * Note that the numbers of the node tags are not contiguous. We left holes + * here so that we can add more tags without changing the existing enum's. + * (Since node tag numbers never exist outside backend memory, there's no + * real harm in renumbering, it just costs a full rebuild ...) + */ +typedef enum NodeTag +{ + T_Invalid = 0, + + /* + * TAGS FOR EXECUTOR NODES (execnodes.h) + */ + T_IndexInfo = 10, + T_ExprContext, + T_ProjectionInfo, + T_JunkFilter, + T_ResultRelInfo, + T_EState, + T_TupleTableSlot, + + /* + * TAGS FOR PLAN NODES (plannodes.h) + */ + T_Plan = 100, + T_Result, + T_Append, + T_BitmapAnd, + T_BitmapOr, + T_Scan, + T_SeqScan, + T_IndexScan, + T_BitmapIndexScan, + T_BitmapHeapScan, + T_TidScan, + T_SubqueryScan, + T_FunctionScan, + T_ValuesScan, + T_Join, + T_NestLoop, + T_MergeJoin, + T_HashJoin, + T_Material, + T_Sort, + T_Group, + T_Agg, + T_Unique, + T_Hash, + T_SetOp, + T_Limit, + + /* + * TAGS FOR PLAN STATE NODES (execnodes.h) + * + * These should correspond one-to-one with Plan node types. + */ + T_PlanState = 200, + T_ResultState, + T_AppendState, + T_BitmapAndState, + T_BitmapOrState, + T_ScanState, + T_SeqScanState, + T_IndexScanState, + T_BitmapIndexScanState, + T_BitmapHeapScanState, + T_TidScanState, + T_SubqueryScanState, + T_FunctionScanState, + T_ValuesScanState, + T_JoinState, + T_NestLoopState, + T_MergeJoinState, + T_HashJoinState, + T_MaterialState, + T_SortState, + T_GroupState, + T_AggState, + T_UniqueState, + T_HashState, + T_SetOpState, + T_LimitState, + + /* + * TAGS FOR PRIMITIVE NODES (primnodes.h) + */ + T_Alias = 300, + T_RangeVar, + T_Expr, + T_Var, + T_Const, + T_Param, + T_Aggref, + T_ArrayRef, + T_FuncExpr, + T_OpExpr, + T_DistinctExpr, + T_ScalarArrayOpExpr, + T_BoolExpr, + T_SubLink, + T_SubPlan, + T_FieldSelect, + T_FieldStore, + T_RelabelType, + T_CoerceViaIO, + T_ArrayCoerceExpr, + T_ConvertRowtypeExpr, + T_CaseExpr, + T_CaseWhen, + T_CaseTestExpr, + T_ArrayExpr, + T_RowExpr, + T_RowCompareExpr, + T_CoalesceExpr, + T_MinMaxExpr, + T_XmlExpr, + T_NullIfExpr, + T_NullTest, + T_BooleanTest, + T_CoerceToDomain, + T_CoerceToDomainValue, + T_SetToDefault, + T_CurrentOfExpr, + T_TargetEntry, + T_RangeTblRef, + T_JoinExpr, + T_FromExpr, + T_IntoClause, + + /* + * TAGS FOR EXPRESSION STATE NODES (execnodes.h) + * + * These correspond (not always one-for-one) to primitive nodes derived + * from Expr. + */ + T_ExprState = 400, + T_GenericExprState, + T_AggrefExprState, + T_ArrayRefExprState, + T_FuncExprState, + T_ScalarArrayOpExprState, + T_BoolExprState, + T_SubPlanState, + T_FieldSelectState, + T_FieldStoreState, + T_CoerceViaIOState, + T_ArrayCoerceExprState, + T_ConvertRowtypeExprState, + T_CaseExprState, + T_CaseWhenState, + T_ArrayExprState, + T_RowExprState, + T_RowCompareExprState, + T_CoalesceExprState, + T_MinMaxExprState, + T_XmlExprState, + T_NullTestState, + T_CoerceToDomainState, + T_DomainConstraintState, + + /* + * TAGS FOR PLANNER NODES (relation.h) + */ + T_PlannerInfo = 500, + T_PlannerGlobal, + T_RelOptInfo, + T_IndexOptInfo, + T_Path, + T_IndexPath, + T_BitmapHeapPath, + T_BitmapAndPath, + T_BitmapOrPath, + T_NestPath, + T_MergePath, + T_HashPath, + T_TidPath, + T_AppendPath, + T_ResultPath, + T_MaterialPath, + T_UniquePath, + T_EquivalenceClass, + T_EquivalenceMember, + T_PathKey, + T_RestrictInfo, + T_InnerIndexscanInfo, + T_OuterJoinInfo, + T_InClauseInfo, + T_AppendRelInfo, + T_PlannerParamItem, + + /* + * TAGS FOR MEMORY NODES (memnodes.h) + */ + T_MemoryContext = 600, + T_AllocSetContext, + + /* + * TAGS FOR VALUE NODES (value.h) + */ + T_Value = 650, + T_Integer, + T_Float, + T_String, + T_BitString, + T_Null, + + /* + * TAGS FOR LIST NODES (pg_list.h) + */ + T_List, + T_IntList, + T_OidList, + + /* + * TAGS FOR STATEMENT NODES (mostly in parsenodes.h) + */ + T_Query = 700, + T_PlannedStmt, + T_InsertStmt, + T_DeleteStmt, + T_UpdateStmt, + T_SelectStmt, + T_AlterTableStmt, + T_AlterTableCmd, + T_AlterDomainStmt, + T_SetOperationStmt, + T_GrantStmt, + T_GrantRoleStmt, + T_ClosePortalStmt, + T_ClusterStmt, + T_CopyStmt, + T_CreateStmt, + T_DefineStmt, + T_DropStmt, + T_TruncateStmt, + T_CommentStmt, + T_FetchStmt, + T_IndexStmt, + T_CreateFunctionStmt, + T_AlterFunctionStmt, + T_RemoveFuncStmt, + T_RenameStmt, + T_RuleStmt, + T_NotifyStmt, + T_ListenStmt, + T_UnlistenStmt, + T_TransactionStmt, + T_ViewStmt, + T_LoadStmt, + T_CreateDomainStmt, + T_CreatedbStmt, + T_DropdbStmt, + T_VacuumStmt, + T_ExplainStmt, + T_CreateSeqStmt, + T_AlterSeqStmt, + T_VariableSetStmt, + T_VariableShowStmt, + T_DiscardStmt, + T_CreateTrigStmt, + T_DropPropertyStmt, + T_CreatePLangStmt, + T_DropPLangStmt, + T_CreateRoleStmt, + T_AlterRoleStmt, + T_DropRoleStmt, + T_LockStmt, + T_ConstraintsSetStmt, + T_ReindexStmt, + T_CheckPointStmt, + T_CreateSchemaStmt, + T_AlterDatabaseStmt, + T_AlterDatabaseSetStmt, + T_AlterRoleSetStmt, + T_CreateConversionStmt, + T_CreateCastStmt, + T_DropCastStmt, + T_CreateOpClassStmt, + T_CreateOpFamilyStmt, + T_AlterOpFamilyStmt, + T_RemoveOpClassStmt, + T_RemoveOpFamilyStmt, + T_PrepareStmt, + T_ExecuteStmt, + T_DeallocateStmt, + T_DeclareCursorStmt, + T_CreateTableSpaceStmt, + T_DropTableSpaceStmt, + T_AlterObjectSchemaStmt, + T_AlterOwnerStmt, + T_DropOwnedStmt, + T_ReassignOwnedStmt, + T_CompositeTypeStmt, + T_CreateEnumStmt, + T_AlterTSDictionaryStmt, + T_AlterTSConfigurationStmt, + + /* + * TAGS FOR PARSE TREE NODES (parsenodes.h) + */ + T_A_Expr = 900, + T_ColumnRef, + T_ParamRef, + T_A_Const, + T_FuncCall, + T_A_Indices, + T_A_Indirection, + T_ResTarget, + T_TypeCast, + T_SortBy, + T_RangeSubselect, + T_RangeFunction, + T_TypeName, + T_ColumnDef, + T_IndexElem, + T_Constraint, + T_DefElem, + T_RangeTblEntry, + T_SortClause, + T_GroupClause, + T_FkConstraint, + T_PrivGrantee, + T_FuncWithArgs, + T_PrivTarget, + T_CreateOpClassItem, + T_InhRelation, + T_FunctionParameter, + T_LockingClause, + T_RowMarkClause, + T_XmlSerialize, + + /* + * TAGS FOR RANDOM OTHER STUFF + * + * These are objects that aren't part of parse/plan/execute node tree + * structures, but we give them NodeTags anyway for identification + * purposes (usually because they are involved in APIs where we want to + * pass multiple object types through the same pointer). + */ + T_TriggerData = 950, /* in commands/trigger.h */ + T_ReturnSetInfo, /* in nodes/execnodes.h */ + T_TIDBitmap /* in nodes/tidbitmap.h */ +} NodeTag; + +/* + * The first field of a node of any type is guaranteed to be the NodeTag. + * Hence the type of any node can be gotten by casting it to Node. Declaring + * a variable to be of Node * (instead of void *) can also facilitate + * debugging. + */ +typedef struct Node +{ + NodeTag type; +} Node; + +#define nodeTag(nodeptr) (((Node*)(nodeptr))->type) + +/* + * newNode - + * create a new node of the specified size and tag the node with the + * specified tag. + * + * !WARNING!: Avoid using newNode directly. You should be using the + * macro makeNode. eg. to create a Query node, use makeNode(Query) + * + * There is no way to dereference the palloc'ed pointer to assign the + * tag, and also return the pointer itself, so we need a holder variable. + * Fortunately, this macro isn't recursive so we just define + * a global variable for this purpose. + */ +extern Node *newNodeMacroHolder; + +#define newNode(size, tag) \ +( \ + newNodeMacroHolder = (Node *) palloc0(size), \ + newNodeMacroHolder->type = (tag), \ + newNodeMacroHolder \ +) + + +#define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_)) +#define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t)) + +#define IsA(nodeptr,_type_) (nodeTag(nodeptr) == T_##_type_) + +/* ---------------------------------------------------------------- + * extern declarations follow + * ---------------------------------------------------------------- + */ + +/* + * nodes/{outfuncs.c,print.c} + */ +extern char *nodeToString(void *obj); + +/* + * nodes/{readfuncs.c,read.c} + */ +extern void *stringToNode(char *str); + +/* + * nodes/copyfuncs.c + */ +extern void *copyObject(void *obj); + +/* + * nodes/equalfuncs.c + */ +extern int equal(void *a, void *b); + + +/* + * Typedefs for identifying qualifier selectivities and plan costs as such. + * These are just plain "double"s, but declaring a variable as Selectivity + * or Cost makes the intent more obvious. + * + * These could have gone into plannodes.h or some such, but many files + * depend on them... + */ +typedef double Selectivity; /* fraction of tuples a qualifier will pass */ +typedef double Cost; /* execution cost (in page-access units) */ + + +/* + * CmdType - + * enums for type of operation represented by a Query or PlannedStmt + * + * This is needed in both parsenodes.h and plannodes.h, so put it here... + */ +typedef enum CmdType +{ + CMD_UNKNOWN, + CMD_SELECT, /* select stmt */ + CMD_UPDATE, /* update stmt */ + CMD_INSERT, /* insert stmt */ + CMD_DELETE, + CMD_UTILITY, /* cmds like create, destroy, copy, vacuum, + * etc. */ + CMD_NOTHING /* dummy command for instead nothing rules + * with qual */ +} CmdType; + + +/* + * JoinType - + * enums for types of relation joins + * + * JoinType determines the exact semantics of joining two relations using + * a matching qualification. For example, it tells what to do with a tuple + * that has no match in the other relation. + * + * This is needed in both parsenodes.h and plannodes.h, so put it here... + */ +typedef enum JoinType +{ + /* + * The canonical kinds of joins + */ + JOIN_INNER, /* matching tuple pairs only */ + JOIN_LEFT, /* pairs + unmatched outer tuples */ + JOIN_FULL, /* pairs + unmatched outer + unmatched inner */ + JOIN_RIGHT, /* pairs + unmatched inner tuples */ + + /* + * These are used for queries like WHERE foo IN (SELECT bar FROM ...). + * Only JOIN_IN is actually implemented in the executor; the others are + * defined for internal use in the planner. + */ + JOIN_IN, /* at most one result per outer row */ + JOIN_REVERSE_IN, /* at most one result per inner row */ + JOIN_UNIQUE_OUTER, /* outer path must be made unique */ + JOIN_UNIQUE_INNER /* inner path must be made unique */ + + /* + * We might need additional join types someday. + */ +} JoinType; + +#define IS_OUTER_JOIN(jointype) \ + ((jointype) == JOIN_LEFT || \ + (jointype) == JOIN_FULL || \ + (jointype) == JOIN_RIGHT) + +#endif /* NODES_H */ diff --git a/parser/outfuncs.c b/parser/outfuncs.c new file mode 100644 index 0000000..dadc742 --- /dev/null +++ b/parser/outfuncs.c @@ -0,0 +1,5195 @@ +/*------------------------------------------------------------------------- + * + * outfuncs.c + * Output functions for Postgres tree nodes. + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.261.2.1 2005/11/14 23:54:34 tgl Exp $ + * + * NOTES + * Every node type that can appear in stored rules' parsetrees *must* + * have an output function defined here (as well as an input function + * in readfuncs.c). For use in debugging, we also provide output + * functions for nodes that appear in raw parsetrees, path, and plan trees. + * These nodes however need not have input functions. + * + *------------------------------------------------------------------------- + */ +#include +#include + +#include "pool_memory.h" +#include "parser.h" +#include "pool_string.h" +#include "pg_list.h" +#include "parsenodes.h" + +#define booltostr(x) ((x) ? "true" : "false") + +void _outNode(String *str, void *obj); +static void _outList(String *str, List *node); +static void _outIdList(String *str, List *node); +static void _outAlias(String *str, Alias *node); +static void _outRangeVar(String *str, RangeVar *node); +static void _outVar(String *str, Var *node); +static void _outConst(String *str, Const *node); +static void _outParam(String *str, Param *node); +static void _outAggref(String *str, Aggref *node); +static void _outArrayRef(String *str, ArrayRef *node); +static void _outFuncExpr(String *str, FuncExpr *node); +static void _outOpExpr(String *str, OpExpr *node); +static void _outDistinctExpr(String *str, DistinctExpr *node); +static void _outScalarArrayOpExpr(String *str, ScalarArrayOpExpr *node); +static void _outBoolExpr(String *str, BoolExpr *node); +static void _outSubLink(String *str, SubLink *node); +static void _outSubPlan(String *str, SubPlan *node); +static void _outFieldSelect(String *str, FieldSelect *node); +static void _outFieldStore(String *str, FieldStore *node); +static void _outRelabelType(String *str, RelabelType *node); +static void _outConvertRowtypeExpr(String *str, ConvertRowtypeExpr *node); +static void _outCaseExpr(String *str, CaseExpr *node); +static void _outCaseWhen(String *str, CaseWhen *node); +static void _outCaseTestExpr(String *str, CaseTestExpr *node); +static void _outArrayExpr(String *str, ArrayExpr *node); +static void _outRowExpr(String *str, RowExpr *node); +static void _outCoalesceExpr(String *str, CoalesceExpr *node); +static void _outMinMaxExpr(String *str, MinMaxExpr *node); +static void _outNullIfExpr(String *str, NullIfExpr *node); +static void _outNullTest(String *str, NullTest *node); +static void _outBooleanTest(String *str, BooleanTest *node); +static void _outCoerceToDomain(String *str, CoerceToDomain *node); +static void _outCoerceToDomainValue(String *str, CoerceToDomainValue *node); +static void _outSetToDefault(String *str, SetToDefault *node); +static void _outTargetEntry(String *str, TargetEntry *node); +static void _outRangeTblRef(String *str, RangeTblRef *node); +static void _outJoinExpr(String *str, JoinExpr *node); +static void _outFromExpr(String *str, FromExpr *node); +static void _outCreateStmt(String *str, CreateStmt *node); +static void _outIndexStmt(String *str, IndexStmt *node); +static void _outNotifyStmt(String *str, NotifyStmt *node); +static void _outDeclareCursorStmt(String *str, DeclareCursorStmt *node); +static void _outSelectStmt(String *str, SelectStmt *node); +static void _outFuncCall(String *str, FuncCall *node); +static void _outDefElem(String *str, DefElem *node); +static void _outLockingClause(String *str, LockingClause *node); +static void _outColumnDef(String *str, ColumnDef *node); +static void _outTypeName(String *str, TypeName *node); +static void _outTypeCast(String *str, TypeCast *node); +static void _outIndexElem(String *str, IndexElem *node); +static void _outSortClause(String *str, SortClause *node); +static void _outGroupClause(String *str, GroupClause *node); +static void _outSetOperationStmt(String *str, SetOperationStmt *node); +static void _outAExpr(String *str, A_Expr *node); +static void _outValue(String *str, Value *value); +static void _outColumnRef(String *str, ColumnRef *node); +static void _outParamRef(String *str, ParamRef *node); +static void _outAConst(String *str, A_Const *node); +static void _outA_Indices(String *str, A_Indices *node); +static void _outA_Indirection(String *str, A_Indirection *node); +static void _outResTarget(String *str, ResTarget *node); +static void _outConstraint(String *str, Constraint *node); +static void _outFkConstraint(String *str, FkConstraint *node); + +static void _outSortBy(String *str, SortBy *node); +static void _outInsertStmt(String *str, InsertStmt *node); +static void _outUpdateStmt(String *str, UpdateStmt *node); +static void _outDeleteStmt(String *str, DeleteStmt *node); +static void _outTransactionStmt(String *str, TransactionStmt *node); +static void _outTruncateStmt(String *str, TruncateStmt *node); +static void _outVacuumStmt(String *str, VacuumStmt *node); +static void _outExplainStmt(String *str, ExplainStmt *node); +static void _outClusterStmt(String *str, ClusterStmt *node); +static void _outCheckPointStmt(String *str, CheckPointStmt *node); +static void _outClosePortalStmt(String *str, ClosePortalStmt *node); +static void _outListenStmt(String *str, ListenStmt *node); +static void _outUnlistenStmt(String *str, UnlistenStmt *node); +static void _outLoadStmt(String *str, LoadStmt *node); +static void _outCopyStmt(String *str, CopyStmt *node); +static void _outDeallocateStmt(String *str, DeallocateStmt *node); +static void _outRenameStmt(String *str, RenameStmt *node); +static void _outCreateRoleStmt(String *str, CreateRoleStmt *node); +static void _outAlterRoleStmt(String *str, AlterRoleStmt *node); +static void _outDropRoleStmt(String *str, DropRoleStmt *node); +static void _outCreateSchemaStmt(String *str, CreateSchemaStmt *node); +static void _outVariableSetStmt(String *str, VariableSetStmt *node); +static void _outVariableShowStmt(String *str, VariableShowStmt *node); +static void _outConstraintsSetStmt(String *str, ConstraintsSetStmt *node); +static void _outAlterTableStmt(String *str, AlterTableStmt *node); +static void _outCreateSeqStmt(String *str, CreateSeqStmt *node); +static void _outAlterSeqStmt(String *str, AlterSeqStmt *node); +static void _outCreatePLangStmt(String *str, CreatePLangStmt *node); +static void _outDropPLangStmt(String *str, DropPLangStmt *node); +static void _outCreateTableSpaceStmt(String *str, CreateTableSpaceStmt *node); +static void _outDropTableSpaceStmt(String *str, DropTableSpaceStmt *node); +static void _outCreateTrigStmt(String *str, CreateTrigStmt *node); +static void _outDropPropertyStmt(String *str, DropPropertyStmt *node); +static void _outDefineStmt(String *str, DefineStmt *node); +static void _outCreateOpClassStmt(String *str, CreateOpClassStmt *node); +static void _outRemoveOpClassStmt(String *str, RemoveOpClassStmt *node); +static void _outDropStmt(String *str, DropStmt *node); +static void _outFetchStmt(String *str, FetchStmt *node); +static void _outGrantStmt(String *str, GrantStmt *node); +static void _outGrantRoleStmt(String *str, GrantRoleStmt *node); +static void _outCreateFunctionStmt(String *str, CreateFunctionStmt *node); +static void _outAlterFunctionStmt(String *str, AlterFunctionStmt *node); +static void _outCreateCastStmt(String *str, CreateCastStmt *node); +static void _outDropCastStmt(String *str, DropCastStmt *node); +static void _outReindexStmt(String *str, ReindexStmt *node); +static void _outRuleStmt(String *str, RuleStmt *node); +static void _outViewStmt(String *str, ViewStmt *node); +static void _outCreatedbStmt(String *str, CreatedbStmt *node); +static void _outAlterDatabaseStmt(String *str, AlterDatabaseStmt *node); +static void _outAlterDatabaseSetStmt(String *str, AlterDatabaseSetStmt *node); +static void _outDropdbStmt(String *str, DropdbStmt *node); +static void _outCreateDomainStmt(String *str, CreateDomainStmt *node); +static void _outAlterDomainStmt(String *str, AlterDomainStmt *node); +static void _outCreateConversionStmt(String *str, CreateConversionStmt *node); +static void _outPrepareStmt(String *str, PrepareStmt *node); +static void _outExecuteStmt(String *str, ExecuteStmt *node); +static void _outLockStmt(String *str, LockStmt *node); +static void _outCommentStmt(String *str, CommentStmt *node); +static void _outDiscardStmt(String *str, DiscardStmt *node); +static void _outCreateOpFamilyStmt(String *str, CreateOpFamilyStmt *node); +static void _outAlterOpFamilyStmt(String *str, AlterOpFamilyStmt *node); +static void _outRemoveOpFamilyStmt(String *str, RemoveOpFamilyStmt *node); +static void _outCreateEnumStmt(String *str, CreateEnumStmt *node); +static void _outDropOwnedStmt(String *str, DropOwnedStmt *node); +static void _outReassignOwnedStmt(String *str, ReassignOwnedStmt *node); +static void _outAlterTSDictionaryStmt(String *str, AlterTSDictionaryStmt *node); +static void _outAlterTSConfigurationStmt(String *str, AlterTSConfigurationStmt *node); +static void _outXmlExpr(String *str, XmlExpr *node); +static void _outXmlSerialize(String *str, XmlSerialize *node); + +static void _outFuncName(String *str, List *func_name); +static void _outSetRest(String *str, VariableSetStmt *node); +static void _outSetTransactionModeList(String *str, List *list); +static void _outAlterTableCmd(String *str, AlterTableCmd *node); +static void _outOptSeqList(String *str, List *options); +static void _outPrivGrantee(String *str, PrivGrantee *node); +static void _outPrivTarget(String *str, PrivTarget *node); +static void _outFuncWithArgs(String *str, FuncWithArgs *node); +static void _outFunctionParameter(String *str, FunctionParameter *node); +static void _outPrivilegeList(String *str, List *list); +static void _outFuncOptList(String *str, List *list); +static void _outCreatedbOptList(String *str, List *options); +static void _outOperatorArgTypes(String *str, List *args); +static void _outRangeFunction(String *str, RangeFunction *node); +static void _outInhRelation(String *str, InhRelation *node); +static void _outWithDefinition(String *str, List *def_list); +static void _outCurrentOfExpr(String *str, CurrentOfExpr *node); + +static char *escape_string(char *str) +{ + int len = strlen(str), i, j; + char *es = palloc0(len * 2 + 1); + + if (es == NULL) + { + return NULL; + } + + for (i = 0, j = 0; i < len; i++, j++) + { + if (str[i] == '\'') + { + es[j++] = '\''; + } + else if (str[i] == '\\') + { + es[j++] = '\\'; + } + es[j] = str[i]; + } + + return es; +} + +static void _outIdList(String *str, List *node) +{ + ListCell *lc; + char first = 0; + + foreach(lc, node) + { + Value *v = lfirst(lc); + + if (first == 0) + first = 1; + else + string_append_char(str, ", "); + + string_append_char(str, "\""); + string_append_char(str, v->val.str); + string_append_char(str, "\""); + } +} + +static void _outList(String *str, List *node) +{ + ListCell *lc; + char first = 0; + + foreach(lc, node) + { + if (first == 0) + first = 1; + else + { + if (!IsA(lfirst(lc), A_Indices)) + string_append_char(str, ","); + } + _outNode(str, lfirst(lc)); + } +} + + + +/***************************************************************************** + * + * Stuff from primnodes.h. + * + *****************************************************************************/ + +static void +_outAlias(String *str, Alias *node) +{ + string_append_char(str, " AS \""); + string_append_char(str, node->aliasname); + string_append_char(str, "\""); + + if (node->colnames) + { + string_append_char(str, "("); + _outNode(str, node->colnames); + string_append_char(str, ")"); + } +} + +static void +_outRangeVar(String *str, RangeVar *node) +{ + if (node->catalogname) + { + string_append_char(str, "\""); + string_append_char(str, node->catalogname); + string_append_char(str, "\"."); + } + + if (node->schemaname) + { + string_append_char(str, "\""); + string_append_char(str, node->schemaname); + string_append_char(str, "\"."); + } + + string_append_char(str, "\""); + string_append_char(str, node->relname); + string_append_char(str, "\""); + + if (node->alias) + _outNode(str, node->alias); + + if (node->inhOpt == INH_YES) + { + string_append_char(str, " * "); + } +} + +static void +_outVar(String *str, Var *node) +{ + +} + +static void +_outConst(String *str, Const *node) +{ + +} + +static void +_outParam(String *str, Param *node) +{ + +} + +static void +_outAggref(String *str, Aggref *node) +{ + +} + +static void +_outArrayRef(String *str, ArrayRef *node) +{ +} + +static void +_outFuncExpr(String *str, FuncExpr *node) +{ + +} + +static void +_outOpExpr(String *str, OpExpr *node) +{ + +} + +static void +_outDistinctExpr(String *str, DistinctExpr *node) +{ + +} + +static void +_outScalarArrayOpExpr(String *str, ScalarArrayOpExpr *node) +{ + +} + +static void +_outBoolExpr(String *str, BoolExpr *node) +{ + +} + +static void +_outSubLink(String *str, SubLink *node) +{ + _outNode(str, node->testexpr); + + if (node->operName != NIL) + { + Value *v = linitial(node->operName); + if (strcmp(v->val.str, "=") == 0) + string_append_char(str, " IN "); + else + { + string_append_char(str, v->val.str); + } + } + + switch (node->subLinkType) + { + case EXISTS_SUBLINK: + string_append_char(str, " EXISTS "); + break; + + case ARRAY_SUBLINK: + string_append_char(str, " ARRAY "); + break; + + case ANY_SUBLINK: + if (node->operName != NIL) + { + Value *v = linitial(node->operName); + if (strcmp(v->val.str, "=") != 0) + { + string_append_char(str, v->val.str); + string_append_char(str, " ANY "); + } + } + break; + + case ALL_SUBLINK: + string_append_char(str, " ALL "); + break; + + default: + break; + } + + + if (node->subselect) + { + string_append_char(str, "("); + _outNode(str, node->subselect); + string_append_char(str, ")"); + } +} + +static void +_outSubPlan(String *str, SubPlan *node) +{ + +} + +static void +_outFieldSelect(String *str, FieldSelect *node) +{ + +} + +static void +_outFieldStore(String *str, FieldStore *node) +{ + +} + +static void +_outRelabelType(String *str, RelabelType *node) +{ + +} + +static void +_outConvertRowtypeExpr(String *str, ConvertRowtypeExpr *node) +{ + +} + +static void +_outCaseExpr(String *str, CaseExpr *node) +{ + ListCell *lc; + + string_append_char(str, "CASE "); + if (node->arg) + _outNode(str, node->arg); + + foreach (lc, node->args) + { + _outNode(str, lfirst(lc)); + } + + if (node->defresult) + { + string_append_char(str, " ELSE "); + _outNode(str, node->defresult); + } + + string_append_char(str, " END"); +} + +static void +_outCaseWhen(String *str, CaseWhen *node) +{ + string_append_char(str, " WHEN "); + _outNode(str, node->expr); + string_append_char(str, " THEN "); + _outNode(str, node->result); +} + +static void +_outCaseTestExpr(String *str, CaseTestExpr *node) +{ + +} + +static void +_outArrayExpr(String *str, ArrayExpr *node) +{ + string_append_char(str, "["); + _outNode(str, node->elements); + string_append_char(str, "]"); +} + +static void +_outRowExpr(String *str, RowExpr *node) +{ + if (node->args == NIL) + string_append_char(str, "ROW ()"); + else + { + string_append_char(str, "ROW ("); + _outNode(str, node->args); + string_append_char(str, ")"); + } +} + +static void +_outCoalesceExpr(String *str, CoalesceExpr *node) +{ + string_append_char(str, "COALESCE ("); + _outNode(str, node->args); + string_append_char(str, ")"); +} + +static void +_outMinMaxExpr(String *str, MinMaxExpr *node) +{ + if (node->op == IS_GREATEST) + { + string_append_char(str, "GREATEST ("); + _outNode(str, node->args); + string_append_char(str, ")"); + } + else if (node->op == IS_LEAST) + { + string_append_char(str, "LEAST ("); + _outNode(str, node->args); + string_append_char(str, ")"); + } +} + +static void +_outNullIfExpr(String *str, NullIfExpr *node) +{ + +} + +static void +_outNullTest(String *str, NullTest *node) +{ + _outNode(str, node->arg); + if (node->nulltesttype == IS_NOT_NULL) + string_append_char(str, " IS NOT NULL"); + else + string_append_char(str, " IS NULL"); +} + +static void +_outBooleanTest(String *str, BooleanTest *node) +{ + _outNode(str, node->arg); + + switch (node->booltesttype) + { + case IS_TRUE: + string_append_char(str, " IS TRUE"); + break; + + case IS_NOT_TRUE: + string_append_char(str, " IS NOT TRUE"); + break; + + case IS_FALSE: + string_append_char(str, " IS FALSE"); + break; + + case IS_NOT_FALSE: + string_append_char(str, " IS NOT FALSE"); + break; + + case IS_UNKNOWN: + string_append_char(str, " IS UNKNOWN"); + break; + + case IS_NOT_UNKNOWN: + string_append_char(str, " IS NOT UNKNOWN"); + break; + } +} + +static void +_outCoerceToDomain(String *str, CoerceToDomain *node) +{ + +} + +static void +_outCoerceToDomainValue(String *str, CoerceToDomainValue *node) +{ + +} + +static void +_outSetToDefault(String *str, SetToDefault *node) +{ + string_append_char(str, "DEFAULT"); +} + +static void +_outTargetEntry(String *str, TargetEntry *node) +{ + +} + +static void +_outRangeTblRef(String *str, RangeTblRef *node) +{ + +} + +static void +_outJoinExpr(String *str, JoinExpr *node) +{ + _outNode(str, node->larg); + + if (node->isNatural == TRUE) + string_append_char(str, " NATURAL"); + + if (node->jointype == JOIN_INNER) + { + if (node->using == NIL && node->quals == NULL && !node->isNatural) + string_append_char(str, " CROSS JOIN "); + else + string_append_char(str, " JOIN "); + } + else if (node->jointype == JOIN_INNER) + string_append_char(str, " JOIN "); + else if (node->jointype == JOIN_LEFT) + string_append_char(str, " LEFT OUTER JOIN "); + else if (node->jointype == JOIN_FULL) + string_append_char(str, " FULL OUTER JOIN "); + else if (node->jointype == JOIN_RIGHT) + string_append_char(str, " RIGHT OUTER JOIN "); + + _outNode(str, node->rarg); + + if (node->using != NIL && IsA(node->using, List)) + { + ListCell *lc; + char comma = 0; + + string_append_char(str, " USING("); + + foreach (lc, node->using) + { + Value *value; + + if (comma == 0) + comma = 1; + else + string_append_char(str, ","); + + value = lfirst(lc); + string_append_char(str, "\""); + string_append_char(str, value->val.str); + string_append_char(str, "\""); + } + + string_append_char(str, ")"); + } + + if (node->quals) + { + string_append_char(str, " ON "); + _outNode(str, node->quals); + } +} + +static void +_outFromExpr(String *str, FromExpr *node) +{ + +} + +/***************************************************************************** + * + * Stuff from parsenodes.h. + * + *****************************************************************************/ + +static void +_outCreateStmt(String *str, CreateStmt *node) +{ + string_append_char(str, "CREATE "); + if (node->relation->istemp) + string_append_char(str, "TEMP "); + string_append_char(str, "TABLE "); + _outNode(str, node->relation); + string_append_char(str, " ("); + _outNode(str, node->tableElts); + string_append_char(str, ") "); + + if (node->inhRelations != NIL) + { + string_append_char(str, "INHERITS ("); + _outNode(str, node->inhRelations); + string_append_char(str, ")"); + } + + if (node->options) + _outWithDefinition(str, node->options); + + switch (node->oncommit) + { + case ONCOMMIT_DROP: + string_append_char(str, " ON COMMIT DROP"); + break; + + case ONCOMMIT_DELETE_ROWS: + string_append_char(str, " ON COMMIT DELETE ROWS"); + break; + + case ONCOMMIT_PRESERVE_ROWS: + string_append_char(str, " ON COMMIT PRESERVE ROWS"); + break; + + default: + break; + } + + if (node->tablespacename) + { + string_append_char(str, " TABLESPACE \""); + string_append_char(str, node->tablespacename); + string_append_char(str, "\""); + } +} + +static void +_outIndexStmt(String *str, IndexStmt *node) +{ + string_append_char(str, "CREATE "); + + if (node->unique == TRUE) + string_append_char(str, "UNIQUE "); + + if (node->concurrent == true) + string_append_char(str, "INDEX CONCURRENTLY \""); + else + string_append_char(str, "INDEX \""); + string_append_char(str, node->idxname); + string_append_char(str, "\" ON "); + _outNode(str, node->relation); + + if (strcmp(node->accessMethod, DEFAULT_INDEX_TYPE)) + { + string_append_char(str, " USING "); + string_append_char(str, node->accessMethod); + } + + string_append_char(str, "("); + _outNode(str, node->indexParams); + string_append_char(str, ")"); + + if (node->tableSpace) + { + string_append_char(str, " TABLESPACE \""); + string_append_char(str, node->tableSpace); + string_append_char(str, "\""); + } + + if (node->whereClause) + { + string_append_char(str, " WHERE "); + _outNode(str, node->whereClause); + } +} + +static void +_outNotifyStmt(String *str, NotifyStmt *node) +{ + string_append_char(str, "NOTIFY "); + _outNode(str, node->relation); +} + +static void +_outDeclareCursorStmt(String *str, DeclareCursorStmt *node) +{ + string_append_char(str, "DECLARE \""); + string_append_char(str, node->portalname); + string_append_char(str, "\" "); + + if (node->options & CURSOR_OPT_SCROLL) + string_append_char(str, "SCROLL "); + if (node->options & CURSOR_OPT_BINARY) + string_append_char(str, "BINARY "); + if (node->options & CURSOR_OPT_INSENSITIVE) + string_append_char(str, "INSENSITIVE "); + + string_append_char(str, "CURSOR "); + if (node->options & CURSOR_OPT_HOLD) + string_append_char(str, "WITH HOLD "); + string_append_char(str, "FOR"); + _outNode(str, node->query); +} + +static void +_outSelectStmt(String *str, SelectStmt *node) +{ + if (node->larg) /* SETOP */ + { + string_append_char(str, "("); + _outNode(str, node->larg); + string_append_char(str, ") "); + + switch (node->op) + { + case SETOP_UNION: + string_append_char(str, " UNION "); + break; + + case SETOP_INTERSECT: + string_append_char(str, " INTERSECT "); + break; + + case SETOP_EXCEPT: + string_append_char(str, " EXCEPT "); + + default: + break; + } + + if (node->all) + string_append_char(str, "ALL "); + + if (node->rarg) + { + string_append_char(str, "("); + _outNode(str, node->rarg); + string_append_char(str, ") "); + } + } + else if (node->valuesLists) /* VALUES ... */ + { + ListCell *lc; + int comma = 0; + + foreach (lc, node->valuesLists) + { + if (comma == 0) + comma = 1; + else + string_append_char(str, ","); + + string_append_char(str, " VALUES ("); + _outNode(str, lfirst(lc)); + string_append_char(str, ")"); + } + } + else + { + if (node->intoClause) + { + IntoClause *into = (IntoClause *)node->intoClause; + RangeVar *rel = (RangeVar *)into->rel; + + string_append_char(str, "CREATE "); + if (rel->istemp == true) + string_append_char(str, "TEMP "); + string_append_char(str, "TABLE "); + _outNode(str, into->rel); + + if (into->colNames) + { + string_append_char(str, " ("); + _outNode(str, into->colNames); + string_append_char(str, ") "); + } + + if (into->options) + _outWithDefinition(str, into->options); + + switch (into->onCommit) + { + case ONCOMMIT_DROP: + string_append_char(str, " ON COMMIT DROP"); + break; + + case ONCOMMIT_DELETE_ROWS: + string_append_char(str, " ON COMMIT DELETE ROWS"); + break; + + case ONCOMMIT_PRESERVE_ROWS: + string_append_char(str, " ON COMMIT PRESERVE ROWS"); + break; + + default: + break; + } + + string_append_char(str, " AS"); + } + + string_append_char(str, " SELECT "); + + if (node->distinctClause) + { + string_append_char(str, "DISTINCT "); + if (lfirst(list_head(node->distinctClause)) != NIL) + { + string_append_char(str, "ON ("); + _outNode(str, node->distinctClause); + string_append_char(str, " ) "); + } + } + + _outNode(str, node->targetList); + + if (node->fromClause) + { + string_append_char(str, " FROM "); + _outNode(str, node->fromClause); + } + + if (node->whereClause) + { + string_append_char(str, " WHERE "); + _outNode(str, node->whereClause); + } + + if (node->groupClause) + { + string_append_char(str, " GROUP BY "); + _outNode(str, node->groupClause); + } + + if (node->havingClause) + { + string_append_char(str, " HAVING "); + _outNode(str, node->havingClause); + } + } + + if (node->sortClause) + { + string_append_char(str, " ORDER BY "); + _outNode(str, node->sortClause); + } + + if (node->limitOffset) + { + string_append_char(str, " OFFSET "); + _outNode(str, node->limitOffset); + } + + if (node->limitCount) + { + string_append_char(str, " LIMIT "); + if (IsA(node->limitCount, A_Const) && + ((A_Const *)node->limitCount)->val.type == T_Null) + { + string_append_char(str, "ALL "); + } + else + { + _outNode(str, node->limitCount); + } + } + + _outNode(str, node->lockingClause); +} + +static void +_outFuncCall(String *str, FuncCall *node) +{ + char *funcname; + _outFuncName(str, node->funcname); + + funcname = strVal(lfirst(list_head(node->funcname))); + + if(strcmp(funcname,"user") == 0 || + strcmp(funcname,"current_user") == 0 || + strcmp(funcname,"session_user") == 0 || + strcmp(funcname,"current_role") == 0) + return ; + + string_append_char(str, "("); + + if (node->agg_distinct == TRUE) + string_append_char(str, "DISTINCT "); + + if (node->agg_star == TRUE) + string_append_char(str, "*"); + else + _outNode(str, node->args); + + string_append_char(str, ")"); +} + +static void +_outDefElem(String *str, DefElem *node) +{ + +} + +static void +_outLockingClause(String *str, LockingClause *node) +{ + if (node == NULL) + return; + + if (node->forUpdate == TRUE) + string_append_char(str, " FOR UPDATE"); + else + string_append_char(str, " FOR SHARED"); + + _outNode(str, node->lockedRels); + + if (node->noWait == TRUE) + string_append_char(str, " NOWAIT "); +} + +static void +_outColumnDef(String *str, ColumnDef *node) +{ + string_append_char(str, "\""); + string_append_char(str, node->colname); + string_append_char(str, "\" "); + _outNode(str, node->typename); + _outNode(str, node->constraints); +} + +static void +_outTypeName(String *str, TypeName *node) +{ + ListCell *lc; + char dot = 0; + + foreach (lc, node->names) + { + Value *v = (Value *) lfirst(lc); + char *typename = v->val.str; + + if (dot == 0) + dot = 1; + else + string_append_char(str, "."); + if(node->typemod < 0) + { + string_append_char(str, "\""); + string_append_char(str, typename); + string_append_char(str, "\""); + } else + string_append_char(str, typename); + } + + if (node->typemod > 0) + { + int lower; + char buf[16]; + string_append_char(str, "("); + snprintf(buf, 16, "%d", ((node->typemod - VARHDRSZ) >> 16) & 0x00FF); + string_append_char(str, buf); + lower = (node->typemod-VARHDRSZ) & 0x00FF; + + if(lower != 0) + { + char buf2[16]; + string_append_char(str, ","); + snprintf(buf2, 16, "%d",lower); + string_append_char(str, buf2); + } + + string_append_char(str, ")"); + } +} + +static void +_outTypeCast(String *str, TypeCast *node) +{ + _outNode(str, node->arg); + string_append_char(str, "::"); + _outNode(str, node->typename); + +} + +static void +_outIndexElem(String *str, IndexElem *node) +{ + if (node->name) + { + string_append_char(str, "\""); + string_append_char(str, node->name); + string_append_char(str, "\""); + if (node->opclass != NIL) + _outNode(str, node->opclass); + } + else + { + string_append_char(str, "("); + _outNode(str, node->expr); + string_append_char(str, ")"); + if (node->opclass != NIL) + _outNode(str, node->opclass); + } +} + + +static void +_outSortClause(String *str, SortClause *node) +{ + +} + +static void +_outGroupClause(String *str, GroupClause *node) +{ + +} + +static void +_outSetOperationStmt(String *str, SetOperationStmt *node) +{ + +} + + +static void +_outAExpr(String *str, A_Expr *node) +{ + Value *v; + + switch (node->kind) + { + case AEXPR_OP: + if (list_length(node->name) == 1) + { + Value *op = (Value *) lfirst(list_head(node->name)); + + string_append_char(str, " ("); + _outNode(str, node->lexpr); + string_append_char(str, op->val.str); + _outNode(str, node->rexpr); + string_append_char(str, " )"); + } + break; + + case AEXPR_AND: + string_append_char(str, " ("); + _outNode(str, node->lexpr); + string_append_char(str, " AND "); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_OR: + string_append_char(str, " ("); + _outNode(str, node->lexpr); + string_append_char(str, " OR "); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_NOT: + string_append_char(str, " (NOT "); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_OP_ANY: + _outNode(str, node->lexpr); + v = linitial(node->name); + string_append_char(str, v->val.str); + string_append_char(str, "ANY("); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_OP_ALL: + _outNode(str, node->lexpr); + v = linitial(node->name); + string_append_char(str, v->val.str); + string_append_char(str, "ALL("); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_DISTINCT: + string_append_char(str, " ("); + _outNode(str, node->lexpr); + string_append_char(str, " IS DISTINCT FROM "); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_NULLIF: + string_append_char(str, " NULLIF("); + _outNode(str, node->lexpr); + string_append_char(str, ", "); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_OF: + _outNode(str, node->lexpr); + v = linitial(node->name); + if (v->val.str[0] == '!') + string_append_char(str, " IS NOT OF ("); + else + string_append_char(str, " IS OF ("); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + case AEXPR_IN: + _outNode(str, node->lexpr); + v = (Value *)lfirst(list_head(node->name)); + if (v->val.str[0] == '=') + string_append_char(str, " IN ("); + else + string_append_char(str, " NOT IN ("); + _outNode(str, node->rexpr); + string_append_char(str, ")"); + break; + + default: + break; + } +} + +static void +_outValue(String *str, Value *value) +{ + char buf[16]; + + switch (value->type) + { + case T_Integer: + sprintf(buf, "%ld", value->val.ival); + string_append_char(str, buf); + break; + + case T_Float: + string_append_char(str, value->val.str); + break; + + case T_String: + string_append_char(str, "'"); + string_append_char(str, escape_string(value->val.str)); + string_append_char(str, "'"); + break; + + case T_Null: + string_append_char(str, "NULL"); + break; + + default: + break; + } +} + +static void +_outColumnRef(String *str, ColumnRef *node) +{ + ListCell *c; + char first = 0; + + foreach (c, node->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + Value *v = (Value *) lfirst(c); + + if (first == 0) + first = 1; + else + string_append_char(str, "."); + + string_append_char(str, "\""); + string_append_char(str, v->val.str); + string_append_char(str, "\""); + } + } +} + +static void +_outParamRef(String *str, ParamRef *node) +{ + char buf[16]; + + snprintf(buf, 16, "%d", node->number); + string_append_char(str, "$"); + string_append_char(str, buf); +} + +static void +_outAConst(String *str, A_Const *node) +{ + char buf[16]; + char *name = NULL; + + if (node->typename) + { + Value *v = linitial(node->typename->names); + name = v->val.str; + _outNode(str, node->typename); + string_append_char(str, " "); + } + + switch (node->val.type) + { + case T_Integer: + sprintf(buf, "%ld", node->val.val.ival); + string_append_char(str, buf); + break; + + case T_Float: + string_append_char(str, node->val.val.str); + break; + + case T_String: + string_append_char(str, "'"); + string_append_char(str, escape_string(node->val.val.str)); + string_append_char(str, "'"); + break; + + case T_Null: + string_append_char(str, "NULL"); + break; + + default: + break; + } + + if (name && (strcmp(name, "interval") == 0) && + node->typename->typmods) + { + A_Const *v = linitial(node->typename->typmods); + int mask = v->val.val.ival; + + if (mask == INTERVAL_MASK(YEAR)) + string_append_char(str, " YEAR"); + else if (mask == INTERVAL_MASK(MONTH)) + string_append_char(str, " MONTH"); + else if (mask == INTERVAL_MASK(DAY)) + string_append_char(str, " DAY"); + else if (mask == INTERVAL_MASK(HOUR)) + string_append_char(str, " HOUR"); + else if (mask == INTERVAL_MASK(MINUTE)) + string_append_char(str, " MINUTE"); + else if (mask == INTERVAL_MASK(SECOND)) + string_append_char(str, " SECOND"); + else if (mask == (INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH))) + string_append_char(str, " YEAR TO MONTH"); + else if (mask == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR))) + string_append_char(str, " DAY TO HOUR"); + else if (mask == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | + INTERVAL_MASK(MINUTE))) + string_append_char(str, " DAY TO MINUTE"); + else if (mask == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | + INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND))) + string_append_char(str, " DAY TO SECOND"); + else if (mask == (INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) + string_append_char(str, " HOUR TO MINUTE"); + else if (mask == (INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | + INTERVAL_MASK(SECOND))) + string_append_char(str, " HOUR TO SECOND"); + } +} + +static void +_outA_Indices(String *str, A_Indices *node) +{ + string_append_char(str, "["); + if (node->lidx) + { + _outNode(str, node->lidx); + string_append_char(str, ":"); + } + _outNode(str, node->uidx); + string_append_char(str, "]"); +} + +static void +_outA_Indirection(String *str, A_Indirection *node) +{ + _outNode(str, node->arg); + _outNode(str, node->indirection); +} + +static void +_outResTarget(String *str, ResTarget *node) +{ + if (node->indirection != NIL) + { + string_append_char(str, "\""); + string_append_char(str, node->name); + string_append_char(str, "\"="); + _outNode(str, node->val); + } + else + { + _outNode(str, node->val); + + if (node->name) + { + string_append_char(str, " AS "); + string_append_char(str, "\""); + string_append_char(str, node->name); + string_append_char(str, "\" "); + } + } +} + +static void +_outConstraint(String *str, Constraint *node) +{ + if (node->name) + { + string_append_char(str, "CONSTRAINT \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + } + + switch (node->contype) + { + case CONSTR_CHECK: + string_append_char(str, " CHECK ("); + _outNode(str, node->raw_expr); + string_append_char(str, ")"); + break; + + case CONSTR_UNIQUE: + string_append_char(str, " UNIQUE"); + if (node->keys) + { + string_append_char(str, "("); + _outIdList(str, node->keys); + string_append_char(str, ")"); + } + + if (node->options) + { + _outWithDefinition(str, node->options); + } + + if (node->indexspace) + { + string_append_char(str, " USING INDEX TABLESPACE \""); + string_append_char(str, node->indexspace); + string_append_char(str, "\""); + } + break; + + case CONSTR_PRIMARY: + string_append_char(str, " PRIMARY KEY"); + if (node->keys) + { + string_append_char(str, "("); + _outIdList(str, node->keys); + string_append_char(str, ")"); + } + if (node->options) + ; + + if (node->indexspace) + { + string_append_char(str, " USING INDEX TABLESPACE \""); + string_append_char(str, node->indexspace); + string_append_char(str, "\""); + } + break; + + case CONSTR_NOTNULL: + string_append_char(str, " NOT NULL"); + break; + + case CONSTR_NULL: + string_append_char(str, " NULL"); + break; + + case CONSTR_DEFAULT: + string_append_char(str, "DEFAULT "); + _outNode(str, node->raw_expr); + break; + + default: + break; + } +} + +static void +_outFkConstraint(String *str, FkConstraint *node) +{ + if (node->constr_name) + { + string_append_char(str, "CONSTRAINT \""); + string_append_char(str, node->constr_name); + string_append_char(str, "\""); + } + + if (node->fk_attrs != NIL) + { + string_append_char(str, " FOREIGN KEY ("); + _outIdList(str, node->fk_attrs); + string_append_char(str, ")" ); + } + + string_append_char(str, " REFERENCES "); + _outNode(str, node->pktable); + + if (node->pk_attrs != NIL) + { + string_append_char(str, "("); + _outIdList(str, node->pk_attrs); + string_append_char(str, ")"); + } + + switch (node->fk_matchtype) + { + case FKCONSTR_MATCH_FULL: + string_append_char(str, " MATCH FULL"); + break; + + case FKCONSTR_MATCH_PARTIAL: + string_append_char(str, " MATCH PARTIAL"); + break; + + default: + break; + } + + switch (node->fk_upd_action) + { + case FKCONSTR_ACTION_RESTRICT: + string_append_char(str, " ON UPDATE RESTRICT"); + break; + + case FKCONSTR_ACTION_CASCADE: + string_append_char(str, " ON UPDATE CASCADE"); + break; + + case FKCONSTR_ACTION_SETNULL: + string_append_char(str, " ON UPDATE SET NULL"); + break; + + case FKCONSTR_ACTION_SETDEFAULT: + string_append_char(str, " ON UPDATE SET DEFAULT"); + break; + + default: + break; + } + + switch (node->fk_del_action) + { + case FKCONSTR_ACTION_RESTRICT: + string_append_char(str, " ON DELETE RESTRICT"); + break; + + case FKCONSTR_ACTION_CASCADE: + string_append_char(str, " ON DELETE CASCADE"); + break; + + case FKCONSTR_ACTION_SETNULL: + string_append_char(str, " ON DELETE SET NULL"); + break; + + case FKCONSTR_ACTION_SETDEFAULT: + string_append_char(str, " ON DELETE SET DEFAULT"); + break; + + default: + break; + } + + if (node->deferrable) + string_append_char(str, " DEFERRABLE"); + + if (node->initdeferred) + string_append_char(str, " INITIALLY DEFERRED"); +} + + +static void +_outSortBy(String *str, SortBy *node) +{ + _outNode(str, node->node); + + if (node->sortby_dir == SORTBY_USING) + { + string_append_char(str, " USING "); + _outNode(str, node->useOp); + } + else if (node->sortby_dir == SORTBY_DESC) + string_append_char(str, " DESC "); + + if (node->sortby_nulls == SORTBY_NULLS_FIRST) + string_append_char(str, " NULLS FIRST "); + else if (node->sortby_nulls == SORTBY_NULLS_LAST) + string_append_char(str, " NULLS LAST "); +} + +static void _outInsertStmt(String *str, InsertStmt *node) +{ + string_append_char(str, "INSERT INTO "); + _outNode(str, node->relation); + + if (node->cols == NIL && node->selectStmt == NULL) + string_append_char(str, " DEFAULT VALUES"); + + if (node->cols) + { + char comma = 0; + ListCell *lc; + + string_append_char(str, "("); + + foreach (lc, node->cols) + { + ResTarget *node = lfirst(lc); + if (comma == 0) + comma = 1; + else + string_append_char(str, ", "); + + string_append_char(str, "\""); + string_append_char(str, node->name); + string_append_char(str, "\""); + } + string_append_char(str, ")"); + } + + if (node->selectStmt) + { + _outNode(str, node->selectStmt); + } + + if (node->returningList) + { + string_append_char(str, " RETURNING "); + _outNode(str, node->returningList); + } +} + +static void _outUpdateStmt(String *str, UpdateStmt *node) +{ + ListCell *lc; + char comma = 0; + + string_append_char(str, "UPDATE "); + + _outNode(str, node->relation); + + string_append_char(str, " SET "); + foreach (lc, node->targetList) + { + ResTarget *node = lfirst(lc); + if (comma == 0) + comma = 1; + else + string_append_char(str, ", "); + + string_append_char(str, "\""); + string_append_char(str, node->name); + string_append_char(str, "\" = "); + _outNode(str, node->val); + } + + if (node->fromClause) + { + string_append_char(str, " FROM "); + _outNode(str, node->fromClause); + } + + if (node->whereClause) + { + string_append_char(str, " WHERE "); + _outNode(str, node->whereClause); + } + + if (node->returningList) + { + string_append_char(str, " RETURNING "); + _outNode(str, node->returningList); + } +} + +static void _outDeleteStmt(String *str, DeleteStmt *node) +{ + string_append_char(str, "DELETE FROM "); + + _outNode(str, node->relation); + + if (node->usingClause) + { + string_append_char(str, " USING "); + _outNode(str, node->usingClause); + } + + if (node->whereClause) + { + string_append_char(str, " WHERE "); + _outNode(str, node->whereClause); + } + + if (node->returningList) + { + string_append_char(str, " RETURNING "); + _outNode(str, node->returningList); + } +} + +static void _outTransactionStmt(String *str, TransactionStmt *node) +{ + switch (node->kind) + { + case TRANS_STMT_BEGIN: + string_append_char(str, "BEGIN "); + break; + + case TRANS_STMT_START: + string_append_char(str, "START TRANSACTION "); + break; + + case TRANS_STMT_COMMIT: + string_append_char(str, "COMMIT "); + break; + + case TRANS_STMT_ROLLBACK: + string_append_char(str, "ABORT "); + break; + + case TRANS_STMT_SAVEPOINT: + string_append_char(str, "SAVEPOINT "); + break; + + case TRANS_STMT_RELEASE: + string_append_char(str, "RELEASE "); + break; + + case TRANS_STMT_ROLLBACK_TO: + string_append_char(str, "ROLLBACK TO "); + break; + + case TRANS_STMT_PREPARE: + string_append_char(str, "PREPARE TRANSACTION "); + break; + + case TRANS_STMT_COMMIT_PREPARED: + string_append_char(str, "COMMIT PREPARED "); + break; + + case TRANS_STMT_ROLLBACK_PREPARED: + string_append_char(str, "ROLLBACK PREPARED "); + break; + + default: + break; + } + + if (node->options) + _outSetTransactionModeList(str, node->options); + + if (node->gid) + string_append_char(str, node->gid); +} + + +static void _outTruncateStmt(String *str, TruncateStmt *node) +{ + string_append_char(str, "TRUNCATE "); + _outNode(str, node->relations); +} + +static void _outVacuumStmt(String *str, VacuumStmt *node) +{ + if (node->vacuum == true) + string_append_char(str, "VACUUM "); + else + string_append_char(str, "ANALYZE "); + + if (node->full == TRUE) + string_append_char(str, "FULL "); + + if (node->freeze_min_age == 0) + string_append_char(str, "FREEZE "); + + if (node->verbose == TRUE) + string_append_char(str, "VERBOSE "); + + if (node->analyze) + string_append_char(str, "ANALYZE "); + + _outNode(str, node->relation); + if (node->va_cols) + { + string_append_char(str, "("); + _outIdList(str, node->va_cols); + string_append_char(str, ") "); + } +} + +static void _outExplainStmt(String *str, ExplainStmt *node) +{ + string_append_char(str, "EXPLAIN "); + + if (node->analyze == TRUE) + string_append_char(str, "ANALYZE "); + if (node->verbose == TRUE) + string_append_char(str, "VERBOSE "); + + _outNode(str, node->query); +} + +static void _outClusterStmt(String *str, ClusterStmt *node) +{ + string_append_char(str, "CLUSTER "); + + if (node->indexname) + { + string_append_char(str, "\""); + string_append_char(str, node->indexname); + string_append_char(str, "\" ON "); + } + if (node->relation) + _outNode(str, node->relation); +} + +static void _outCheckPointStmt(String *str, CheckPointStmt *node) +{ + string_append_char(str, "CHECKPOINT"); +} + +static void _outClosePortalStmt(String *str, ClosePortalStmt *node) +{ + string_append_char(str, "CLOSE "); + string_append_char(str, "\""); + string_append_char(str, node->portalname); + string_append_char(str, "\""); +} + +static void _outListenStmt(String *str, ListenStmt *node) +{ + string_append_char(str, "LISTEN "); + _outNode(str, node->relation); +} + +static void _outUnlistenStmt(String *str, UnlistenStmt *node) +{ + string_append_char(str, "UNLISTEN "); + _outNode(str, node->relation); +} + +static void _outLoadStmt(String *str, LoadStmt *node) +{ + string_append_char(str, "LOAD '"); + string_append_char(str, node->filename); + string_append_char(str, "'"); +} + +static void _outCopyStmt(String *str, CopyStmt *node) +{ + int binary = FALSE; + int oids = FALSE; + char *delimiter = NULL; + char *null = NULL; + int csv = FALSE; + int header = FALSE; + char *quote = NULL; + char *escape = NULL; + Node *force_quote = NULL; + Node *force_notnull = NULL; + ListCell *lc; + + foreach (lc, node->options) + { + DefElem *e = lfirst(lc); + + if (strcmp(e->defname, "binary") == 0) + binary = TRUE; + else if (strcmp(e->defname, "oids") == 0) + oids = TRUE; + else if (strcmp(e->defname, "delimiter") == 0) + delimiter = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "null") == 0) + null = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "csv") == 0) + csv = TRUE; + else if (strcmp(e->defname, "header") == 0) + header = TRUE; + else if (strcmp(e->defname, "quote") == 0) + quote = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "escape") == 0) + escape = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "force_quote") == 0) + force_quote = e->arg; + else if (strcmp(e->defname, "force_notnull") == 0) + force_notnull = e->arg; + } + + string_append_char(str, "COPY "); + + if (node->query) + { + string_append_char(str, "("); + _outNode(str, node->query); + string_append_char(str, ")"); + } + + _outNode(str, node->relation); + + if (node->attlist) + { + string_append_char(str, "("); + _outIdList(str, node->attlist); + string_append_char(str, ") "); + } + + if (node->is_from == TRUE) + string_append_char(str, " FROM "); + else + string_append_char(str, " TO "); + + if (node->filename) + { + string_append_char(str, "'"); + string_append_char(str, node->filename); + string_append_char(str, "'"); + } + else + string_append_char(str, node->is_from == TRUE ? "STDIN" : "STDOUT"); + + if (binary == TRUE) + string_append_char(str, " BINARY "); + + if (oids == TRUE) + string_append_char(str, " OIDS "); + + if (delimiter) + { + string_append_char(str, " DELIMITERS '"); + string_append_char(str, delimiter); + string_append_char(str, "'"); + } + + if (null) + { + string_append_char(str, " NULL '"); + string_append_char(str, null); + string_append_char(str, "' "); + } + + if (csv == TRUE) + string_append_char(str, "CSV "); + + if (header == TRUE) + string_append_char(str, "HEADER "); + + if (quote) + { + string_append_char(str, "QUOTE '"); + string_append_char(str, quote); + string_append_char(str, "' "); + } + + if (escape) + { + string_append_char(str, "ESCAPE '"); + string_append_char(str, escape); + string_append_char(str, "' "); + } + + if (force_quote) + { + string_append_char(str, "FORCE QUOTE "); + _outNode(str, force_quote); + } + + if (force_notnull) + { + string_append_char(str, " FORCE NOT NULL "); + _outNode(str, force_notnull); + } +} + +static void _outDeallocateStmt(String *str, DeallocateStmt *node) +{ + string_append_char(str, "DEALLOCATE \""); + string_append_char(str, node->name); + string_append_char(str, "\""); +} + +static void _outRenameStmt(String *str, RenameStmt *node) +{ + ListCell *lc; + char comma = 0; + + string_append_char(str, "ALTER "); + + switch (node->renameType) + { + case OBJECT_AGGREGATE: + string_append_char(str, "AGGREGATE "); + _outNode(str, node->object); + string_append_char(str, " ("); + string_append_char(str, ") RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_CONVERSION: + string_append_char(str, "CONVERSION "); + _outNode(str, node->object); + string_append_char(str, " RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_DATABASE: + string_append_char(str, "DATABASE \""); + string_append_char(str, node->subname); + string_append_char(str, "\" RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_FUNCTION: + string_append_char(str, "FUNCTION "); + + foreach (lc, node->object) + { + Node *n = lfirst(lc); + if (IsA(n, String)) + { + Value *value = (Value *) n; + if (comma == 0) + comma = 1; + else + string_append_char(str, "."); + string_append_char(str, "\""); + string_append_char(str, value->val.str); + string_append_char(str, "\""); + } + else + _outNode(str, n); + } + + string_append_char(str, "("); + _outNode(str, node->objarg); + string_append_char(str, ")"); + string_append_char(str, " RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_ROLE: + string_append_char(str, "ROLE \""); + string_append_char(str, node->subname); + string_append_char(str, "\" RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_LANGUAGE: + string_append_char(str, "LANGUAGE \""); + string_append_char(str, node->subname); + string_append_char(str, "\" RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_OPCLASS: + string_append_char(str, "OPERATOR CLASS "); + _outNode(str, node->object); + string_append_char(str, " USING "); + string_append_char(str, node->subname); + string_append_char(str, " RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_SCHEMA: + string_append_char(str, "SCHEMA \""); + string_append_char(str, node->subname); + string_append_char(str, "\" RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_TABLE: + string_append_char(str, "TABLE "); + _outNode(str, node->relation); + string_append_char(str, " RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_INDEX: + string_append_char(str, "INDEX "); + _outNode(str, node->relation); + string_append_char(str, " RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_COLUMN: + string_append_char(str, "TABLE "); + _outNode(str, node->relation); + string_append_char(str, " RENAME \""); + string_append_char(str, node->subname); + string_append_char(str, "\" TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_TRIGGER: + string_append_char(str, "TRIGGER \""); + string_append_char(str, node->subname); + string_append_char(str, "\" ON "); + _outNode(str, node->relation); + string_append_char(str, " RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + case OBJECT_TABLESPACE: + string_append_char(str, "TABLESPACE \""); + string_append_char(str, node->subname); + string_append_char(str, "\" RENAME TO \""); + string_append_char(str, node->newname); + string_append_char(str, "\""); + break; + + default: + break; + } +} + +static void +_outOptRoleList(String *str, List *options) +{ + ListCell *lc; + + foreach (lc, options) + { + DefElem *elem = lfirst(lc); + Value *value = (Value *) elem->arg; + + if (strcmp(elem->defname, "password") == 0) + { + if (value == NULL) + string_append_char(str, " PASSWORD NULL"); + else + { + string_append_char(str, " PASSWORD '"); + string_append_char(str, value->val.str); + string_append_char(str, "'"); + } + } + else if (strcmp(elem->defname, "encryptedPassword") == 0) + { + string_append_char(str, " ENCRYPTED PASSWORD '"); + string_append_char(str, value->val.str); + string_append_char(str, "'"); + } + else if (strcmp(elem->defname, "unencryptedPassword") == 0) + { + string_append_char(str, " UNENCRYPTED PASSWORD '"); + string_append_char(str, value->val.str); + string_append_char(str, "'"); + } + else if (strcmp(elem->defname, "superuser") == 0) + { + if (value->val.ival == TRUE) + string_append_char(str, " SUPERUSER"); + else + string_append_char(str, " NOSUPERUSER"); + } + else if (strcmp(elem->defname, "inherit") == 0) + { + if (value->val.ival == TRUE) + string_append_char(str, " INHERIT"); + else + string_append_char(str, " NOINHERIT"); + } + else if (strcmp(elem->defname, "createdb") == 0) + { + if (value->val.ival == TRUE) + string_append_char(str, " CREATEDB"); + else + string_append_char(str, " NOCREATEDB"); + } + else if (strcmp(elem->defname, "createrole") == 0) + { + if (value->val.ival == TRUE) + string_append_char(str, " CREATEROLE"); + else + string_append_char(str, " NOCREATEROLE"); + } + else if (strcmp(elem->defname, "canlogin") == 0) + { + if (value->val.ival == TRUE) + string_append_char(str, " LOGIN"); + else + string_append_char(str, " NOLOGIN"); + } + else if (strcmp(elem->defname, "connectionlimit") == 0) + { + char buf[16]; + + string_append_char(str, " CONNECTION LIMIT "); + snprintf(buf, 16, "%ld", value->val.ival); + string_append_char(str, buf); + } + else if (strcmp(elem->defname, "validUntil") == 0) + { + string_append_char(str, " VALID UNTIL '"); + string_append_char(str, value->val.str); + string_append_char(str, "'"); + } + else if (strcmp(elem->defname, "rolemembers") == 0) + { + string_append_char(str, " ROLE "); + _outIdList(str, (List *) elem->arg); + } + else if (strcmp(elem->defname, "sysid") == 0) + { + char buf[16]; + + string_append_char(str, " SYSID "); + snprintf(buf, 16, "%ld", value->val.ival); + string_append_char(str, buf); + } + else if (strcmp(elem->defname, "adminmembers") == 0) + { + string_append_char(str, " ADMIN "); + _outIdList(str, (List *) elem->arg); + } + else if (strcmp(elem->defname, "addroleto") == 0) + { + string_append_char(str, " IN ROLE "); + _outIdList(str, (List *) elem->arg); + } + } +} + +static void +_outCreateRoleStmt(String *str, CreateRoleStmt *node) +{ + string_append_char(str, "CREATE "); + switch (node->stmt_type) + { + case ROLESTMT_ROLE: + string_append_char(str, "ROLE \""); + break; + + case ROLESTMT_USER: + string_append_char(str, "USER \""); + break; + + case ROLESTMT_GROUP: + string_append_char(str, "GROUP \""); + break; + } + string_append_char(str, node->role); + string_append_char(str, "\""); + + _outOptRoleList(str, node->options); +} + +static void +_outAlterRoleStmt(String *str, AlterRoleStmt *node) +{ + string_append_char(str, "ALTER ROLE \""); + string_append_char(str, node->role); + string_append_char(str, "\""); + + if (node->options) + _outOptRoleList(str, node->options); +} + +static void +_outAlterRoleSetStmt(String *str, AlterRoleSetStmt *node) +{ + string_append_char(str, "ALTER ROLE \""); + string_append_char(str, node->role); + string_append_char(str, "\" "); + + if (node->setstmt) + { + _outNode(str, node->setstmt); + } +} + + +static void +_outSetTransactionModeList(String *str, List *list) +{ + ListCell *lc; + char comma = 0; + + foreach (lc, list) + { + DefElem *elem = lfirst(lc); + + if (comma == 0) + comma = 1; + else + string_append_char(str, ","); + + if (strcmp(elem->defname, "transaction_isolation") == 0) + { + A_Const *v = (A_Const *) elem->arg; + string_append_char(str, " ISOLATION LEVEL "); + string_append_char(str, v->val.val.str); + } + else if (strcmp(elem->defname, "transaction_read_only") == 0) + { + A_Const *n = (A_Const *) elem->arg; + if (n->val.val.ival == TRUE) + string_append_char(str, "READ ONLY "); + else + string_append_char(str, "READ WRITE "); + } + } +} + + +static void +_outSetRest(String *str, VariableSetStmt *node) +{ + if (strcmp(node->name, "timezone") == 0) + { + string_append_char(str, "TIME ZONE "); + if (node->kind != VAR_RESET) + _outNode(str, node->args); + } + else if (strcmp(node->name, "TRANSACTION") == 0) + { + string_append_char(str, "TRANSACTION "); + _outSetTransactionModeList(str, node->args); + } + else if (strcmp(node->name, "SESSION CHARACTERISTICS") == 0) + { + string_append_char(str, "SESSION CHARACTERISTICS AS TRANSACTION "); + _outSetTransactionModeList(str, node->args); + } + else if (strcmp(node->name, "role") == 0) + { + string_append_char(str, "ROLE "); + if (node->kind != VAR_RESET) + _outNode(str, node->args); + } + else if (strcmp(node->name, "session_authorization") == 0) + { + string_append_char(str, "SESSION AUTHORIZATION "); + if (node->args == NIL && node->kind != VAR_RESET) + string_append_char(str, "DEFAULT"); + else + _outNode(str, node->args); + } + else if (strcmp(node->name, "transaction_isolation") == 0) + { + string_append_char(str, "TRANSACTION ISOLATION LEVEL"); + if (node->kind != VAR_RESET) + _outSetTransactionModeList(str, node->args); + } + else if (strcmp(node->name, "xmloption") == 0) + { + A_Const *v = linitial(node->args); + string_append_char(str, "XML OPTOIN "); + string_append_char(str, v->val.val.str); + } + else + { + string_append_char(str, node->name); + if (node->kind != VAR_RESET) + { + if (node->kind == VAR_SET_CURRENT) + { + string_append_char(str, " FROM CURRENT"); + } + else + { + string_append_char(str, " TO "); + if (node->args == NULL) + { + string_append_char(str, "DEFAULT"); + } + else + _outNode(str, node->args); + } + } + } +} + +static void +_outDropRoleStmt(String *str, DropRoleStmt *node) +{ + string_append_char(str, "DROP ROLE "); + if (node->missing_ok == TRUE) + string_append_char(str, "IF EXISTS "); + _outIdList(str, node->roles); +} + +static void +_outCreateSchemaStmt(String *str, CreateSchemaStmt *node) +{ + string_append_char(str, "CREATE SCHEMA \""); + string_append_char(str, node->schemaname); + string_append_char(str, "\""); + if (node->authid) + { + string_append_char(str, "AUTHORIZATION \""); + string_append_char(str, node->authid); + string_append_char(str, "\" "); + } + _outNode(str, node->schemaElts); +} + +static void +_outVariableSetStmt(String *str, VariableSetStmt *node) +{ + if (node->kind == VAR_RESET_ALL) + { + string_append_char(str, "RESET ALL"); + return; + } + + if (node->kind == VAR_RESET) + string_append_char(str, "RESET "); + else + string_append_char(str, "SET "); + + if (node->is_local) + string_append_char(str, "LOCAL "); + + _outSetRest(str, node); +} + +static void +_outVariableShowStmt(String *str, VariableShowStmt *node) +{ + if (strcmp(node->name, "timezone") == 0) + string_append_char(str, "SHOW TIME ZONE"); + else if (strcmp(node->name, "transaction_isolation") == 0) + string_append_char(str, "SHOW TRANSACTION ISOLATION LEVEL"); + else if (strcmp(node->name, "session_authorization") == 0) + string_append_char(str, "SHOW SESSION AUTHORIZATION"); + else if (strcmp(node->name, "all") == 0) + string_append_char(str, "SHOW ALL"); + else + { + string_append_char(str, "SHOW "); + string_append_char(str, node->name); + } +} + +static void +_outConstraintsSetStmt(String *str, ConstraintsSetStmt *node) +{ + string_append_char(str, "SET CONSTRAINTS "); + + if (node->constraints == NIL) + string_append_char(str, "ALL"); + else + _outNode(str, node->constraints); + + string_append_char(str, node->deferred == TRUE ? " DEFERRED" : " IMMEDIATE"); +} + +static void +_outAlterTableCmd(String *str, AlterTableCmd *node) +{ + char buf[16]; + + switch (node->subtype) + { + case AT_AddColumn: + string_append_char(str, "ADD "); + _outNode(str, node->def); + break; + + case AT_ColumnDefault: + string_append_char(str, "ALTER \""); + string_append_char(str, node->name); + string_append_char(str, "\" "); + if (node->def == NULL) + string_append_char(str, "DROP DEFAULT"); + else + { + string_append_char(str, "SET DEFAULT "); + _outNode(str, node->def); + } + break; + + case AT_DropNotNull: + string_append_char(str, "ALTER \""); + string_append_char(str, node->name); + string_append_char(str, "\" DROP NOT NULL"); + break; + + case AT_SetNotNull: + string_append_char(str, "ALTER \""); + string_append_char(str, node->name); + string_append_char(str, "\" SET NOT NULL"); + break; + + case AT_SetStatistics: + string_append_char(str, "ALTER \""); + string_append_char(str, node->name); + string_append_char(str, "\" SET STATISTICS "); + snprintf(buf, 16, "%ld", ((Value *) node->def)->val.ival); + string_append_char(str, buf); + break; + + case AT_SetStorage: + string_append_char(str, "ALTER \""); + string_append_char(str, node->name); + string_append_char(str, "\" SET STORAGE "); + string_append_char(str, ((Value *) node->def)->val.str); + break; + + case AT_DropColumn: + string_append_char(str, "DROP \""); + string_append_char(str, node->name); + string_append_char(str, "\" "); + if (node->behavior == DROP_CASCADE) + string_append_char(str, "CASCADE"); + break; + + case AT_AlterColumnType: + string_append_char(str, "ALTER \""); + string_append_char(str, node->name); + string_append_char(str, "\" TYPE "); + _outNode(str, node->def); + if (node->transform) + { + string_append_char(str, " USING "); + _outNode(str, node->transform); + } + break; + + case AT_AddConstraint: + string_append_char(str, "ADD "); + _outNode(str, node->def); + break; + + case AT_DropConstraint: + string_append_char(str, "DROP CONSTRAINT \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); + break; + + case AT_DropOids: + string_append_char(str, "SET WITHOUT OIDS"); + break; + + case AT_ClusterOn: + string_append_char(str, "CLUSTER ON \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + break; + + case AT_DropCluster: + string_append_char(str, "SET WITHOUT CLUSTER"); + break; + + case AT_EnableTrig: + string_append_char(str, "ENABLE TRIGGER \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + break; + + case AT_EnableAlwaysTrig: + /* not implemented */ + break; + + case AT_EnableReplicaTrig: + /* not implemented */ + break; + + case AT_EnableTrigAll: + string_append_char(str, "ENABLE TRIGGER ALL"); + break; + + case AT_EnableTrigUser: + string_append_char(str, "ENABLE TRIGGER USER"); + break; + + case AT_DisableTrig: + string_append_char(str, "DISABLE TRIGGER \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + break; + + case AT_DisableTrigAll: + string_append_char(str, "DISABLE TRIGGER ALL"); + break; + + case AT_DisableTrigUser: + string_append_char(str, "DISABLE TRIGGER USER"); + break; + + case AT_EnableRule: + /* not implemented */ + break; + + case AT_EnableReplicaRule: + /* not implemented */ + break; + + case AT_EnableAlwaysRule: + /* not implemented */ + break; + + case AT_DisableRule: + /* not implemented */ + break; + + case AT_AddInherit: + /* not implemented */ + break; + + case AT_ChangeOwner: + string_append_char(str, "OWNER TO \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + break; + + case AT_SetTableSpace: + string_append_char(str, "SET TABLESPACE \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + break; + + case AT_SetRelOptions: + /* not implemented */ + break; + + case AT_ResetRelOptions: + /* not implemented */ + break; + + default: + break; + } +} + +static void +_outAlterTableStmt(String *str, AlterTableStmt *node) +{ + if (node->relkind == OBJECT_TABLE) + string_append_char(str, "ALTER TABLE "); + else + string_append_char(str, "ALTER INDEX "); + + _outNode(str, node->relation); + string_append_char(str, " "); + _outNode(str, node->cmds); +} + +static void +_outOptSeqList(String *str, List *options) +{ + ListCell *lc; + + foreach (lc, options) + { + DefElem *e = lfirst(lc); + Value *v = (Value *)e->arg; + char buf[16]; + + if (strcmp(e->defname, "cycle") == 0) + { + if (v->val.ival == TRUE) + string_append_char(str, " CYCLE"); + else + string_append_char(str, " NO CYCLE"); + } + else if (strcmp(e->defname, "minvalue") == 0 && !v) + string_append_char(str, " NO MINVALUE"); + else if (strcmp(e->defname, "maxvalue") == 0 && !v) + string_append_char(str, " NO MAXVALUE"); + else if (strcmp(e->defname, "owned_by") == 0) + { + string_append_char(str, " OWNED BY "); + _outIdList(str, (List *)e->arg); + } + else + { + if (strcmp(e->defname, "cache") == 0) + string_append_char(str, " CACHE "); + else if (strcmp(e->defname, "increment") == 0) + string_append_char(str, " INCREMENT "); + else if (strcmp(e->defname, "maxvalue") == 0 && v) + string_append_char(str, " MAXVALUE "); + else if (strcmp(e->defname, "minvalue") == 0 && v) + string_append_char(str, " MINVALUE "); + else if (strcmp(e->defname, "start") == 0) + string_append_char(str, " START "); + else if (strcmp(e->defname, "restart") == 0) + string_append_char(str, " RESTART "); + + if (IsA(e->arg, String)) + string_append_char(str, v->val.str); + else + { + snprintf(buf, 16, "%ld", v->val.ival); + string_append_char(str, buf); + } + } + } +} + +static void +_outCreateSeqStmt(String *str, CreateSeqStmt *node) +{ + string_append_char(str, "CREATE "); + if (node->sequence->istemp) + string_append_char(str, "TEMP "); + string_append_char(str, "SEQUENCE "); + _outNode(str, node->sequence); + + _outOptSeqList(str, node->options); +} + +static void +_outAlterSeqStmt(String *str, AlterSeqStmt *node) +{ + string_append_char(str, "ALTER SEQUENCE "); + _outNode(str, node->sequence); + _outOptSeqList(str, node->options); +} + +static void +_outCreatePLangStmt(String *str, CreatePLangStmt *node) +{ + string_append_char(str, "CREATE "); + if (node->pltrusted == true) + string_append_char(str, "TRUSTED "); + string_append_char(str, "LANGUAGE \""); + string_append_char(str, node->plname); + string_append_char(str, "\""); + + if (node->plhandler != NIL) + { + ListCell *lc; + char dot = 0; + + string_append_char(str, " HANDLER "); + foreach (lc, node->plhandler) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + string_append_char(str, "."); + + string_append_char(str, "\""); + string_append_char(str, v->val.str); + string_append_char(str, "\""); + } + } + + if (node->plvalidator != NIL) + { + ListCell *lc; + char dot = 0; + + string_append_char(str, " VALIDATOR "); + foreach (lc, node->plvalidator) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + string_append_char(str, "."); + + string_append_char(str, "\""); + string_append_char(str, v->val.str); + string_append_char(str, "\""); + } + } +} + +static void +_outDropPLangStmt(String *str, DropPLangStmt *node) +{ + string_append_char(str, "DROP LANGUAGE \""); + string_append_char(str, node->plname); + string_append_char(str, "\""); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outCreateTableSpaceStmt(String *str, CreateTableSpaceStmt *node) +{ + string_append_char(str, "CREATE TABLESPACE \""); + string_append_char(str, node->tablespacename); + string_append_char(str, "\" "); + + if (node->owner) + { + string_append_char(str, "OWNER \""); + string_append_char(str, node->owner); + string_append_char(str, "\" "); + } + + string_append_char(str, "LOCATION '"); + string_append_char(str, node->location); + string_append_char(str, "'"); +} + +static void +_outDropTableSpaceStmt(String *str, DropTableSpaceStmt *node) +{ + string_append_char(str, "DROP TABLESPACE \""); + string_append_char(str, node->tablespacename); + string_append_char(str, "\""); +} + +static void +_outFuncName(String *str, List *func_name) +{ + ListCell *lc; + Value *v; + char dot = 0; + + if (func_name == NULL) + return; + + foreach (lc, func_name) + { + v = (Value *) lfirst(lc); + + if (dot == 0) + dot = 1; + else + string_append_char(str, "."); + + if (IsA(v, String)) + { + string_append_char(str, "\""); + string_append_char(str, v->val.str); + string_append_char(str, "\""); + } + else + { + _outNode(str, v); + } + } +} + +static void +_outCreateTrigStmt(String *str, CreateTrigStmt *node) +{ + int i, len; + + if (node->isconstraint == TRUE) + string_append_char(str, "CREATE CONSTRAINT TRIGGER \""); + else + string_append_char(str, "CREATE TRIGGER \""); + string_append_char(str, node->trigname); + string_append_char(str, "\" "); + + if (node->before == TRUE) + string_append_char(str, "BEFORE "); + else + string_append_char(str, "AFTER "); + + len = strlen(node->actions); + for (i = 0; i < len; i++) + { + if (i) + string_append_char(str, "OR "); + + if (node->actions[i] == 'i') + string_append_char(str, "INSERT "); + else if (node->actions[i] == 'd') + string_append_char(str, "DELETE "); + else + string_append_char(str, "UPDATE "); + } + + string_append_char(str, "ON "); + _outNode(str, node->relation); + + if (node->constrrel) + { + string_append_char(str, " FROM "); + _outNode(str, node->constrrel); + } + + if (node->deferrable) + string_append_char(str, " DEFERRABLE"); + if (node->initdeferred) + string_append_char(str, " INITIALLY DEFERRED"); + + if (node->row == TRUE) + string_append_char(str, " FOR EACH ROW "); + else + string_append_char(str, " FOR EACH STATEMENT "); + + string_append_char(str, "EXECUTE PROCEDURE "); + + _outFuncName(str, node->funcname); + string_append_char(str, "("); + _outNode(str, node->args); + string_append_char(str, ")"); +} + +static void +_outDropPropertyStmt(String *str, DropPropertyStmt *node) +{ + switch (node->removeType) + { + case OBJECT_TRIGGER: + string_append_char(str, "DROP TRIGGER \""); + string_append_char(str, node->property); + string_append_char(str, "\" ON "); + _outNode(str, node->relation); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); + break; + + case OBJECT_RULE: + string_append_char(str, "DROP RULE \""); + string_append_char(str, node->property); + string_append_char(str, "\" ON "); + _outNode(str, node->relation); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); + break; + + default: + break; + } +} + +static void +_outDefinition(String *str, List *definition) +{ + ListCell *lc; + char comma = 0; + + if (definition == NIL) + return; + + string_append_char(str, "("); + foreach (lc, definition) + { + DefElem *e = lfirst(lc); + + if (comma == 0) + comma = 1; + else + string_append_char(str, ", "); + + string_append_char(str, "\""); + string_append_char(str, e->defname); + string_append_char(str, "\""); + + if (e->arg) + { + string_append_char(str, "="); + _outNode(str, e->arg); + } + } + string_append_char(str, ")"); +} + +static void +_outDefineStmt(String *str, DefineStmt *node) +{ + ListCell *lc; + char dot = 0; + + switch (node->kind) + { + case OBJECT_AGGREGATE: + string_append_char(str, "CREATE AGGREGATE "); + _outFuncName(str, node->defnames); + string_append_char(str, " "); + _outDefinition(str, node->definition); + break; + + case OBJECT_OPERATOR: + string_append_char(str, "CREATE OPERATOR "); + + foreach (lc, node->defnames) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + string_append_char(str, "."); + + string_append_char(str, v->val.str); + } + + string_append_char(str, " "); + _outDefinition(str, node->definition); + break; + + case OBJECT_TYPE: + string_append_char(str, "CREATE TYPE"); + _outFuncName(str, node->defnames); + string_append_char(str, " "); + _outDefinition(str, node->definition); + break; + + case OBJECT_TSPARSER: + string_append_char(str, "CREATE TEXT SEARCH PARSER "); + _outIdList(str, node->defnames); + _outDefinition(str, node->definition); + break; + + case OBJECT_TSDICTIONARY: + string_append_char(str, "CREATE TEXT SEARCH DICTIONARY "); + _outIdList(str, node->defnames); + _outDefinition(str, node->definition); + break; + + case OBJECT_TSTEMPLATE: + string_append_char(str, "CREATE TEXT SEARCH TEMPLATE "); + _outIdList(str, node->defnames); + _outDefinition(str, node->definition); + break; + + case OBJECT_TSCONFIGURATION: + string_append_char(str, "CREATE TEXT SEARCH CONFIGURATION "); + _outIdList(str, node->defnames); + _outDefinition(str, node->definition); + break; + + default: + break; + } +} + +static void +_outOperatorName(String *str, List *list) +{ + char dot = 0; + ListCell *lc; + + foreach (lc, list) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + string_append_char(str, "."); + + string_append_char(str, v->val.str); + } +} + +static void +_outCreateOpClassItem(String *str, CreateOpClassItem *node) +{ + char buf[16]; + + switch (node->itemtype) + { + case OPCLASS_ITEM_OPERATOR: + string_append_char(str, "OPERATOR "); + snprintf(buf, 16, "%d", node->number); + string_append_char(str, buf); + string_append_char(str, " "); + _outOperatorName(str, node->name); + + if (node->args != NIL) + { + string_append_char(str, "("); + _outNode(str, node->args); + string_append_char(str, ")"); + } + if (node->recheck == TRUE) + string_append_char(str, " RECHECK"); + break; + + case OPCLASS_ITEM_FUNCTION: + string_append_char(str, "FUNCTION "); + snprintf(buf, 16, "%d", node->number); + string_append_char(str, buf); + string_append_char(str, " "); + _outFuncName(str, node->name); + string_append_char(str, "("); + _outNode(str, node->args); + string_append_char(str, ")"); + break; + + case OPCLASS_ITEM_STORAGETYPE: + string_append_char(str, "STORAGE "); + _outNode(str, node->storedtype); + break; + + default: + break; + } + +} + +static void +_outCreateOpClassStmt(String *str, CreateOpClassStmt *node) +{ + string_append_char(str, "CREATE OPERATOR CLASS "); + _outFuncName(str, node->opclassname); + + if (node->isDefault == TRUE) + string_append_char(str, " DEFAULT"); + + string_append_char(str, " FOR TYPE "); + _outNode(str, node->datatype); + string_append_char(str, " USING "); + string_append_char(str, node->amname); + string_append_char(str, " AS "); + _outNode(str, node->items); +} + +static void +_outRemoveOpClassStmt(String *str, RemoveOpClassStmt *node) +{ + string_append_char(str, "DROP OPERATOR CLASS "); + _outFuncName(str, node->opclassname); + string_append_char(str, " USING "); + string_append_char(str, node->amname); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outDropStmt(String *str, DropStmt *node) +{ + ListCell *lc; + char comma = 0; + + string_append_char(str, "DROP "); + switch (node->removeType) + { + case OBJECT_TABLE: + string_append_char(str, "TABLE "); + break; + + case OBJECT_SEQUENCE: + string_append_char(str, "SEQUENCE "); + break; + + case OBJECT_VIEW: + string_append_char(str, "VIEW "); + break; + + case OBJECT_INDEX: + string_append_char(str, "INDEX "); + break; + + case OBJECT_TYPE: + string_append_char(str, "TYPE "); + break; + + case OBJECT_DOMAIN: + string_append_char(str, "DOMAIN "); + break; + + case OBJECT_CONVERSION: + string_append_char(str, "CONVERSION "); + break; + + case OBJECT_SCHEMA: + string_append_char(str, "SCHEMA "); + break; + + default: + break; + } + + foreach (lc, node->objects) + { + if (comma == 0) + comma = 1; + else + string_append_char(str, ", "); + _outFuncName(str, lfirst(lc)); + } + + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outFetchStmt(String *str, FetchStmt *node) +{ + char buf[16]; + + snprintf(buf, 16, "%ld", node->howMany); + + if (node->ismove == TRUE) + string_append_char(str, "MOVE "); + else + string_append_char(str, "FETCH "); + + switch (node->direction) + { + case FETCH_FORWARD: + string_append_char(str, "FORWARD "); + if (node->howMany == FETCH_ALL) + string_append_char(str, "ALL "); + else + { + string_append_char(str, buf); + string_append_char(str, " "); + } + break; + + case FETCH_BACKWARD: + string_append_char(str, "BACKWARD "); + if (node->howMany == FETCH_ALL) + string_append_char(str, "ALL "); + else + { + string_append_char(str, buf); + string_append_char(str, " "); + } + break; + + case FETCH_ABSOLUTE: + if (node->howMany == 1) + string_append_char(str, "FIRST "); + else if (node->howMany == -1) + string_append_char(str, "LAST "); + else + { + string_append_char(str, "ABSOLUTE "); + string_append_char(str, buf); + string_append_char(str, " "); + } + break; + + case FETCH_RELATIVE: + string_append_char(str, "RELATIVE "); + string_append_char(str, buf); + string_append_char(str, " "); + break; + } + + string_append_char(str, "IN \""); + string_append_char(str, node->portalname); + string_append_char(str, "\""); +} + +static void +_outPrivilegeList(String *str, List *list) +{ + ListCell *lc; + char comma = 0; + + if (list == NIL) + string_append_char(str, "ALL"); + else + { + foreach (lc, list) + { + Value *v = lfirst(lc); + + if (comma == 0) + comma = 1; + else + string_append_char(str, ", "); + + string_append_char(str, v->val.str); + } + } +} + +static void +_outFunctionParameter(String *str, FunctionParameter *node) +{ + switch (node->mode) + { + case FUNC_PARAM_OUT: + string_append_char(str, "OUT "); + break; + + case FUNC_PARAM_INOUT: + string_append_char(str, "INOUT "); + break; + + default: + break; + } + + /* function name */ + if (node->name) + { + string_append_char(str, "\""); + string_append_char(str, node->name); + string_append_char(str, "\" "); + } + + _outNode(str, node->argType); +} + +static void +_outFuncWithArgs(String *str, FuncWithArgs *node) +{ + _outFuncName(str, node->funcname); + string_append_char(str, "("); + _outNode(str, node->funcargs); + string_append_char(str, ")"); +} + +static void +_outPrivTarget(String *str, PrivTarget *node) +{ + switch (node->objtype) + { + case ACL_OBJECT_RELATION: + _outNode(str, node->objs); + break; + + case ACL_OBJECT_SEQUENCE: + string_append_char(str, "SEQUENCE "); + _outNode(str, node->objs); + break; + + case ACL_OBJECT_FUNCTION: + string_append_char(str, "FUNCTION "); + _outNode(str, node->objs); + break; + + case ACL_OBJECT_DATABASE: + string_append_char(str, "DATABASE "); + _outIdList(str, node->objs); + break; + + case ACL_OBJECT_LANGUAGE: + string_append_char(str, "LANGUAGE "); + _outIdList(str, node->objs); + break; + + case ACL_OBJECT_NAMESPACE: + string_append_char(str, "SCHEMA "); + _outIdList(str, node->objs); + break; + + case ACL_OBJECT_TABLESPACE: + string_append_char(str, "TABLESPACE "); + _outIdList(str, node->objs); + break; + } +} + +static void +_outPrivGrantee(String *str, PrivGrantee *node) +{ + if (node->rolname == NULL) + string_append_char(str, "PUBLIC"); + else + { + string_append_char(str, "\""); + string_append_char(str, node->rolname); + string_append_char(str, "\""); + } +} + +static void +_outGrantStmt(String *str, GrantStmt *node) +{ + PrivTarget *n; + + if (node->is_grant == true) + string_append_char(str, "GRANT "); + else + { + string_append_char(str, "REVOKE "); + if (node->grant_option == true) + string_append_char(str, "GRANT OPTION FOR "); + } + + _outPrivilegeList(str, node->privileges); + + string_append_char(str, " ON "); + + n = makeNode(PrivTarget); + n->objtype = node->objtype; + n->objs = node->objects; + _outNode(str, n); + pfree(n); + + if (node->is_grant == true) + string_append_char(str, " TO "); + else + string_append_char(str, " FROM "); + _outNode(str, node->grantees); + + if (node->is_grant == true && node->grant_option == TRUE) + string_append_char(str, " WITH GRANT OPTION"); + + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outGrantRoleStmt(String *str, GrantRoleStmt *node) +{ + if (node->is_grant == true) + string_append_char(str, "GRANT "); + else + { + string_append_char(str, "REVOKE "); + if (node->admin_opt == true) + string_append_char(str, "ADMIN OPTION FOR "); + } + + _outIdList(str, node->granted_roles); + + string_append_char(str, node->is_grant == true ? " TO " : " FROM "); + + _outIdList(str, node->grantee_roles); + + if (node->admin_opt == true && node->is_grant == true) + string_append_char(str, " WITH ADMIN OPTION"); + + if (node->grantor != NULL) + { + string_append_char(str, " GRANTED BY \""); + string_append_char(str, node->grantor); + string_append_char(str, "\""); + } + + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outFuncOptList(String *str, List *list) +{ + ListCell *lc; + + foreach (lc, list) + { + DefElem *e = lfirst(lc); + Value *v = (Value *) e->arg; + + if (strcmp(e->defname, "strict") == 0) + { + if (v->val.ival == TRUE) + string_append_char(str, " STRICT"); + else + string_append_char(str, " CALLED ON NULL INPUT"); + } + else if (strcmp(e->defname, "volatility") == 0) + { + char *s = v->val.str; + if (strcmp(s, "immutable") == 0) + string_append_char(str, " IMMUTABLE"); + else if (strcmp(s, "stable") == 0) + string_append_char(str, " STABLE"); + else if (strcmp(s, "volatile") == 0) + string_append_char(str, " VOLATILE"); + } + else if (strcmp(e->defname, "security") == 0) + { + if (v->val.ival == TRUE) + string_append_char(str, " SECURITY DEFINER"); + else + string_append_char(str, " SECURITY INVOKER"); + } + else if (strcmp(e->defname, "as") == 0) + { + string_append_char(str, " AS "); + _outNode(str, e->arg); + } + else if (strcmp(e->defname, "language") == 0) + { + string_append_char(str, " LANGUAGE '"); + string_append_char(str, v->val.str); + string_append_char(str, "'"); + } + } +} + +static void +_outCreateFunctionStmt(String *str, CreateFunctionStmt *node) +{ + string_append_char(str, "CREATE "); + if (node->replace == true) + string_append_char(str, "OR REPLACE "); + string_append_char(str, "FUNCTION "); + + _outFuncName(str, node->funcname); + + string_append_char(str, " ("); + _outNode(str, node->parameters); + string_append_char(str, ")"); + + if (node->returnType) + { + string_append_char(str, " RETURNS "); + _outNode(str, node->returnType); + } + + _outFuncOptList(str, node->options); + + if (node->withClause) + { + string_append_char(str, " WITH "); + _outDefinition(str, node->withClause); + } +} + +static void +_outAlterFunctionStmt(String *str, AlterFunctionStmt *node) +{ + string_append_char(str, "ALTER FUNCTION "); + _outNode(str, node->func); + _outFuncOptList(str, node->actions); +} + +static void +_outRemoveFuncStmt(String *str, RemoveFuncStmt *node) +{ + switch (node->kind) + { + case OBJECT_FUNCTION: + string_append_char(str, "DROP FUNCTION "); + break; + + + case OBJECT_AGGREGATE: + string_append_char(str, "DROP AGGREGATE "); + break; + + case OBJECT_OPERATOR: + string_append_char(str, "DROP OPERATOR CLASS "); + break; + + default: + break; + } + + if (node->missing_ok) + string_append_char(str, "IF EXISTS "); + + _outFuncName(str, node->name); + + string_append_char(str, " ("); + _outNode(str, node->args); + string_append_char(str, ")"); + + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outCreateCastStmt(String *str, CreateCastStmt *node) +{ + string_append_char(str, "CREATE CAST ("); + _outNode(str, node->sourcetype); + string_append_char(str, " AS "); + _outNode(str, node->targettype); + string_append_char(str, ") WITH FUNCTION "); + _outNode(str, node->func); + + switch (node->context) + { + case COERCION_IMPLICIT: + string_append_char(str, " AS IMPLICIT"); + break; + + case COERCION_ASSIGNMENT: + string_append_char(str, " AS ASSIGNMENT"); + break; + + default: + break; + } +} + +static void +_outDropCastStmt(String *str, DropCastStmt *node) +{ + string_append_char(str, "DROP CAST ("); + _outNode(str, node->sourcetype); + string_append_char(str, " AS "); + _outNode(str, node->targettype); + string_append_char(str, ")"); + + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outReindexStmt(String *str, ReindexStmt *node) +{ + string_append_char(str, "REINDEX "); + + switch (node->kind) + { + case OBJECT_DATABASE: + if (node->do_system == true && node->do_user == false) + string_append_char(str, "SYSTEM "); + else + string_append_char(str, "DATABASE "); + break; + + case OBJECT_INDEX: + string_append_char(str, "INDEX "); + break; + + case OBJECT_TABLE: + string_append_char(str, "TABLE "); + break; + + default: + break; + } + + if (node->relation) + _outNode(str, node->relation); + + if (node->name) + { + string_append_char(str, "\""); + string_append_char(str, (char *) node->name); + string_append_char(str, "\""); + } +} + +static void +_outAlterObjectSchemaStmt(String *str, AlterObjectSchemaStmt *node) +{ + string_append_char(str, "ALTER "); + + switch (node->objectType) + { + case OBJECT_AGGREGATE: + string_append_char(str, "AGGREGATE "); + _outFuncName(str, node->object); + string_append_char(str, "("); + if (lfirst(list_head(node->objarg)) == NULL) + string_append_char(str, "*"); + else + _outNode(str, lfirst(list_head(node->objarg))); + string_append_char(str, ") SET SCHAME \""); + string_append_char(str, node->newschema); + string_append_char(str, "\""); + break; + + case OBJECT_DOMAIN: + string_append_char(str, "DOMAIN "); + _outFuncName(str, node->object); + string_append_char(str, " SET SCHEMA \""); + string_append_char(str, node->newschema); + string_append_char(str, "\""); + break; + + case OBJECT_FUNCTION: + string_append_char(str, "FUNCTION "); + _outFuncName(str, node->object); + string_append_char(str, "("); + _outNode(str, node->objarg); + string_append_char(str, ") SET SCHEMA \""); + string_append_char(str, node->newschema); + string_append_char(str, "\""); + break; + + case OBJECT_SEQUENCE: + string_append_char(str, "SEQUENCE "); + _outNode(str, node->relation); + string_append_char(str, " SET SCHEMA \""); + string_append_char(str, node->newschema); + string_append_char(str, "\""); + break; + + case OBJECT_TABLE: + string_append_char(str, "TABLE "); + _outNode(str, node->relation); + string_append_char(str, " SET SCHEMA \""); + string_append_char(str, node->newschema); + string_append_char(str, "\""); + break; + + case OBJECT_TYPE: + string_append_char(str, "TYPE "); + _outFuncName(str, node->object); + string_append_char(str, " SET SCHEMA \""); + string_append_char(str, node->newschema); + string_append_char(str, "\""); + break; + + default: + break; + } +} + +static void +_outAlterOwnerStmt(String *str, AlterOwnerStmt *node) +{ + string_append_char(str, "ALTER "); + + switch (node->objectType) + { + case OBJECT_AGGREGATE: + string_append_char(str, "AGGREGATE "); + _outFuncName(str, node->object); + string_append_char(str, "("); + if (lfirst(list_head(node->objarg)) == NULL) + string_append_char(str, "*"); + else + _outNode(str, lfirst(list_head(node->objarg))); + string_append_char(str, ") OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_CONVERSION: + string_append_char(str, "CONVERSION "); + _outFuncName(str, node->object); + string_append_char(str, " OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_DATABASE: + string_append_char(str, "DATABASE \""); + _outIdList(str, node->object); + string_append_char(str, "\" OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_DOMAIN: + string_append_char(str, "DOMAIN "); + _outFuncName(str, node->object); + string_append_char(str, " OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_FUNCTION: + string_append_char(str, "FUNCTION "); + _outFuncName(str, node->object); + string_append_char(str, "("); + _outNode(str, node->objarg); + string_append_char(str, ") OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_OPERATOR: + string_append_char(str, "OPERATOR "); + _outOperatorName(str, node->object); + string_append_char(str, "("); + _outOperatorArgTypes(str, node->objarg); + string_append_char(str, ") OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_OPCLASS: + string_append_char(str, "OPERATOR CLASS "); + _outFuncName(str, node->object); + string_append_char(str, " USING "); + string_append_char(str, node->addname); + string_append_char(str, " OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_SCHEMA: + string_append_char(str, "SCHEMA \""); + string_append_char(str, linitial(node->object)); + string_append_char(str, "\" OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_TYPE: + string_append_char(str, "TYPE "); + _outFuncName(str, node->object); + string_append_char(str, " OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + case OBJECT_TABLESPACE: + string_append_char(str, "TABLESPACE \""); + string_append_char(str, linitial(node->object)); + string_append_char(str, "\" OWNER TO \""); + string_append_char(str, node->newowner); + string_append_char(str, "\""); + break; + + default: + break; + } +} + +static void +_outRuleStmt(String *str, RuleStmt *node) +{ + string_append_char(str, "CREATE "); + if (node->replace) + string_append_char(str, "OR REPLACE "); + string_append_char(str, "RULE \""); + string_append_char(str, node->rulename); + string_append_char(str, "\" AS ON "); + + switch (node->event) + { + case CMD_SELECT: + string_append_char(str, "SELECT"); + break; + + case CMD_UPDATE: + string_append_char(str, "UPDATE"); + break; + + case CMD_DELETE: + string_append_char(str, "DELETE"); + break; + + case CMD_INSERT: + string_append_char(str, "INSERT"); + break; + + default: + break; + } + + string_append_char(str, " TO "); + _outNode(str, node->relation); + + if (node->whereClause) + { + string_append_char(str, " WHERE "); + _outNode(str, node->whereClause); + } + + string_append_char(str, " DO "); + + if (node->instead) + string_append_char(str, "INSTEAD "); + + if (node->actions == NIL) + string_append_char(str, "NOTHING"); + else if (list_length(node->actions) == 1) + _outNode(str, linitial(node->actions)); + else + { + ListCell *lc; + char semi = 0; + + string_append_char(str, "("); + + foreach (lc, node->actions) + { + if (semi == 0) + semi = 1; + else + string_append_char(str, ";"); + + _outNode(str, lfirst(lc)); + } + + string_append_char(str, ")"); + } +} + +static void +_outViewStmt(String *str, ViewStmt *node) +{ + if (node->replace) + string_append_char(str, "CREATE OR REPLACE "); + else + string_append_char(str, "CREATE "); + + if (node->view->istemp == TRUE) + string_append_char(str, "TEMP "); + + string_append_char(str, "VIEW "); + _outNode(str, node->view); + + if (node->aliases) + { + string_append_char(str, "("); + _outIdList(str, node->aliases); + string_append_char(str, ")"); + } + + string_append_char(str, " AS"); + _outNode(str, node->query); +} + +static void +_outCreatedbOptList(String *str, List *options) +{ + ListCell *lc; + + foreach (lc, options) + { + DefElem *e = lfirst(lc); + Value *v = (Value *) e->arg; + int sconst = false; + + /* keyword */ + if (strcmp(e->defname, "template") == 0) + string_append_char(str, " TEMPLATE "); + else if (strcmp(e->defname, "location") == 0) + { + string_append_char(str, " LOCATION "); + sconst = true; + } + else if (strcmp(e->defname, "tablespace") == 0) + string_append_char(str, " TABLESPACE "); + else if (strcmp(e->defname, "encoding") == 0) + { + string_append_char(str, " ENCODING "); + sconst = true; + } + else if (strcmp(e->defname, "owner") == 0) + string_append_char(str, " OWNER "); + else if (strcmp(e->defname, "connectionlimit") == 0) + string_append_char(str, " CONNECTION LIMIT "); + + /* value */ + if (v == NULL) + string_append_char(str, "DEFAULT"); + else if (IsA((Node *)v, String)) + { + string_append_char(str, sconst ? "'" : "'"); + string_append_char(str, v->val.str); + string_append_char(str, sconst ? "'" : "'"); + } + else + { + char buf[16]; + snprintf(buf, 16, "%ld", v->val.ival); + string_append_char(str, buf); + } + } +} + +static void +_outCreatedbStmt(String *str, CreatedbStmt *node) +{ + string_append_char(str, "CREATE DATABASE \""); + string_append_char(str, node->dbname); + string_append_char(str, "\""); + + _outCreatedbOptList(str, node->options); +} + +static void +_outAlterDatabaseStmt(String *str, AlterDatabaseStmt *node) +{ + string_append_char(str, "ALTER DATABASE \""); + string_append_char(str, node->dbname); + string_append_char(str, "\" "); + + _outCreatedbOptList(str, node->options); +} + +static void +_outAlterDatabaseSetStmt(String *str, AlterDatabaseSetStmt *node) +{ + string_append_char(str, "ALTER DATABASE \""); + string_append_char(str, node->dbname); + string_append_char(str, "\" "); + + _outNode(str, node->setstmt); +} + +static void +_outDropdbStmt(String *str, DropdbStmt *node) +{ + string_append_char(str, "DROP DATABASE \""); + string_append_char(str, node->dbname); + string_append_char(str, "\""); +} + +static void +_outCreateDomainStmt(String *str, CreateDomainStmt *node) +{ + ListCell *lc; + + string_append_char(str, "CREATE DOMAIN "); + _outFuncName(str, node->domainname); + string_append_char(str, " "); + _outNode(str, node->typename); + + + foreach (lc, node->constraints) + { + string_append_char(str, " "); + _outNode(str, lfirst(lc)); + } +} + +static void +_outAlterDomainStmt(String *str, AlterDomainStmt *node) +{ + string_append_char(str, "ALTER DOMAIN "); + _outFuncName(str, node->typename); + + switch (node->subtype) + { + case 'T': + if (node->def) + { + string_append_char(str, " SET DEFAULT "); + _outNode(str, node->def); + } + else + string_append_char(str, " DROP DEFAULT"); + break; + + case 'N': + string_append_char(str, " DROP NOT NULL"); + break; + + case 'O': + string_append_char(str, " SET NOT NULL"); + break; + + case 'C': + string_append_char(str, " ADD "); + _outNode(str, node->def); + break; + + case 'X': + string_append_char(str, " DROP CONSTRAINT \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); + break; + } +} + +static void +_outCreateConversionStmt(String *str, CreateConversionStmt *node) +{ + string_append_char(str, "CREATE "); + + if (node->def == TRUE) + string_append_char(str, "DEFAULT "); + + string_append_char(str, "CONVERSION "); + + _outFuncName(str, node->conversion_name); + + string_append_char(str, " FOR '"); + string_append_char(str, node->for_encoding_name); + string_append_char(str, "' TO '"); + string_append_char(str, node->to_encoding_name); + string_append_char(str, " FROM "); + _outFuncName(str, node->func_name); +} + +static void +_outPrepareStmt(String *str, PrepareStmt *node) +{ + string_append_char(str, "PREPARE \""); + string_append_char(str, node->name); + string_append_char(str, "\" "); + + if (node->argtypes != NIL) + { + string_append_char(str, "("); + _outNode(str, node->argtypes); + string_append_char(str, ") "); + } + + string_append_char(str, "AS "); + _outNode(str, node->query); +} + +static void +_outExecuteStmt(String *str, ExecuteStmt *node) +{ + if (node->into) + { + IntoClause *into = node->into; + RangeVar *rel = into->rel; + + string_append_char(str, "CREATE "); + if (rel->istemp == TRUE) + string_append_char(str, "TEMP "); + string_append_char(str, "TABLE "); + _outNode(str, into->rel); + string_append_char(str, " AS "); + } + + string_append_char(str, "EXECUTE \""); + string_append_char(str, node->name); + string_append_char(str, "\" "); + + if (node->params != NIL) + { + string_append_char(str, "("); + _outNode(str, node->params); + string_append_char(str, ")"); + } +} + +static void +_outLockStmt(String *str, LockStmt *node) +{ + string_append_char(str, "LOCK TABLE "); + _outNode(str, node->relations); + + string_append_char(str, " IN "); + switch (node->mode) + { + case AccessShareLock: + string_append_char(str, "ACCESS SHARE "); + break; + + case RowShareLock: + string_append_char(str, "ROW SHARE "); + break; + + case RowExclusiveLock: + string_append_char(str, "ROW EXCLUSIVE "); + break; + + case ShareUpdateExclusiveLock: + string_append_char(str, "SHARE UPDATE EXCLUSIVE "); + break; + + case ShareLock: + string_append_char(str, "SHARE "); + break; + + case ShareRowExclusiveLock: + string_append_char(str, "SHARE ROW EXCLUSIVE "); + break; + + case ExclusiveLock: + string_append_char(str, "EXCLUSIVE "); + break; + + case AccessExclusiveLock: + string_append_char(str, "ACCESS EXCLUSIVE "); + break; + } + string_append_char(str, "MODE"); + + if (node->nowait == TRUE) + string_append_char(str, " NOWAIT"); +} + +static void +_outOperatorArgTypes(String *str, List *args) +{ + TypeName *left, *right; + + left = linitial(args); + right = lsecond(args); + + if (left) + _outNode(str, left); + else + string_append_char(str, "NONE"); + string_append_char(str, ", "); + if (right) + _outNode(str, right); + else + string_append_char(str, "NONE"); +} + +static void +_outCommentStmt(String *str, CommentStmt *node) +{ + TypeName *t; + Value *v; + char buf[16]; + + string_append_char(str, "COMMENT ON "); + + switch (node->objtype) + { + case OBJECT_AGGREGATE: + string_append_char(str, "AGGREGATE "); + _outFuncName(str, node->objname); + string_append_char(str, "("); + + t = linitial(node->objargs); + if (t) + _outNode(str, t); + else + string_append_char(str, "*"); + string_append_char(str, ")"); + break; + + case OBJECT_FUNCTION: + string_append_char(str, "FUNCTION "); + _outFuncName(str, node->objname); + string_append_char(str, "("); + _outNode(str, node->objargs); + string_append_char(str, ")"); + break; + + case OBJECT_OPERATOR: + string_append_char(str, "OPERATOR "); + _outOperatorName(str, node->objname); + string_append_char(str, "("); + _outOperatorArgTypes(str, node->objargs); + string_append_char(str, ")"); + break; + + case OBJECT_CONSTRAINT: + string_append_char(str, "CONSTRAINT \""); + v = lsecond(node->objname); + string_append_char(str, v->val.str); + string_append_char(str, "\" ON "); + _outFuncName(str, linitial(node->objargs)); + break; + + case OBJECT_RULE: + string_append_char(str, "RULE \""); + v = lsecond(node->objname); + string_append_char(str, v->val.str); + string_append_char(str, "\" ON "); + _outFuncName(str, linitial(node->objargs)); + break; + + case OBJECT_TRIGGER: + string_append_char(str, "TRIGGER \""); + v = lsecond(node->objname); + string_append_char(str, v->val.str); + string_append_char(str, "\" ON "); + _outFuncName(str, linitial(node->objargs)); + break; + + case OBJECT_OPCLASS: + string_append_char(str, "OPERATOR CLASS "); + _outFuncName(str, node->objname); + string_append_char(str, " USING "); + v = linitial(node->objargs); + string_append_char(str, v->val.str); + break; + + case OBJECT_LARGEOBJECT: + string_append_char(str, "LARGE OBJECT "); + v = linitial(node->objname); + if (IsA(v, String)) + string_append_char(str, v->val.str); + else if (IsA(v, Integer)) + { + snprintf(buf, 16, "%ld", v->val.ival); + string_append_char(str, buf); + } + + case OBJECT_CAST: + string_append_char(str, "CAST ("); + _outNode(str, linitial(node->objname)); + string_append_char(str, " AS "); + _outNode(str, linitial(node->objargs)); + string_append_char(str, ")"); + break; + + case OBJECT_LANGUAGE: + string_append_char(str, "LANGUAGE "); + _outFuncName(str, node->objname); + break; + + default: + switch (node->objtype) + { + case OBJECT_COLUMN: + string_append_char(str, "COLUMN "); + break; + case OBJECT_DATABASE: + string_append_char(str, "DATABASE "); + break; + case OBJECT_SCHEMA: + string_append_char(str, "SCHEMA "); + break; + case OBJECT_INDEX: + string_append_char(str, "INDEX "); + break; + case OBJECT_SEQUENCE: + string_append_char(str, "SEQUENCE "); + break; + case OBJECT_TABLE: + string_append_char(str, "TABLE "); + break; + case OBJECT_DOMAIN: + string_append_char(str, "DOMAIN "); + break; + case OBJECT_TYPE: + string_append_char(str, "TYPE "); + break; + case OBJECT_VIEW: + string_append_char(str, "VIEW "); + break; + default: + break; + } + _outFuncName(str, node->objname); + break; + } + + string_append_char(str, " IS "); + if (node->comment) + { + string_append_char(str, "'"); + string_append_char(str, node->comment); + string_append_char(str, "'"); + } + else + string_append_char(str, "NULL"); +} + +static void +_outRangeSubselect(String *str, RangeSubselect *node) +{ + string_append_char(str, "("); + _outNode(str, node->subquery); + string_append_char(str, ")"); + + _outNode(str, node->alias); +} + +static void +_outRangeFunction(String *str, RangeFunction *node) +{ + _outNode(str, node->funccallnode); + if (node->alias) + { + _outNode(str, node->alias); + } + + if (node->coldeflist) + { + string_append_char(str, " ("); + _outNode(str, node->coldeflist); + string_append_char(str, ")"); + } +} + +static void +_outDiscardStmt(String *str, DiscardStmt *node) +{ + switch (node->target) + { + case DISCARD_ALL: + string_append_char(str, "DISCARD ALL"); + break; + + case DISCARD_TEMP: + string_append_char(str, "DISCARD TEMP"); + break; + + case DISCARD_PLANS: + string_append_char(str, "DISCARD PLANS"); + break; + + default: + break; + } +} + +static void +_outCreateOpFamilyStmt(String *str, CreateOpFamilyStmt *node) +{ + string_append_char(str, "CREATE OPERATOR FAMILY "); + _outIdList(str, node->opfamilyname); + string_append_char(str, " USING \""); + string_append_char(str, node->amname); + string_append_char(str, "\""); +} + +static void +_outAlterOpFamilyStmt(String *str, AlterOpFamilyStmt *node) +{ +} + +static void +_outRemoveOpFamilyStmt(String *str, RemoveOpFamilyStmt *node) +{ + string_append_char(str, "DROP OPERATOR FAMILY "); + if (node->missing_ok) + string_append_char(str, "IF EXISTS "); + _outIdList(str, node->opfamilyname); + string_append_char(str, " USING \""); + string_append_char(str, node->amname); + string_append_char(str, "\""); +} + +static void +_outCreateEnumStmt(String *str, CreateEnumStmt *node) +{ + string_append_char(str, "CREATE TYPE "); + _outIdList(str, node->typename); + string_append_char(str, " AS ENUM ("); + _outNode(str, node->vals); + string_append_char(str, ")"); +} + +static void +_outDropOwnedStmt(String *str, DropOwnedStmt *node) +{ + string_append_char(str, "DROP OWNED BY "); + _outIdList(str, node->roles); + if (node->behavior == DROP_CASCADE) + string_append_char(str, " CASCADE"); +} + +static void +_outReassignOwnedStmt(String *str, ReassignOwnedStmt *node) +{ + string_append_char(str, "REASSIGN OWNED BY "); + _outIdList(str, node->roles); + string_append_char(str, " TO \""); + string_append_char(str, node->newrole); + string_append_char(str, "\""); +} + +static void +_outAlterTSDictionaryStmt(String *str, AlterTSDictionaryStmt *node) +{ + string_append_char(str, "ALTER TEXT SEARCH DICTIONARY "); + _outIdList(str, node->dictname); + string_append_char(str, "("); + _outNode(str, node->options); + string_append_char(str, ")"); +} + +static void +_outAlterTSConfigurationStmt(String *str, AlterTSConfigurationStmt *node) +{ + string_append_char(str, "ALTER TEXT SEARCH CONFIGURATION "); + _outIdList(str, node->cfgname); + if (node->override == false && node->replace == false) + { + string_append_char(str, "ADD MAPPING FOR "); + _outIdList(str, node->tokentype); + string_append_char(str, " WITH "); + _outIdList(str, node->dicts); + } + else if (node->override == true && node->replace == false) + { + string_append_char(str, "ALTER MAPPING FOR "); + _outIdList(str, node->tokentype); + string_append_char(str, " WITH "); + _outIdList(str, node->dicts); + } + else if (node->override == false && node->replace == true) + { + if (node->tokentype == NIL) + string_append_char(str, "ALTER MAPPING "); + else + { + string_append_char(str, "ALTER MAPPING FOR "); + _outIdList(str, node->tokentype); + } + string_append_char(str, "REPLACE "); + _outNode(str, linitial(node->dicts)); + string_append_char(str, " WITH "); + _outNode(str, lsecond(node->dicts)); + } + else if (node->missing_ok == false) + { + string_append_char(str, " DROP MAPPING FOR "); + _outIdList(str, node->tokentype); + } + else if (node->missing_ok == true) + { + string_append_char(str, " DROP MAPPING IF EXISTS FOR "); + _outIdList(str, node->tokentype); + } +} + +static void +_outXmlExpr(String *str, XmlExpr *node) +{ + A_Const *n; + + switch (node->op) + { + case IS_DOCUMENT: + _outNode(str, node->args); + string_append_char(str, " IS DOCUMENT"); + break; + + case IS_XMLCONCAT: + string_append_char(str, "XMLCONCAT ("); + _outNode(str, node->args); + string_append_char(str, ")"); + break; + + case IS_XMLELEMENT: + string_append_char(str, "XMLELEMENT ("); + if (node->name) + { + string_append_char(str, "NAME \""); + string_append_char(str, node->name); + string_append_char(str, "\""); + if (node->named_args != NIL) + { + string_append_char(str, ","); + _outIdList(str, node->named_args); + } + } + if (node->args != NIL) + { + string_append_char(str, ","); + _outNode(str, node->args); + } + string_append_char(str, ")"); + break; + + case IS_XMLFOREST: + string_append_char(str, "XMLFOREST ("); + _outNode(str, node->named_args); + string_append_char(str, ")"); + break; + + case IS_XMLPARSE: + string_append_char(str, "XMLPARSE ("); + if (node->xmloption == XMLOPTION_DOCUMENT) + string_append_char(str, "DOCUMENT "); + else + string_append_char(str, "CONTENT "); + + _outNode(str, linitial(node->args)); + n = lsecond(node->args); + if (n->val.val.str[0] == 't') + string_append_char(str, " PRESERVE WHITESPACE"); + + string_append_char(str, ")"); + break; + + + default: + break; + } +} + +static void +_outXmlSerialize(String *str, XmlSerialize *node) +{ + +} + +static void +_outInhRelation(String *str, InhRelation *node) +{ + ListCell *lc; + + string_append_char(str, "LIKE "); + _outNode(str, node->relation); + foreach (lc, node->options) + { + CreateStmtLikeOption v; + v = (CreateStmtLikeOption)lfirst(lc); + + switch (v) + { + case CREATE_TABLE_LIKE_INCLUDING_DEFAULTS: + string_append_char(str, " INCLUDING DEFAULTS"); + break; + + case CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS: + string_append_char(str, " EXCLUDING DEFAULTS"); + break; + + case CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS: + string_append_char(str, " INCLUDING CONSTRAINTS"); + break; + + case CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS: + string_append_char(str, " EXCLUDING CONSTRAINTS"); + break; + + case CREATE_TABLE_LIKE_INCLUDING_INDEXES: + string_append_char(str, " INCLUDING INDEXES"); + break; + + case CREATE_TABLE_LIKE_EXCLUDING_INDEXES: + string_append_char(str, " EXCLUDING INDEXES"); + break; + + default: + break; + } + } +} + +static void +_outWithDefinition(String *str, List *def_list) +{ + int oid = 0; + + if (list_length(def_list) == 1) + { + DefElem *elem; + Value *v; + + elem = linitial(def_list); + v = (Value *)elem->arg; + if (strcmp(elem->defname, "oids") == 0) + { + Value *v = (Value *)elem->arg; + if (v->val.ival == 1) + string_append_char(str, " WITH OIDS "); + else + string_append_char(str, " WITHOUT OIDS "); + oid = 1; + } + } + + if (oid == 1) + return; + + string_append_char(str, " WITH "); + _outDefinition(str, def_list); +} + +static void +_outCurrentOfExpr(String *str, CurrentOfExpr *node) +{ + string_append_char(str, "CURRENT OF "); + if (node->cursor_name == NULL) + { + char n[10]; + snprintf(n, sizeof(n), "$%d", node->cursor_param); + string_append_char(str, n); + } + else + string_append_char(str, node->cursor_name); +} + +/* + * _outNode - + * converts a Node into ascii string and append it to 'str' + */ +void +_outNode(String *str, void *obj) +{ + if (obj == NULL) + return; + else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList)) + _outList(str, obj); + else if (IsA(obj, Integer) || + IsA(obj, Float) || + IsA(obj, String) || + IsA(obj, BitString)) + { + /* nodeRead does not want to see { } around these! */ + _outValue(str, obj); + } + else + { + switch (nodeTag(obj)) + { + case T_Alias: + _outAlias(str, obj); + break; + case T_RangeVar: + _outRangeVar(str, obj); + break; + case T_Var: + _outVar(str, obj); + break; + case T_Const: + _outConst(str, obj); + break; + case T_Param: + _outParam(str, obj); + break; + case T_Aggref: + _outAggref(str, obj); + break; + case T_ArrayRef: + _outArrayRef(str, obj); + break; + case T_FuncExpr: + _outFuncExpr(str, obj); + break; + case T_OpExpr: + _outOpExpr(str, obj); + break; + case T_DistinctExpr: + _outDistinctExpr(str, obj); + break; + case T_ScalarArrayOpExpr: + _outScalarArrayOpExpr(str, obj); + break; + case T_BoolExpr: + _outBoolExpr(str, obj); + break; + case T_SubLink: + _outSubLink(str, obj); + break; + case T_SubPlan: + _outSubPlan(str, obj); + break; + case T_FieldSelect: + _outFieldSelect(str, obj); + break; + case T_FieldStore: + _outFieldStore(str, obj); + break; + case T_RelabelType: + _outRelabelType(str, obj); + break; + case T_ConvertRowtypeExpr: + _outConvertRowtypeExpr(str, obj); + break; + case T_CaseExpr: + _outCaseExpr(str, obj); + break; + case T_CaseWhen: + _outCaseWhen(str, obj); + break; + case T_CaseTestExpr: + _outCaseTestExpr(str, obj); + break; + case T_ArrayExpr: + _outArrayExpr(str, obj); + break; + case T_RowExpr: + _outRowExpr(str, obj); + break; + case T_CoalesceExpr: + _outCoalesceExpr(str, obj); + break; + case T_MinMaxExpr: + _outMinMaxExpr(str, obj); + break; + case T_NullIfExpr: + _outNullIfExpr(str, obj); + break; + case T_NullTest: + _outNullTest(str, obj); + break; + case T_BooleanTest: + _outBooleanTest(str, obj); + break; + case T_CoerceToDomain: + _outCoerceToDomain(str, obj); + break; + case T_CoerceToDomainValue: + _outCoerceToDomainValue(str, obj); + break; + case T_SetToDefault: + _outSetToDefault(str, obj); + break; + case T_TargetEntry: + _outTargetEntry(str, obj); + break; + case T_RangeTblRef: + _outRangeTblRef(str, obj); + break; + case T_JoinExpr: + _outJoinExpr(str, obj); + break; + case T_FromExpr: + _outFromExpr(str, obj); + break; + + case T_CreateStmt: + _outCreateStmt(str, obj); + break; + case T_IndexStmt: + _outIndexStmt(str, obj); + break; + case T_NotifyStmt: + _outNotifyStmt(str, obj); + break; + case T_DeclareCursorStmt: + _outDeclareCursorStmt(str, obj); + break; + case T_SelectStmt: + _outSelectStmt(str, obj); + break; + case T_ColumnDef: + _outColumnDef(str, obj); + break; + case T_TypeName: + _outTypeName(str, obj); + break; + case T_TypeCast: + _outTypeCast(str, obj); + break; + case T_IndexElem: + _outIndexElem(str, obj); + break; + case T_SortClause: + _outSortClause(str, obj); + break; + case T_GroupClause: + _outGroupClause(str, obj); + break; + case T_SetOperationStmt: + _outSetOperationStmt(str, obj); + break; +/* case T_RangeTblEntry: + _outRangeTblEntry(str, obj); + break;*/ + case T_A_Expr: + _outAExpr(str, obj); + break; + case T_ColumnRef: + _outColumnRef(str, obj); + break; + case T_ParamRef: + _outParamRef(str, obj); + break; + case T_A_Const: + _outAConst(str, obj); + break; + case T_A_Indices: + _outA_Indices(str, obj); + break; + case T_A_Indirection: + _outA_Indirection(str, obj); + break; + case T_ResTarget: + _outResTarget(str, obj); + break; + case T_Constraint: + _outConstraint(str, obj); + break; + case T_FkConstraint: + _outFkConstraint(str, obj); + break; + case T_FuncCall: + _outFuncCall(str, obj); + break; + case T_DefElem: + _outDefElem(str, obj); + break; + case T_LockingClause: + _outLockingClause(str, obj); + break; + + case T_SortBy: + _outSortBy(str, obj); + break; + + case T_InsertStmt: + _outInsertStmt(str, obj); + break; + + case T_UpdateStmt: + _outUpdateStmt(str, obj); + break; + + case T_DeleteStmt: + _outDeleteStmt(str, obj); + break; + + case T_TransactionStmt: + _outTransactionStmt(str, obj); + break; + + case T_TruncateStmt: + _outTruncateStmt(str, obj); + break; + + case T_VacuumStmt: + _outVacuumStmt(str, obj); + break; + + case T_ExplainStmt: + _outExplainStmt(str, obj); + break; + + case T_ClusterStmt: + _outClusterStmt(str, obj); + break; + + case T_CheckPointStmt: + _outCheckPointStmt(str, obj); + break; + + case T_ClosePortalStmt: + _outClosePortalStmt(str, obj); + break; + + case T_ListenStmt: + _outListenStmt(str, obj); + break; + + case T_UnlistenStmt: + _outUnlistenStmt(str, obj); + break; + + case T_LoadStmt: + _outLoadStmt(str, obj); + break; + + case T_CopyStmt: + _outCopyStmt(str, obj); + break; + + case T_DeallocateStmt: + _outDeallocateStmt(str, obj); + break; + + case T_RenameStmt: + _outRenameStmt(str, obj); + break; + + case T_CreateRoleStmt: + _outCreateRoleStmt(str, obj); + break; + + case T_AlterRoleStmt: + _outAlterRoleStmt(str, obj); + break; + + case T_AlterRoleSetStmt: + _outAlterRoleSetStmt(str, obj); + break; + + case T_DropRoleStmt: + _outDropRoleStmt(str, obj); + break; + + case T_CreateSchemaStmt: + _outCreateSchemaStmt(str, obj); + break; + + case T_VariableSetStmt: + _outVariableSetStmt(str, obj); + break; + + case T_VariableShowStmt: + _outVariableShowStmt(str, obj); + break; + + case T_ConstraintsSetStmt: + _outConstraintsSetStmt(str, obj); + break; + + case T_AlterTableStmt: + _outAlterTableStmt(str, obj); + break; + + case T_AlterTableCmd: + _outAlterTableCmd(str, obj); + break; + + case T_CreateSeqStmt: + _outCreateSeqStmt(str, obj); + break; + + case T_AlterSeqStmt: + _outAlterSeqStmt(str, obj); + break; + + case T_CreatePLangStmt: + _outCreatePLangStmt(str, obj); + break; + + case T_DropPLangStmt: + _outDropPLangStmt(str, obj); + break; + + case T_CreateTableSpaceStmt: + _outCreateTableSpaceStmt(str, obj); + break; + + case T_DropTableSpaceStmt: + _outDropTableSpaceStmt(str, obj); + break; + + case T_CreateTrigStmt: + _outCreateTrigStmt(str, obj); + break; + + case T_DropPropertyStmt: + _outDropPropertyStmt(str, obj); + break; + + case T_DefineStmt: + _outDefineStmt(str, obj); + break; + + case T_CreateOpClassStmt: + _outCreateOpClassStmt(str, obj); + break; + + case T_CreateOpClassItem: + _outCreateOpClassItem(str, obj); + break; + + case T_RemoveOpClassStmt: + _outRemoveOpClassStmt(str, obj); + break; + + case T_DropStmt: + _outDropStmt(str, obj); + break; + + case T_FetchStmt: + _outFetchStmt(str, obj); + break; + + case T_GrantStmt: + _outGrantStmt(str, obj); + break; + + case T_PrivTarget: + _outPrivTarget(str, obj); + break; + + case T_FuncWithArgs: + _outFuncWithArgs(str, obj); + break; + + case T_FunctionParameter: + _outFunctionParameter(str, obj); + break; + + case T_PrivGrantee: + _outPrivGrantee(str, obj); + break; + + case T_GrantRoleStmt: + _outGrantRoleStmt(str, obj); + break; + + case T_CreateFunctionStmt: + _outCreateFunctionStmt(str, obj); + break; + + case T_AlterFunctionStmt: + _outAlterFunctionStmt(str, obj); + break; + + case T_RemoveFuncStmt: + _outRemoveFuncStmt(str, obj); + break; + + case T_CreateCastStmt: + _outCreateCastStmt(str, obj); + break; + + case T_DropCastStmt: + _outDropCastStmt(str, obj); + break; + + case T_ReindexStmt: + _outReindexStmt(str, obj); + break; + + case T_AlterObjectSchemaStmt: + _outAlterObjectSchemaStmt(str, obj); + break; + + case T_AlterOwnerStmt: + _outAlterOwnerStmt(str, obj); + break; + + case T_RuleStmt: + _outRuleStmt(str, obj); + break; + + case T_ViewStmt: + _outViewStmt(str, obj); + break; + + case T_CreatedbStmt: + _outCreatedbStmt(str, obj); + break; + + case T_AlterDatabaseStmt: + _outAlterDatabaseStmt(str, obj); + break; + + + case T_AlterDatabaseSetStmt: + _outAlterDatabaseSetStmt(str, obj); + break; + + case T_DropdbStmt: + _outDropdbStmt(str, obj); + break; + + case T_CreateDomainStmt: + _outCreateDomainStmt(str, obj); + break; + + case T_AlterDomainStmt: + _outAlterDomainStmt(str, obj); + break; + + case T_CreateConversionStmt: + _outCreateConversionStmt(str, obj); + break; + + case T_PrepareStmt: + _outPrepareStmt(str, obj); + break; + + case T_ExecuteStmt: + _outExecuteStmt(str, obj); + break; + + case T_LockStmt: + _outLockStmt(str, obj); + break; + + case T_CommentStmt: + _outCommentStmt(str, obj); + break; + + case T_RangeSubselect: + _outRangeSubselect(str, obj); + break; + + case T_RangeFunction: + _outRangeFunction(str, obj); + break; + + case T_DiscardStmt: + _outDiscardStmt(str, obj); + break; + + case T_CreateOpFamilyStmt: + _outCreateOpFamilyStmt(str, obj); + break; + + case T_AlterOpFamilyStmt: + _outAlterOpFamilyStmt(str, obj); + break; + + case T_RemoveOpFamilyStmt: + _outRemoveOpFamilyStmt(str, obj); + break; + + case T_CreateEnumStmt: + _outCreateEnumStmt(str, obj); + break; + + case T_DropOwnedStmt: + _outDropOwnedStmt(str, obj); + break; + + case T_ReassignOwnedStmt: + _outReassignOwnedStmt(str, obj); + break; + + case T_AlterTSDictionaryStmt: + _outAlterTSDictionaryStmt(str, obj); + break; + + case T_AlterTSConfigurationStmt: + _outAlterTSConfigurationStmt(str, obj); + break; + + case T_XmlExpr: + _outXmlExpr(str, obj); + break; + + case T_XmlSerialize: + _outXmlSerialize(str, obj); + break; + + case T_InhRelation: + _outInhRelation(str, obj); + break; + + case T_CurrentOfExpr: + _outCurrentOfExpr(str, obj); + + default: + break; + } + } +} + + +/* + * nodeToString - + * returns the ascii representation of the Node as a palloc'd string + */ +char * +nodeToString(void *obj) +{ + String *str; + + str = init_string(""); + _outNode(str, obj); + return str->data; +} diff --git a/parser/parsenodes.h b/parser/parsenodes.h new file mode 100644 index 0000000..fc59a8a --- /dev/null +++ b/parser/parsenodes.h @@ -0,0 +1,2069 @@ +/*------------------------------------------------------------------------- + * + * parsenodes.h + * definitions for parse tree nodes + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.353 2007/09/03 18:46:30 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PARSENODES_H +#define PARSENODES_H + +#include "primnodes.h" +#include "value.h" + +/* Possible sources of a Query */ +typedef enum QuerySource +{ + QSRC_ORIGINAL, /* original parsetree (explicit query) */ + QSRC_PARSER, /* added by parse analysis (now unused) */ + QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */ + QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */ + QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */ +} QuerySource; + +/* Sort ordering options for ORDER BY and CREATE INDEX */ +typedef enum SortByDir +{ + SORTBY_DEFAULT, + SORTBY_ASC, + SORTBY_DESC, + SORTBY_USING /* not allowed in CREATE INDEX ... */ +} SortByDir; + +typedef enum SortByNulls +{ + SORTBY_NULLS_DEFAULT, + SORTBY_NULLS_FIRST, + SORTBY_NULLS_LAST +} SortByNulls; + + +/* + * Grantable rights are encoded so that we can OR them together in a bitmask. + * The present representation of AclItem limits us to 16 distinct rights, + * even though AclMode is defined as uint32. See utils/acl.h. + * + * Caution: changing these codes breaks stored ACLs, hence forces initdb. + */ +typedef unsigned int AclMode; /* a bitmask of privilege bits */ + +#define ACL_INSERT (1<<0) /* for relations */ +#define ACL_SELECT (1<<1) +#define ACL_UPDATE (1<<2) +#define ACL_DELETE (1<<3) +/* #define ACL_RULE (1<<4) unused, available */ +#define ACL_REFERENCES (1<<5) +#define ACL_TRIGGER (1<<6) +#define ACL_EXECUTE (1<<7) /* for functions */ +#define ACL_USAGE (1<<8) /* for languages and namespaces */ +#define ACL_CREATE (1<<9) /* for namespaces and databases */ +#define ACL_CREATE_TEMP (1<<10) /* for databases */ +#define ACL_CONNECT (1<<11) /* for databases */ +#define N_ACL_RIGHTS 12 /* 1 plus the last 1<" */ + AEXPR_IN /* [NOT] IN - name must be "=" or "<>" */ +} A_Expr_Kind; + +typedef struct A_Expr +{ + NodeTag type; + A_Expr_Kind kind; /* see above */ + List *name; /* possibly-qualified name of operator */ + Node *lexpr; /* left argument, or NULL if none */ + Node *rexpr; /* right argument, or NULL if none */ + int location; /* token location, or -1 if unknown */ +} A_Expr; + +/* + * A_Const - a constant expression + */ +typedef struct A_Const +{ + NodeTag type; + Value val; /* the value (with the tag) */ + TypeName *typename; /* typecast, or NULL if none */ +} A_Const; + +/* + * TypeCast - a CAST expression + * + * NOTE: for mostly historical reasons, A_Const parsenodes contain + * room for a TypeName; we only generate a separate TypeCast node if the + * argument to be casted is not a constant. In theory either representation + * would work, but the combined representation saves a bit of code in many + * productions in gram.y. + */ +typedef struct TypeCast +{ + NodeTag type; + Node *arg; /* the expression being casted */ + TypeName *typename; /* the target type */ +} TypeCast; + +/* + * FuncCall - a function or aggregate invocation + * + * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct + * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct + * *must* be an aggregate call. Otherwise, it might be either an + * aggregate or some other kind of function. + */ +typedef struct FuncCall +{ + NodeTag type; + List *funcname; /* qualified name of function */ + List *args; /* the arguments (list of exprs) */ + bool agg_star; /* argument was really '*' */ + bool agg_distinct; /* arguments were labeled DISTINCT */ + int location; /* token location, or -1 if unknown */ +} FuncCall; + +/* + * A_Indices - array reference or bounds ([lidx:uidx] or [uidx]) + */ +typedef struct A_Indices +{ + NodeTag type; + Node *lidx; /* could be NULL */ + Node *uidx; +} A_Indices; + +/* + * A_Indirection - select a field and/or array element from an expression + * + * The indirection list can contain both A_Indices nodes (representing + * subscripting) and string Value nodes (representing field selection + * --- the string value is the name of the field to select). For example, + * a complex selection operation like + * (foo).field1[42][7].field2 + * would be represented with a single A_Indirection node having a 4-element + * indirection list. + * + * Note: as of Postgres 8.0, we don't support arrays of composite values, + * so cases in which a field select follows a subscript aren't actually + * semantically legal. However the parser is prepared to handle such. + */ +typedef struct A_Indirection +{ + NodeTag type; + Node *arg; /* the thing being selected from */ + List *indirection; /* subscripts and/or field names */ +} A_Indirection; + +/* + * ResTarget - + * result target (used in target list of pre-transformed parse trees) + * + * In a SELECT target list, 'name' is the column label from an + * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the + * value expression itself. The 'indirection' field is not used. + * + * INSERT uses ResTarget in its target-column-names list. Here, 'name' is + * the name of the destination column, 'indirection' stores any subscripts + * attached to the destination, and 'val' is not used. + * + * In an UPDATE target list, 'name' is the name of the destination column, + * 'indirection' stores any subscripts attached to the destination, and + * 'val' is the expression to assign. + * + * See A_Indirection for more info about what can appear in 'indirection'. + */ +typedef struct ResTarget +{ + NodeTag type; + char *name; /* column name or NULL */ + List *indirection; /* subscripts and field names, or NIL */ + Node *val; /* the value expression to compute or assign */ + int location; /* token location, or -1 if unknown */ +} ResTarget; + +/* + * SortBy - for ORDER BY clause + */ +typedef struct SortBy +{ + NodeTag type; + SortByDir sortby_dir; /* ASC/DESC/USING */ + SortByNulls sortby_nulls; /* NULLS FIRST/LAST */ + List *useOp; /* name of op to use, if SORTBY_USING */ + Node *node; /* expression to sort on */ +} SortBy; + +/* + * RangeSubselect - subquery appearing in a FROM clause + */ +typedef struct RangeSubselect +{ + NodeTag type; + Node *subquery; /* the untransformed sub-select clause */ + Alias *alias; /* table alias & optional column aliases */ +} RangeSubselect; + +/* + * RangeFunction - function call appearing in a FROM clause + */ +typedef struct RangeFunction +{ + NodeTag type; + Node *funccallnode; /* untransformed function call tree */ + Alias *alias; /* table alias & optional column aliases */ + List *coldeflist; /* list of ColumnDef nodes to describe result + * of function returning RECORD */ +} RangeFunction; + +/* + * ColumnDef - column definition (used in various creates) + * + * If the column has a default value, we may have the value expression + * in either "raw" form (an untransformed parse tree) or "cooked" form + * (the nodeToString representation of an executable expression tree), + * depending on how this ColumnDef node was created (by parsing, or by + * inheritance from an existing relation). We should never have both + * in the same node! + * + * The constraints list may contain a CONSTR_DEFAULT item in a raw + * parsetree produced by gram.y, but transformCreateStmt will remove + * the item and set raw_default instead. CONSTR_DEFAULT items + * should not appear in any subsequent processing. + */ +typedef struct ColumnDef +{ + NodeTag type; + char *colname; /* name of column */ + TypeName *typename; /* type of column */ + int inhcount; /* number of times column is inherited */ + bool is_local; /* column has local (non-inherited) def'n */ + bool is_not_null; /* NOT NULL constraint specified? */ + Node *raw_default; /* default value (untransformed parse tree) */ + char *cooked_default; /* nodeToString representation */ + List *constraints; /* other constraints on column */ +} ColumnDef; + +/* + * inhRelation - Relations a CREATE TABLE is to inherit attributes of + */ +typedef struct InhRelation +{ + NodeTag type; + RangeVar *relation; + List *options; /* integer List of CreateStmtLikeOption */ +} InhRelation; + +typedef enum CreateStmtLikeOption +{ + CREATE_TABLE_LIKE_INCLUDING_DEFAULTS, + CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS, + CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS, + CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS, + CREATE_TABLE_LIKE_INCLUDING_INDEXES, + CREATE_TABLE_LIKE_EXCLUDING_INDEXES +} CreateStmtLikeOption; + +/* + * IndexElem - index parameters (used in CREATE INDEX) + * + * For a plain index attribute, 'name' is the name of the table column to + * index, and 'expr' is NULL. For an index expression, 'name' is NULL and + * 'expr' is the expression tree. + */ +typedef struct IndexElem +{ + NodeTag type; + char *name; /* name of attribute to index, or NULL */ + Node *expr; /* expression to index, or NULL */ + List *opclass; /* name of desired opclass; NIL = default */ + SortByDir ordering; /* ASC/DESC/default */ + SortByNulls nulls_ordering; /* FIRST/LAST/default */ +} IndexElem; + +/* + * DefElem - + * a definition (used in definition lists in the form of defname = arg) + */ +typedef struct DefElem +{ + NodeTag type; + char *defname; + Node *arg; /* a (Value *) or a (TypeName *) */ +} DefElem; + +/* + * LockingClause - raw representation of FOR UPDATE/SHARE options + * + * Note: lockedRels == NIL means "all relations in query". Otherwise it + * is a list of String nodes giving relation eref names. + */ +typedef struct LockingClause +{ + NodeTag type; + List *lockedRels; /* FOR UPDATE or FOR SHARE relations */ + bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + bool noWait; /* NOWAIT option */ +} LockingClause; + +/* + * XMLSERIALIZE + */ +typedef struct XmlSerialize +{ + NodeTag type; + XmlOptionType xmloption; + Node *expr; + TypeName *typename; +} XmlSerialize; + + +/**************************************************************************** + * Nodes for a Query tree + ****************************************************************************/ + +/*-------------------- + * RangeTblEntry - + * A range table is a List of RangeTblEntry nodes. + * + * A range table entry may represent a plain relation, a sub-select in + * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax + * produces an RTE, not the implicit join resulting from multiple FROM + * items. This is because we only need the RTE to deal with SQL features + * like outer joins and join-output-column aliasing.) Other special + * RTE types also exist, as indicated by RTEKind. + * + * alias is an Alias node representing the AS alias-clause attached to the + * FROM expression, or NULL if no clause. + * + * eref is the table reference name and column reference names (either + * real or aliases). Note that system columns (OID etc) are not included + * in the column list. + * eref->aliasname is required to be present, and should generally be used + * to identify the RTE for error messages etc. + * + * In RELATION RTEs, the colnames in both alias and eref are indexed by + * physical attribute number; this means there must be colname entries for + * dropped columns. When building an RTE we insert empty strings ("") for + * dropped columns. Note however that a stored rule may have nonempty + * colnames for columns dropped since the rule was created (and for that + * matter the colnames might be out of date due to column renamings). + * The same comments apply to FUNCTION RTEs when the function's return type + * is a named composite type. + * + * In JOIN RTEs, the colnames in both alias and eref are one-to-one with + * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when + * those columns are known to be dropped at parse time. Again, however, + * a stored rule might contain entries for columns dropped since the rule + * was created. (This is only possible for columns not actually referenced + * in the rule.) When loading a stored rule, we replace the joinaliasvars + * items for any such columns with NULL Consts. (We can't simply delete + * them from the joinaliasvars list, because that would affect the attnums + * of Vars referencing the rest of the list.) + * + * inh is TRUE for relation references that should be expanded to include + * inheritance children, if the rel has any. This *must* be FALSE for + * RTEs other than RTE_RELATION entries. + * + * inFromCl marks those range variables that are listed in the FROM clause. + * It's false for RTEs that are added to a query behind the scenes, such + * as the NEW and OLD variables for a rule, or the subqueries of a UNION. + * This flag is not used anymore during parsing, since the parser now uses + * a separate "namespace" data structure to control visibility, but it is + * needed by ruleutils.c to determine whether RTEs should be shown in + * decompiled queries. + * + * requiredPerms and checkAsUser specify run-time access permissions + * checks to be performed at query startup. The user must have *all* + * of the permissions that are OR'd together in requiredPerms (zero + * indicates no permissions checking). If checkAsUser is not zero, + * then do the permissions checks using the access rights of that user, + * not the current effective user ID. (This allows rules to act as + * setuid gateways.) + *-------------------- + */ +typedef enum RTEKind +{ + RTE_RELATION, /* ordinary relation reference */ + RTE_SUBQUERY, /* subquery in FROM */ + RTE_JOIN, /* join */ + RTE_SPECIAL, /* special rule relation (NEW or OLD) */ + RTE_FUNCTION, /* function in FROM */ + RTE_VALUES /* VALUES (), (), ... */ +} RTEKind; + +typedef struct RangeTblEntry +{ + NodeTag type; + + RTEKind rtekind; /* see above */ + + /* + * XXX the fields applicable to only some rte kinds should be merged into + * a union. I didn't do this yet because the diffs would impact a lot of + * code that is being actively worked on. FIXME later. + */ + + /* + * Fields valid for a plain relation RTE (else zero): + */ + Oid relid; /* OID of the relation */ + + /* + * Fields valid for a subquery RTE (else NULL): + */ + Query *subquery; /* the sub-query */ + + /* + * Fields valid for a function RTE (else NULL): + * + * If the function returns RECORD, funccoltypes lists the column types + * declared in the RTE's column type specification, and funccoltypmods + * lists their declared typmods. Otherwise, both fields are NIL. + */ + Node *funcexpr; /* expression tree for func call */ + List *funccoltypes; /* OID list of column type OIDs */ + List *funccoltypmods; /* integer list of column typmods */ + + /* + * Fields valid for a values RTE (else NIL): + */ + List *values_lists; /* list of expression lists */ + + /* + * Fields valid for a join RTE (else NULL/zero): + * + * joinaliasvars is a list of Vars or COALESCE expressions corresponding + * to the columns of the join result. An alias Var referencing column K + * of the join result can be replaced by the K'th element of joinaliasvars + * --- but to simplify the task of reverse-listing aliases correctly, we + * do not do that until planning time. In a Query loaded from a stored + * rule, it is also possible for joinaliasvars items to be NULL Consts, + * denoting columns dropped since the rule was made. + */ + JoinType jointype; /* type of join */ + List *joinaliasvars; /* list of alias-var expansions */ + + /* + * Fields valid in all RTEs: + */ + Alias *alias; /* user-written alias clause, if any */ + Alias *eref; /* expanded reference names */ + bool inh; /* inheritance requested? */ + bool inFromCl; /* present in FROM clause? */ + AclMode requiredPerms; /* bitmask of required access permissions */ + Oid checkAsUser; /* if valid, check access as this role */ +} RangeTblEntry; + +/* + * SortClause - + * representation of ORDER BY clauses + * + * tleSortGroupRef must match ressortgroupref of exactly one entry of the + * associated targetlist; that is the expression to be sorted (or grouped) by. + * sortop is the OID of the ordering operator (a "<" or ">" operator). + * nulls_first does about what you'd expect. + * + * SortClauses are also used to identify targets that we will do a "Unique" + * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON). The + * distinctClause list is simply a copy of the relevant members of the + * sortClause list. Note that distinctClause can be a subset of sortClause, + * but cannot have members not present in sortClause; and the members that + * do appear must be in the same order as in sortClause. + */ +typedef struct SortClause +{ + NodeTag type; + Index tleSortGroupRef; /* reference into targetlist */ + Oid sortop; /* the ordering operator ('<' op) */ + bool nulls_first; /* do NULLs come before normal values? */ +} SortClause; + +/* + * GroupClause - + * representation of GROUP BY clauses + * + * GroupClause is exactly like SortClause except for the nodetag value. + * We have routines that operate interchangeably on both. + * + * XXX SortClause overspecifies the semantics so far as GROUP BY is concerned + * (ditto for DISTINCT). It'd be better to specify an equality operator not + * an ordering operator. However, the two implementations are tightly entwined + * at the moment ... breaking them apart is work for another day. + */ +typedef SortClause GroupClause; + +/* + * RowMarkClause - + * representation of FOR UPDATE/SHARE clauses + * + * We create a separate RowMarkClause node for each target relation + */ +typedef struct RowMarkClause +{ + NodeTag type; + Index rti; /* range table index of target relation */ + bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */ + bool noWait; /* NOWAIT option */ +} RowMarkClause; + +/***************************************************************************** + * Optimizable Statements + *****************************************************************************/ + +/* ---------------------- + * Insert Statement + * + * The source expression is represented by SelectStmt for both the + * SELECT and VALUES cases. If selectStmt is NULL, then the query + * is INSERT ... DEFAULT VALUES. + * ---------------------- + */ +typedef struct InsertStmt +{ + NodeTag type; + RangeVar *relation; /* relation to insert into */ + List *cols; /* optional: names of the target columns */ + Node *selectStmt; /* the source SELECT/VALUES, or NULL */ + List *returningList; /* list of expressions to return */ +} InsertStmt; + +/* ---------------------- + * Delete Statement + * ---------------------- + */ +typedef struct DeleteStmt +{ + NodeTag type; + RangeVar *relation; /* relation to delete from */ + List *usingClause; /* optional using clause for more tables */ + Node *whereClause; /* qualifications */ + List *returningList; /* list of expressions to return */ +} DeleteStmt; + +/* ---------------------- + * Update Statement + * ---------------------- + */ +typedef struct UpdateStmt +{ + NodeTag type; + RangeVar *relation; /* relation to update */ + List *targetList; /* the target list (of ResTarget) */ + Node *whereClause; /* qualifications */ + List *fromClause; /* optional from clause for more tables */ + List *returningList; /* list of expressions to return */ +} UpdateStmt; + +/* ---------------------- + * Select Statement + * + * A "simple" SELECT is represented in the output of gram.y by a single + * SelectStmt node; so is a VALUES construct. A query containing set + * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt + * nodes, in which the leaf nodes are component SELECTs and the internal nodes + * represent UNION, INTERSECT, or EXCEPT operators. Using the same node + * type for both leaf and internal nodes allows gram.y to stick ORDER BY, + * LIMIT, etc, clause values into a SELECT statement without worrying + * whether it is a simple or compound SELECT. + * ---------------------- + */ +typedef enum SetOperation +{ + SETOP_NONE = 0, + SETOP_UNION, + SETOP_INTERSECT, + SETOP_EXCEPT +} SetOperation; + +typedef struct SelectStmt +{ + NodeTag type; + + /* + * These fields are used only in "leaf" SelectStmts. + */ + List *distinctClause; /* NULL, list of DISTINCT ON exprs, or + * lcons(NIL,NIL) for all (SELECT DISTINCT) */ + IntoClause *intoClause; /* target for SELECT INTO / CREATE TABLE AS */ + List *targetList; /* the target list (of ResTarget) */ + List *fromClause; /* the FROM clause */ + Node *whereClause; /* WHERE qualification */ + List *groupClause; /* GROUP BY clauses */ + Node *havingClause; /* HAVING conditional-expression */ + + /* + * In a "leaf" node representing a VALUES list, the above fields are all + * null, and instead this field is set. Note that the elements of the + * sublists are just expressions, without ResTarget decoration. Also note + * that a list element can be DEFAULT (represented as a SetToDefault + * node), regardless of the context of the VALUES list. It's up to parse + * analysis to reject that where not valid. + */ + List *valuesLists; /* untransformed list of expression lists */ + + /* + * These fields are used in both "leaf" SelectStmts and upper-level + * SelectStmts. + */ + List *sortClause; /* sort clause (a list of SortBy's) */ + Node *limitOffset; /* # of result tuples to skip */ + Node *limitCount; /* # of result tuples to return */ + List *lockingClause; /* FOR UPDATE (list of LockingClause's) */ + + /* + * These fields are used only in upper-level SelectStmts. + */ + SetOperation op; /* type of set op */ + bool all; /* ALL specified? */ + struct SelectStmt *larg; /* left child */ + struct SelectStmt *rarg; /* right child */ + /* Eventually add fields for CORRESPONDING spec here */ +} SelectStmt; + + +/* ---------------------- + * Set Operation node for post-analysis query trees + * + * After parse analysis, a SELECT with set operations is represented by a + * top-level Query node containing the leaf SELECTs as subqueries in its + * range table. Its setOperations field shows the tree of set operations, + * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal + * nodes replaced by SetOperationStmt nodes. + * ---------------------- + */ +typedef struct SetOperationStmt +{ + NodeTag type; + SetOperation op; /* type of set op */ + bool all; /* ALL specified? */ + Node *larg; /* left child */ + Node *rarg; /* right child */ + /* Eventually add fields for CORRESPONDING spec here */ + + /* Fields derived during parse analysis: */ + List *colTypes; /* OID list of output column type OIDs */ + List *colTypmods; /* integer list of output column typmods */ +} SetOperationStmt; + + +/***************************************************************************** + * Other Statements (no optimizations required) + * + * These are not touched by parser/analyze.c except to put them into + * the utilityStmt field of a Query. This is eventually passed to + * ProcessUtility (by-passing rewriting and planning). Some of the + * statements do need attention from parse analysis, and this is + * done by routines in parser/parse_utilcmd.c after ProcessUtility + * receives the command for execution. + *****************************************************************************/ + +/* + * When a command can act on several kinds of objects with only one + * parse structure required, use these constants to designate the + * object type. + */ + +typedef enum ObjectType +{ + OBJECT_AGGREGATE, + OBJECT_CAST, + OBJECT_COLUMN, + OBJECT_CONSTRAINT, + OBJECT_CONVERSION, + OBJECT_DATABASE, + OBJECT_DOMAIN, + OBJECT_FUNCTION, + OBJECT_INDEX, + OBJECT_LANGUAGE, + OBJECT_LARGEOBJECT, + OBJECT_OPCLASS, + OBJECT_OPERATOR, + OBJECT_OPFAMILY, + OBJECT_ROLE, + OBJECT_RULE, + OBJECT_SCHEMA, + OBJECT_SEQUENCE, + OBJECT_TABLE, + OBJECT_TABLESPACE, + OBJECT_TRIGGER, + OBJECT_TSCONFIGURATION, + OBJECT_TSDICTIONARY, + OBJECT_TSPARSER, + OBJECT_TSTEMPLATE, + OBJECT_TYPE, + OBJECT_VIEW +} ObjectType; + +/* ---------------------- + * Create Schema Statement + * + * NOTE: the schemaElts list contains raw parsetrees for component statements + * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and + * executed after the schema itself is created. + * ---------------------- + */ +typedef struct CreateSchemaStmt +{ + NodeTag type; + char *schemaname; /* the name of the schema to create */ + char *authid; /* the owner of the created schema */ + List *schemaElts; /* schema components (list of parsenodes) */ +} CreateSchemaStmt; + +typedef enum DropBehavior +{ + DROP_RESTRICT, /* drop fails if any dependent objects */ + DROP_CASCADE /* remove dependent objects too */ +} DropBehavior; + +/* ---------------------- + * Alter Table + * ---------------------- + */ +typedef struct AlterTableStmt +{ + NodeTag type; + RangeVar *relation; /* table to work on */ + List *cmds; /* list of subcommands */ + ObjectType relkind; /* type of object */ +} AlterTableStmt; + +typedef enum AlterTableType +{ + AT_AddColumn, /* add column */ + AT_ColumnDefault, /* alter column default */ + AT_DropNotNull, /* alter column drop not null */ + AT_SetNotNull, /* alter column set not null */ + AT_SetStatistics, /* alter column statistics */ + AT_SetStorage, /* alter column storage */ + AT_DropColumn, /* drop column */ + AT_DropColumnRecurse, /* internal to commands/tablecmds.c */ + AT_AddIndex, /* add index */ + AT_ReAddIndex, /* internal to commands/tablecmds.c */ + AT_AddConstraint, /* add constraint */ + AT_ProcessedConstraint, /* pre-processed add constraint (local in + * parser/parse_utilcmd.c) */ + AT_DropConstraint, /* drop constraint */ + AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in + * commands/tablecmds.c) */ + AT_AlterColumnType, /* alter column type */ + AT_ChangeOwner, /* change owner */ + AT_ClusterOn, /* CLUSTER ON */ + AT_DropCluster, /* SET WITHOUT CLUSTER */ + AT_DropOids, /* SET WITHOUT OIDS */ + AT_SetTableSpace, /* SET TABLESPACE */ + AT_SetRelOptions, /* SET (...) -- AM specific parameters */ + AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */ + AT_EnableTrig, /* ENABLE TRIGGER name */ + AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */ + AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */ + AT_DisableTrig, /* DISABLE TRIGGER name */ + AT_EnableTrigAll, /* ENABLE TRIGGER ALL */ + AT_DisableTrigAll, /* DISABLE TRIGGER ALL */ + AT_EnableTrigUser, /* ENABLE TRIGGER USER */ + AT_DisableTrigUser, /* DISABLE TRIGGER USER */ + AT_EnableRule, /* ENABLE RULE name */ + AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */ + AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */ + AT_DisableRule, /* DISABLE RULE name */ + AT_AddInherit, /* INHERIT parent */ + AT_DropInherit /* NO INHERIT parent */ +} AlterTableType; + +typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */ +{ + NodeTag type; + AlterTableType subtype; /* Type of table alteration to apply */ + char *name; /* column, constraint, or trigger to act on, + * or new owner or tablespace */ + Node *def; /* definition of new column, column type, + * index, constraint, or parent table */ + Node *transform; /* transformation expr for ALTER TYPE */ + DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */ +} AlterTableCmd; + + +/* ---------------------- + * Alter Domain + * + * The fields are used in different ways by the different variants of + * this command. + * ---------------------- + */ +typedef struct AlterDomainStmt +{ + NodeTag type; + char subtype; /*------------ + * T = alter column default + * N = alter column drop not null + * O = alter column set not null + * C = add constraint + * X = drop constraint + *------------ + */ + List *typename; /* domain to work on */ + char *name; /* column or constraint name to act on */ + Node *def; /* definition of default or constraint */ + DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */ +} AlterDomainStmt; + + +/* ---------------------- + * Grant|Revoke Statement + * ---------------------- + */ +typedef enum GrantObjectType +{ + ACL_OBJECT_RELATION, /* table, view */ + ACL_OBJECT_SEQUENCE, /* sequence */ + ACL_OBJECT_DATABASE, /* database */ + ACL_OBJECT_FUNCTION, /* function */ + ACL_OBJECT_LANGUAGE, /* procedural language */ + ACL_OBJECT_NAMESPACE, /* namespace */ + ACL_OBJECT_TABLESPACE /* tablespace */ +} GrantObjectType; + +typedef struct GrantStmt +{ + NodeTag type; + bool is_grant; /* true = GRANT, false = REVOKE */ + GrantObjectType objtype; /* kind of object being operated on */ + List *objects; /* list of RangeVar nodes, FuncWithArgs nodes, + * or plain names (as Value strings) */ + List *privileges; /* list of privilege names (as Strings) */ + /* privileges == NIL denotes "all privileges" */ + List *grantees; /* list of PrivGrantee nodes */ + bool grant_option; /* grant or revoke grant option */ + DropBehavior behavior; /* drop behavior (for REVOKE) */ +} GrantStmt; + +typedef struct PrivGrantee +{ + NodeTag type; + char *rolname; /* if NULL then PUBLIC */ +} PrivGrantee; + +/* + * Note: FuncWithArgs carries only the types of the input parameters of the + * function. So it is sufficient to identify an existing function, but it + * is not enough info to define a function nor to call it. + */ +typedef struct FuncWithArgs +{ + NodeTag type; + List *funcname; /* qualified name of function */ + List *funcargs; /* list of Typename nodes */ +} FuncWithArgs; + +/* This is only used internally in gram.y. */ +typedef struct PrivTarget +{ + NodeTag type; + GrantObjectType objtype; + List *objs; +} PrivTarget; + +/* ---------------------- + * Grant/Revoke Role Statement + * + * Note: the lists of roles are lists of names, as Value strings + * ---------------------- + */ +typedef struct GrantRoleStmt +{ + NodeTag type; + List *granted_roles; /* list of roles to be granted/revoked */ + List *grantee_roles; /* list of member roles to add/delete */ + bool is_grant; /* true = GRANT, false = REVOKE */ + bool admin_opt; /* with admin option */ + char *grantor; /* set grantor to other than current role */ + DropBehavior behavior; /* drop behavior (for REVOKE) */ +} GrantRoleStmt; + +/* ---------------------- + * Copy Statement + * + * We support "COPY relation FROM file", "COPY relation TO file", and + * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation" + * and "query" must be non-NULL. + * ---------------------- + */ +typedef struct CopyStmt +{ + NodeTag type; + RangeVar *relation; /* the relation to copy */ + Node *query; /* the SELECT query to copy */ + List *attlist; /* List of column names (as Strings), or NIL + * for all columns */ + bool is_from; /* TO or FROM */ + char *filename; /* filename, or NULL for STDIN/STDOUT */ + List *options; /* List of DefElem nodes */ +} CopyStmt; + +/* ---------------------- + * SET Statement (includes RESET) + * + * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we + * preserve the distinction in VariableSetKind for CreateCommandTag(). + * ---------------------- + */ +typedef enum +{ + VAR_SET_VALUE, /* SET var = value */ + VAR_SET_DEFAULT, /* SET var TO DEFAULT */ + VAR_SET_CURRENT, /* SET var FROM CURRENT */ + VAR_SET_MULTI, /* special case for SET TRANSACTION ... */ + VAR_RESET, /* RESET var */ + VAR_RESET_ALL /* RESET ALL */ +} VariableSetKind; + +typedef struct VariableSetStmt +{ + NodeTag type; + VariableSetKind kind; + char *name; /* variable to be set */ + List *args; /* List of A_Const nodes */ + bool is_local; /* SET LOCAL? */ +} VariableSetStmt; + +/* ---------------------- + * Show Statement + * ---------------------- + */ +typedef struct VariableShowStmt +{ + NodeTag type; + char *name; +} VariableShowStmt; + +/* ---------------------- + * Create Table Statement + * + * NOTE: in the raw gram.y output, ColumnDef, Constraint, and FkConstraint + * nodes are intermixed in tableElts, and constraints is NIL. After parse + * analysis, tableElts contains just ColumnDefs, and constraints contains + * just Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present + * implementation). + * ---------------------- + */ + +typedef struct CreateStmt +{ + NodeTag type; + RangeVar *relation; /* relation to create */ + List *tableElts; /* column definitions (list of ColumnDef) */ + List *inhRelations; /* relations to inherit from (list of + * inhRelation) */ + List *constraints; /* constraints (list of Constraint nodes) */ + List *options; /* options from WITH clause */ + OnCommitAction oncommit; /* what do we do at COMMIT? */ + char *tablespacename; /* table space to use, or NULL */ +} CreateStmt; + +/* ---------- + * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt + * + * XXX probably these ought to be unified with FkConstraints at some point? + * To this end we include CONSTR_FOREIGN in the ConstrType enum, even though + * the parser does not generate it. + * + * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK) + * we may have the expression in either "raw" form (an untransformed + * parse tree) or "cooked" form (the nodeToString representation of + * an executable expression tree), depending on how this Constraint + * node was created (by parsing, or by inheritance from an existing + * relation). We should never have both in the same node! + * + * Constraint attributes (DEFERRABLE etc) are initially represented as + * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes + * a pass through the constraints list to attach the info to the appropriate + * FkConstraint node (and, perhaps, someday to other kinds of constraints). + * ---------- + */ + +typedef enum ConstrType /* types of constraints */ +{ + CONSTR_NULL, /* not SQL92, but a lot of people expect it */ + CONSTR_NOTNULL, + CONSTR_DEFAULT, + CONSTR_CHECK, + CONSTR_FOREIGN, + CONSTR_PRIMARY, + CONSTR_UNIQUE, + CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */ + CONSTR_ATTR_NOT_DEFERRABLE, + CONSTR_ATTR_DEFERRED, + CONSTR_ATTR_IMMEDIATE +} ConstrType; + +typedef struct Constraint +{ + NodeTag type; + ConstrType contype; + char *name; /* name, or NULL if unnamed */ + Node *raw_expr; /* expr, as untransformed parse tree */ + char *cooked_expr; /* expr, as nodeToString representation */ + List *keys; /* String nodes naming referenced column(s) */ + List *options; /* options from WITH clause */ + char *indexspace; /* index tablespace for PKEY/UNIQUE + * constraints; NULL for default */ +} Constraint; + +/* ---------- + * Definitions for FOREIGN KEY constraints in CreateStmt + * + * Note: FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype + * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are + * stored into pg_constraint.confmatchtype. Changing the code values may + * require an initdb! + * + * If skip_validation is true then we skip checking that the existing rows + * in the table satisfy the constraint, and just install the catalog entries + * for the constraint. This is currently used only during CREATE TABLE + * (when we know the table must be empty). + * ---------- + */ +#define FKCONSTR_ACTION_NOACTION 'a' +#define FKCONSTR_ACTION_RESTRICT 'r' +#define FKCONSTR_ACTION_CASCADE 'c' +#define FKCONSTR_ACTION_SETNULL 'n' +#define FKCONSTR_ACTION_SETDEFAULT 'd' + +#define FKCONSTR_MATCH_FULL 'f' +#define FKCONSTR_MATCH_PARTIAL 'p' +#define FKCONSTR_MATCH_UNSPECIFIED 'u' + +typedef struct FkConstraint +{ + NodeTag type; + char *constr_name; /* Constraint name, or NULL if unnamed */ + RangeVar *pktable; /* Primary key table */ + List *fk_attrs; /* Attributes of foreign key */ + List *pk_attrs; /* Corresponding attrs in PK table */ + char fk_matchtype; /* FULL, PARTIAL, UNSPECIFIED */ + char fk_upd_action; /* ON UPDATE action */ + char fk_del_action; /* ON DELETE action */ + bool deferrable; /* DEFERRABLE */ + bool initdeferred; /* INITIALLY DEFERRED */ + bool skip_validation; /* skip validation of existing rows? */ +} FkConstraint; + + +/* ---------------------- + * Create/Drop Table Space Statements + * ---------------------- + */ + +typedef struct CreateTableSpaceStmt +{ + NodeTag type; + char *tablespacename; + char *owner; + char *location; +} CreateTableSpaceStmt; + +typedef struct DropTableSpaceStmt +{ + NodeTag type; + char *tablespacename; + bool missing_ok; /* skip error if missing? */ +} DropTableSpaceStmt; + +/* ---------------------- + * Create/Drop TRIGGER Statements + * ---------------------- + */ + +typedef struct CreateTrigStmt +{ + NodeTag type; + char *trigname; /* TRIGGER's name */ + RangeVar *relation; /* relation trigger is on */ + List *funcname; /* qual. name of function to call */ + List *args; /* list of (T_String) Values or NIL */ + bool before; /* BEFORE/AFTER */ + bool row; /* ROW/STATEMENT */ + char actions[4]; /* 1 to 3 of 'i', 'u', 'd', + trailing \0 */ + + /* The following are used for referential */ + /* integrity constraint triggers */ + bool isconstraint; /* This is an RI trigger */ + bool deferrable; /* [NOT] DEFERRABLE */ + bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */ + RangeVar *constrrel; /* opposite relation */ +} CreateTrigStmt; + +/* ---------------------- + * Create/Drop PROCEDURAL LANGUAGE Statement + * ---------------------- + */ +typedef struct CreatePLangStmt +{ + NodeTag type; + char *plname; /* PL name */ + List *plhandler; /* PL call handler function (qual. name) */ + List *plvalidator; /* optional validator function (qual. name) */ + bool pltrusted; /* PL is trusted */ +} CreatePLangStmt; + +typedef struct DropPLangStmt +{ + NodeTag type; + char *plname; /* PL name */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if missing? */ +} DropPLangStmt; + +/* ---------------------- + * Create/Alter/Drop Role Statements + * + * Note: these node types are also used for the backwards-compatible + * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases + * there's really no need to distinguish what the original spelling was, + * but for CREATE we mark the type because the defaults vary. + * ---------------------- + */ +typedef enum RoleStmtType +{ + ROLESTMT_ROLE, + ROLESTMT_USER, + ROLESTMT_GROUP +} RoleStmtType; + +typedef struct CreateRoleStmt +{ + NodeTag type; + RoleStmtType stmt_type; /* ROLE/USER/GROUP */ + char *role; /* role name */ + List *options; /* List of DefElem nodes */ +} CreateRoleStmt; + +typedef struct AlterRoleStmt +{ + NodeTag type; + char *role; /* role name */ + List *options; /* List of DefElem nodes */ + int action; /* +1 = add members, -1 = drop members */ +} AlterRoleStmt; + +typedef struct AlterRoleSetStmt +{ + NodeTag type; + char *role; /* role name */ + VariableSetStmt *setstmt; /* SET or RESET subcommand */ +} AlterRoleSetStmt; + +typedef struct DropRoleStmt +{ + NodeTag type; + List *roles; /* List of roles to remove */ + bool missing_ok; /* skip error if a role is missing? */ +} DropRoleStmt; + +/* ---------------------- + * {Create|Alter} SEQUENCE Statement + * ---------------------- + */ + +typedef struct CreateSeqStmt +{ + NodeTag type; + RangeVar *sequence; /* the sequence to create */ + List *options; +} CreateSeqStmt; + +typedef struct AlterSeqStmt +{ + NodeTag type; + RangeVar *sequence; /* the sequence to alter */ + List *options; +} AlterSeqStmt; + +/* ---------------------- + * Create {Aggregate|Operator|Type} Statement + * ---------------------- + */ +typedef struct DefineStmt +{ + NodeTag type; + ObjectType kind; /* aggregate, operator, type */ + bool oldstyle; /* hack to signal old CREATE AGG syntax */ + List *defnames; /* qualified name (list of Value strings) */ + List *args; /* a list of TypeName (if needed) */ + List *definition; /* a list of DefElem */ +} DefineStmt; + +/* ---------------------- + * Create Domain Statement + * ---------------------- + */ +typedef struct CreateDomainStmt +{ + NodeTag type; + List *domainname; /* qualified name (list of Value strings) */ + TypeName *typename; /* the base type */ + List *constraints; /* constraints (list of Constraint nodes) */ +} CreateDomainStmt; + +/* ---------------------- + * Create Operator Class Statement + * ---------------------- + */ +typedef struct CreateOpClassStmt +{ + NodeTag type; + List *opclassname; /* qualified name (list of Value strings) */ + List *opfamilyname; /* qualified name (ditto); NIL if omitted */ + char *amname; /* name of index AM opclass is for */ + TypeName *datatype; /* datatype of indexed column */ + List *items; /* List of CreateOpClassItem nodes */ + bool isDefault; /* Should be marked as default for type? */ +} CreateOpClassStmt; + +#define OPCLASS_ITEM_OPERATOR 1 +#define OPCLASS_ITEM_FUNCTION 2 +#define OPCLASS_ITEM_STORAGETYPE 3 + +typedef struct CreateOpClassItem +{ + NodeTag type; + int itemtype; /* see codes above */ + /* fields used for an operator or function item: */ + List *name; /* operator or function name */ + List *args; /* argument types */ + int number; /* strategy num or support proc num */ + bool recheck; /* only used for operators */ + List *class_args; /* only used for functions */ + /* fields used for a storagetype item: */ + TypeName *storedtype; /* datatype stored in index */ +} CreateOpClassItem; + +/* ---------------------- + * Create Operator Family Statement + * ---------------------- + */ +typedef struct CreateOpFamilyStmt +{ + NodeTag type; + List *opfamilyname; /* qualified name (list of Value strings) */ + char *amname; /* name of index AM opfamily is for */ +} CreateOpFamilyStmt; + +/* ---------------------- + * Alter Operator Family Statement + * ---------------------- + */ +typedef struct AlterOpFamilyStmt +{ + NodeTag type; + List *opfamilyname; /* qualified name (list of Value strings) */ + char *amname; /* name of index AM opfamily is for */ + bool isDrop; /* ADD or DROP the items? */ + List *items; /* List of CreateOpClassItem nodes */ +} AlterOpFamilyStmt; + +/* ---------------------- + * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement + * ---------------------- + */ + +typedef struct DropStmt +{ + NodeTag type; + List *objects; /* list of sublists of names (as Values) */ + ObjectType removeType; /* object type */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if object is missing? */ +} DropStmt; + +/* ---------------------- + * Drop Rule|Trigger Statement + * + * In general this may be used for dropping any property of a relation; + * for example, someday soon we may have DROP ATTRIBUTE. + * ---------------------- + */ + +typedef struct DropPropertyStmt +{ + NodeTag type; + RangeVar *relation; /* owning relation */ + char *property; /* name of rule, trigger, etc */ + ObjectType removeType; /* OBJECT_RULE or OBJECT_TRIGGER */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if missing? */ +} DropPropertyStmt; + +/* ---------------------- + * Truncate Table Statement + * ---------------------- + */ +typedef struct TruncateStmt +{ + NodeTag type; + List *relations; /* relations (RangeVars) to be truncated */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ +} TruncateStmt; + +/* ---------------------- + * Comment On Statement + * ---------------------- + */ +typedef struct CommentStmt +{ + NodeTag type; + ObjectType objtype; /* Object's type */ + List *objname; /* Qualified name of the object */ + List *objargs; /* Arguments if needed (eg, for functions) */ + char *comment; /* Comment to insert, or NULL to remove */ +} CommentStmt; + +/* ---------------------- + * Declare Cursor Statement + * + * Note: the "query" field of DeclareCursorStmt is only used in the raw grammar + * output. After parse analysis it's set to null, and the Query points to the + * DeclareCursorStmt, not vice versa. + * ---------------------- + */ +#define CURSOR_OPT_BINARY 0x0001 /* BINARY */ +#define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */ +#define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */ +#define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE (unimplemented) */ +#define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */ +#define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */ + +typedef struct DeclareCursorStmt +{ + NodeTag type; + char *portalname; /* name of the portal (cursor) */ + int options; /* bitmask of options (see above) */ + Node *query; /* the raw SELECT query */ +} DeclareCursorStmt; + +/* ---------------------- + * Close Portal Statement + * ---------------------- + */ +typedef struct ClosePortalStmt +{ + NodeTag type; + char *portalname; /* name of the portal (cursor) */ + /* NULL means CLOSE ALL */ +} ClosePortalStmt; + +/* ---------------------- + * Fetch Statement (also Move) + * ---------------------- + */ +typedef enum FetchDirection +{ + /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */ + FETCH_FORWARD, + FETCH_BACKWARD, + /* for these, howMany indicates a position; only one row is fetched */ + FETCH_ABSOLUTE, + FETCH_RELATIVE +} FetchDirection; + +#define FETCH_ALL LONG_MAX + +typedef struct FetchStmt +{ + NodeTag type; + FetchDirection direction; /* see above */ + long howMany; /* number of rows, or position argument */ + char *portalname; /* name of portal (cursor) */ + bool ismove; /* TRUE if MOVE */ +} FetchStmt; + +/* ---------------------- + * Create Index Statement + * ---------------------- + */ +typedef struct IndexStmt +{ + NodeTag type; + char *idxname; /* name of new index, or NULL for default */ + RangeVar *relation; /* relation to build index on */ + char *accessMethod; /* name of access method (eg. btree) */ + char *tableSpace; /* tablespace, or NULL to use parent's */ + List *indexParams; /* a list of IndexElem */ + List *options; /* options from WITH clause */ + char *src_options; /* relopts inherited from source index */ + Node *whereClause; /* qualification (partial-index predicate) */ + bool unique; /* is index unique? */ + bool primary; /* is index on primary key? */ + bool isconstraint; /* is it from a CONSTRAINT clause? */ + bool concurrent; /* should this be a concurrent index build? */ +} IndexStmt; + +/* ---------------------- + * Create Function Statement + * ---------------------- + */ +typedef struct CreateFunctionStmt +{ + NodeTag type; + bool replace; /* T => replace if already exists */ + List *funcname; /* qualified name of function to create */ + List *parameters; /* a list of FunctionParameter */ + TypeName *returnType; /* the return type */ + List *options; /* a list of DefElem */ + List *withClause; /* a list of DefElem */ +} CreateFunctionStmt; + +typedef enum FunctionParameterMode +{ + /* the assigned enum values appear in pg_proc, don't change 'em! */ + FUNC_PARAM_IN = 'i', /* input only */ + FUNC_PARAM_OUT = 'o', /* output only */ + FUNC_PARAM_INOUT = 'b' /* both */ +} FunctionParameterMode; + +typedef struct FunctionParameter +{ + NodeTag type; + char *name; /* parameter name, or NULL if not given */ + TypeName *argType; /* TypeName for parameter type */ + FunctionParameterMode mode; /* IN/OUT/INOUT */ +} FunctionParameter; + +typedef struct AlterFunctionStmt +{ + NodeTag type; + FuncWithArgs *func; /* name and args of function */ + List *actions; /* list of DefElem */ +} AlterFunctionStmt; + +/* ---------------------- + * Drop {Function|Aggregate|Operator} Statement + * ---------------------- + */ +typedef struct RemoveFuncStmt +{ + NodeTag type; + ObjectType kind; /* function, aggregate, operator */ + List *name; /* qualified name of object to drop */ + List *args; /* types of the arguments */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if missing? */ +} RemoveFuncStmt; + +/* ---------------------- + * Drop Operator Class Statement + * ---------------------- + */ +typedef struct RemoveOpClassStmt +{ + NodeTag type; + List *opclassname; /* qualified name (list of Value strings) */ + char *amname; /* name of index AM opclass is for */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if missing? */ +} RemoveOpClassStmt; + +/* ---------------------- + * Drop Operator Family Statement + * ---------------------- + */ +typedef struct RemoveOpFamilyStmt +{ + NodeTag type; + List *opfamilyname; /* qualified name (list of Value strings) */ + char *amname; /* name of index AM opfamily is for */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if missing? */ +} RemoveOpFamilyStmt; + +/* ---------------------- + * Alter Object Rename Statement + * ---------------------- + */ +typedef struct RenameStmt +{ + NodeTag type; + ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */ + RangeVar *relation; /* in case it's a table */ + List *object; /* in case it's some other object */ + List *objarg; /* argument types, if applicable */ + char *subname; /* name of contained object (column, rule, + * trigger, etc) */ + char *newname; /* the new name */ +} RenameStmt; + +/* ---------------------- + * ALTER object SET SCHEMA Statement + * ---------------------- + */ +typedef struct AlterObjectSchemaStmt +{ + NodeTag type; + ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ + RangeVar *relation; /* in case it's a table */ + List *object; /* in case it's some other object */ + List *objarg; /* argument types, if applicable */ + char *addname; /* additional name if needed */ + char *newschema; /* the new schema */ +} AlterObjectSchemaStmt; + +/* ---------------------- + * Alter Object Owner Statement + * ---------------------- + */ +typedef struct AlterOwnerStmt +{ + NodeTag type; + ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ + RangeVar *relation; /* in case it's a table */ + List *object; /* in case it's some other object */ + List *objarg; /* argument types, if applicable */ + char *addname; /* additional name if needed */ + char *newowner; /* the new owner */ +} AlterOwnerStmt; + + +/* ---------------------- + * Create Rule Statement + * ---------------------- + */ +typedef struct RuleStmt +{ + NodeTag type; + RangeVar *relation; /* relation the rule is for */ + char *rulename; /* name of the rule */ + Node *whereClause; /* qualifications */ + CmdType event; /* SELECT, INSERT, etc */ + bool instead; /* is a 'do instead'? */ + List *actions; /* the action statements */ + bool replace; /* OR REPLACE */ +} RuleStmt; + +/* ---------------------- + * Notify Statement + * ---------------------- + */ +typedef struct NotifyStmt +{ + NodeTag type; + RangeVar *relation; /* qualified name to notify */ +} NotifyStmt; + +/* ---------------------- + * Listen Statement + * ---------------------- + */ +typedef struct ListenStmt +{ + NodeTag type; + RangeVar *relation; /* qualified name to listen on */ +} ListenStmt; + +/* ---------------------- + * Unlisten Statement + * ---------------------- + */ +typedef struct UnlistenStmt +{ + NodeTag type; + RangeVar *relation; /* qualified name to unlisten on, or '*' */ +} UnlistenStmt; + +/* ---------------------- + * {Begin|Commit|Rollback} Transaction Statement + * ---------------------- + */ +typedef enum TransactionStmtKind +{ + TRANS_STMT_BEGIN, + TRANS_STMT_START, /* semantically identical to BEGIN */ + TRANS_STMT_COMMIT, + TRANS_STMT_ROLLBACK, + TRANS_STMT_SAVEPOINT, + TRANS_STMT_RELEASE, + TRANS_STMT_ROLLBACK_TO, + TRANS_STMT_PREPARE, + TRANS_STMT_COMMIT_PREPARED, + TRANS_STMT_ROLLBACK_PREPARED +} TransactionStmtKind; + +typedef struct TransactionStmt +{ + NodeTag type; + TransactionStmtKind kind; /* see above */ + List *options; /* for BEGIN/START and savepoint commands */ + char *gid; /* for two-phase-commit related commands */ +} TransactionStmt; + +/* ---------------------- + * Create Type Statement, composite types + * ---------------------- + */ +typedef struct CompositeTypeStmt +{ + NodeTag type; + RangeVar *typevar; /* the composite type to be created */ + List *coldeflist; /* list of ColumnDef nodes */ +} CompositeTypeStmt; + +/* ---------------------- + * Create Type Statement, enum types + * ---------------------- + */ +typedef struct CreateEnumStmt +{ + NodeTag type; + List *typename; /* qualified name (list of Value strings) */ + List *vals; /* enum values (list of Value strings) */ +} CreateEnumStmt; + + +/* ---------------------- + * Create View Statement + * ---------------------- + */ +typedef struct ViewStmt +{ + NodeTag type; + RangeVar *view; /* the view to be created */ + List *aliases; /* target column names */ + Node *query; /* the SELECT query */ + bool replace; /* replace an existing view? */ +} ViewStmt; + +/* ---------------------- + * Load Statement + * ---------------------- + */ +typedef struct LoadStmt +{ + NodeTag type; + char *filename; /* file to load */ +} LoadStmt; + +/* ---------------------- + * Createdb Statement + * ---------------------- + */ +typedef struct CreatedbStmt +{ + NodeTag type; + char *dbname; /* name of database to create */ + List *options; /* List of DefElem nodes */ +} CreatedbStmt; + +/* ---------------------- + * Alter Database + * ---------------------- + */ +typedef struct AlterDatabaseStmt +{ + NodeTag type; + char *dbname; /* name of database to alter */ + List *options; /* List of DefElem nodes */ +} AlterDatabaseStmt; + +typedef struct AlterDatabaseSetStmt +{ + NodeTag type; + char *dbname; /* database name */ + VariableSetStmt *setstmt; /* SET or RESET subcommand */ +} AlterDatabaseSetStmt; + +/* ---------------------- + * Dropdb Statement + * ---------------------- + */ +typedef struct DropdbStmt +{ + NodeTag type; + char *dbname; /* database to drop */ + bool missing_ok; /* skip error if db is missing? */ +} DropdbStmt; + +/* ---------------------- + * Cluster Statement (support pbrown's cluster index implementation) + * ---------------------- + */ +typedef struct ClusterStmt +{ + NodeTag type; + RangeVar *relation; /* relation being indexed, or NULL if all */ + char *indexname; /* original index defined */ +} ClusterStmt; + +/* ---------------------- + * Vacuum and Analyze Statements + * + * Even though these are nominally two statements, it's convenient to use + * just one node type for both. + * ---------------------- + */ +typedef struct VacuumStmt +{ + NodeTag type; + bool vacuum; /* do VACUUM step */ + bool full; /* do FULL (non-concurrent) vacuum */ + bool analyze; /* do ANALYZE step */ + bool verbose; /* print progress info */ + int freeze_min_age; /* min freeze age, or -1 to use default */ + RangeVar *relation; /* single table to process, or NULL */ + List *va_cols; /* list of column names, or NIL for all */ +} VacuumStmt; + +/* ---------------------- + * Explain Statement + * ---------------------- + */ +typedef struct ExplainStmt +{ + NodeTag type; + Node *query; /* the query (as a raw parse tree) */ + bool verbose; /* print plan info */ + bool analyze; /* get statistics by executing plan */ +} ExplainStmt; + +/* ---------------------- + * Checkpoint Statement + * ---------------------- + */ +typedef struct CheckPointStmt +{ + NodeTag type; +} CheckPointStmt; + +/* ---------------------- + * Discard Statement + * ---------------------- + */ + +typedef enum DiscardMode +{ + DISCARD_ALL, + DISCARD_PLANS, + DISCARD_TEMP +} DiscardMode; + +typedef struct DiscardStmt +{ + NodeTag type; + DiscardMode target; +} DiscardStmt; + +/* ---------------------- + * LOCK Statement + * ---------------------- + */ +typedef struct LockStmt +{ + NodeTag type; + List *relations; /* relations to lock */ + int mode; /* lock mode */ + bool nowait; /* no wait mode */ +} LockStmt; + +/* ---------------------- + * SET CONSTRAINTS Statement + * ---------------------- + */ +typedef struct ConstraintsSetStmt +{ + NodeTag type; + List *constraints; /* List of names as RangeVars */ + bool deferred; +} ConstraintsSetStmt; + +/* ---------------------- + * REINDEX Statement + * ---------------------- + */ +typedef struct ReindexStmt +{ + NodeTag type; + ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */ + RangeVar *relation; /* Table or index to reindex */ + const char *name; /* name of database to reindex */ + bool do_system; /* include system tables in database case */ + bool do_user; /* include user tables in database case */ +} ReindexStmt; + +/* ---------------------- + * CREATE CONVERSION Statement + * ---------------------- + */ +typedef struct CreateConversionStmt +{ + NodeTag type; + List *conversion_name; /* Name of the conversion */ + char *for_encoding_name; /* source encoding name */ + char *to_encoding_name; /* destination encoding name */ + List *func_name; /* qualified conversion function name */ + bool def; /* is this a default conversion? */ +} CreateConversionStmt; + +/* ---------------------- + * CREATE CAST Statement + * ---------------------- + */ +typedef struct CreateCastStmt +{ + NodeTag type; + TypeName *sourcetype; + TypeName *targettype; + FuncWithArgs *func; + CoercionContext context; +} CreateCastStmt; + +/* ---------------------- + * DROP CAST Statement + * ---------------------- + */ +typedef struct DropCastStmt +{ + NodeTag type; + TypeName *sourcetype; + TypeName *targettype; + DropBehavior behavior; + bool missing_ok; /* skip error if missing? */ +} DropCastStmt; + + +/* ---------------------- + * PREPARE Statement + * ---------------------- + */ +typedef struct PrepareStmt +{ + NodeTag type; + char *name; /* Name of plan, arbitrary */ + List *argtypes; /* Types of parameters (List of TypeName) */ + Node *query; /* The query itself (as a raw parsetree) */ +} PrepareStmt; + + +/* ---------------------- + * EXECUTE Statement + * ---------------------- + */ + +typedef struct ExecuteStmt +{ + NodeTag type; + char *name; /* The name of the plan to execute */ + IntoClause *into; /* Optional table to store results in */ + List *params; /* Values to assign to parameters */ +} ExecuteStmt; + + +/* ---------------------- + * DEALLOCATE Statement + * ---------------------- + */ +typedef struct DeallocateStmt +{ + NodeTag type; + char *name; /* The name of the plan to remove */ + /* NULL means DEALLOCATE ALL */ +} DeallocateStmt; + +/* + * DROP OWNED statement + */ +typedef struct DropOwnedStmt +{ + NodeTag type; + List *roles; + DropBehavior behavior; +} DropOwnedStmt; + +/* + * REASSIGN OWNED statement + */ +typedef struct ReassignOwnedStmt +{ + NodeTag type; + List *roles; + char *newrole; +} ReassignOwnedStmt; + +/* + * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default + */ +typedef struct AlterTSDictionaryStmt +{ + NodeTag type; + List *dictname; /* qualified name (list of Value strings) */ + List *options; /* List of DefElem nodes */ +} AlterTSDictionaryStmt; + +/* + * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default + */ +typedef struct AlterTSConfigurationStmt +{ + NodeTag type; + List *cfgname; /* qualified name (list of Value strings) */ + + /* + * dicts will be non-NIL if ADD/ALTER MAPPING was specified. + * If dicts is NIL, but tokentype isn't, DROP MAPPING was specified. + */ + List *tokentype; /* list of Value strings */ + List *dicts; /* list of list of Value strings */ + bool override; /* if true - remove old variant */ + bool replace; /* if true - replace dictionary by another */ + bool missing_ok; /* for DROP - skip error if missing? */ +} AlterTSConfigurationStmt; + +#endif /* PARSENODES_H */ diff --git a/parser/parser.c b/parser/parser.c new file mode 100644 index 0000000..17c5d74 --- /dev/null +++ b/parser/parser.c @@ -0,0 +1,187 @@ +/*------------------------------------------------------------------------- + * + * parser.c + * Main entry point/driver for PostgreSQL grammar + * + * Note that the grammar is not allowed to perform any table access + * (since we need to be able to do basic parsing even while inside an + * aborted transaction). Therefore, the data structures returned by + * the grammar are "raw" parsetrees that still need to be analyzed by + * parse_analyze. + * + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.63 2004/12/31 22:00:27 pgsql Exp $ + * + *------------------------------------------------------------------------- + */ + +#include +#include "pool_parser.h" +#include "pool_memory.h" +#include "gramparse.h" +#include "gram.h" +#include "parser.h" +#include "value.h" + +List *parsetree; /* result of parsing is left here */ +jmp_buf jmpbuffer; + +static int lookahead_token; /* one-token lookahead */ +static bool have_lookahead; /* lookahead_token set? */ +static YYSTYPE lookahead_yylval; /* yylval for lookahead token */ +static YYLTYPE lookahead_yylloc; /* yylloc for lookahead token */ + + +/* + * raw_parser + * Given a query in string form, do lexical and grammatical analysis. + * + * Returns a list of raw (un-analyzed) parse trees. + */ +List * +raw_parser(const char *str) +{ + int yyresult; + + if (pool_memory == NULL) + pool_memory = pool_memory_create(PARSER_BLOCK_SIZE); + + parsetree = NIL; /* in case grammar forgets to set it */ + have_lookahead = false; + + scanner_init(str); + parser_init(); + + if (setjmp(jmpbuffer) != 0) + { + scanner_finish(); + return NIL; /* error */ + } + else + { + yyresult = base_yyparse(); + + scanner_finish(); + + if (yyresult) /* error */ + return NIL; + } + return parsetree; +} + +void free_parser(void) +{ + pool_memory_delete(pool_memory, 1); +} + +/* + * Intermediate filter between parser and base lexer (base_yylex in scan.l). + * + * The filter is needed because in some cases the standard SQL grammar + * requires more than one token lookahead. We reduce these cases to one-token + * lookahead by combining tokens here, in order to keep the grammar LALR(1). + * + * Using a filter is simpler than trying to recognize multiword tokens + * directly in scan.l, because we'd have to allow for comments between the + * words. Furthermore it's not clear how to do it without re-introducing + * scanner backtrack, which would cost more performance than this filter + * layer does. + */ +int +filtered_base_yylex(void) +{ + int cur_token; + int next_token; + YYSTYPE cur_yylval; + YYLTYPE cur_yylloc; + + /* Get next token --- we might already have it */ + if (have_lookahead) + { + cur_token = lookahead_token; + base_yylval = lookahead_yylval; + base_yylloc = lookahead_yylloc; + have_lookahead = false; + } + else + cur_token = base_yylex(); + + /* Do we need to look ahead for a possible multiword token? */ + switch (cur_token) + { + case NULLS_P: + /* + * NULLS FIRST and NULLS LAST must be reduced to one token + */ + cur_yylval = base_yylval; + cur_yylloc = base_yylloc; + next_token = base_yylex(); + switch (next_token) + { + case FIRST_P: + cur_token = NULLS_FIRST; + break; + case LAST_P: + cur_token = NULLS_LAST; + break; + default: + /* save the lookahead token for next time */ + lookahead_token = next_token; + lookahead_yylval = base_yylval; + lookahead_yylloc = base_yylloc; + have_lookahead = true; + /* and back up the output info to cur_token */ + base_yylval = cur_yylval; + base_yylloc = cur_yylloc; + break; + } + break; + + case WITH: + /* + * WITH CASCADED, LOCAL, or CHECK must be reduced to one token + * + * XXX an alternative way is to recognize just WITH_TIME and put + * the ugliness into the datetime datatype productions instead of + * WITH CHECK OPTION. However that requires promoting WITH to a + * fully reserved word. If we ever have to do that anyway + * (perhaps for SQL99 recursive queries), come back and simplify + * this code. + */ + cur_yylval = base_yylval; + cur_yylloc = base_yylloc; + next_token = base_yylex(); + switch (next_token) + { + case CASCADED: + cur_token = WITH_CASCADED; + break; + case LOCAL: + cur_token = WITH_LOCAL; + break; + case CHECK: + cur_token = WITH_CHECK; + break; + default: + /* save the lookahead token for next time */ + lookahead_token = next_token; + lookahead_yylval = base_yylval; + lookahead_yylloc = base_yylloc; + have_lookahead = true; + /* and back up the output info to cur_token */ + base_yylval = cur_yylval; + base_yylloc = cur_yylloc; + break; + } + break; + + default: + break; + } + + return cur_token; +} diff --git a/parser/parser.h b/parser/parser.h new file mode 100644 index 0000000..7284b65 --- /dev/null +++ b/parser/parser.h @@ -0,0 +1,25 @@ +/*------------------------------------------------------------------------- + * + * parser.h + * Definitions for the "raw" parser (lex and yacc phases only) + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.19 2004/12/31 22:03:38 pgsql Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PARSER_H +#define PARSER_H + +#include "pg_list.h" +#include "parsenodes.h" + +extern List *raw_parser(const char *str); +extern void free_parser(void); +extern int filtered_base_yylex(void); + +#endif /* PARSER_H */ diff --git a/parser/pg_list.h b/parser/pg_list.h new file mode 100644 index 0000000..4519176 --- /dev/null +++ b/parser/pg_list.h @@ -0,0 +1,325 @@ +/*------------------------------------------------------------------------- + * + * pg_list.h + * interface for PostgreSQL generic linked list package + * + * This package implements singly-linked homogeneous lists. + * + * It is important to have constant-time length, append, and prepend + * operations. To achieve this, we deal with two distinct data + * structures: + * + * 1. A set of "list cells": each cell contains a data field and + * a link to the next cell in the list or NULL. + * 2. A single structure containing metadata about the list: the + * type of the list, pointers to the head and tail cells, and + * the length of the list. + * + * We support three types of lists: + * + * T_List: lists of pointers + * (in practice usually pointers to Nodes, but not always; + * declared as "void *" to minimize casting annoyances) + * T_IntList: lists of integers + * T_OidList: lists of Oids + * + * (At the moment, ints and Oids are the same size, but they may not + * always be so; try to be careful to maintain the distinction.) + * + * There is also limited support for lists of TransactionIds; since these + * are used in only one or two places, we don't provide a full implementation, + * but map them onto Oid lists. This effectively assumes that TransactionId + * is no wider than Oid and both are unsigned types. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.56 2007/01/05 22:19:55 momjian Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PG_LIST_H +#define PG_LIST_H + +#include +#include "pool_parser.h" +#include "nodes.h" + + +typedef struct ListCell ListCell; + +typedef struct List +{ + NodeTag type; /* T_List, T_IntList, or T_OidList */ + int length; + ListCell *head; + ListCell *tail; +} List; + +struct ListCell +{ + union + { + void *ptr_value; + int int_value; + Oid oid_value; + } data; + ListCell *next; +}; + +/* + * The *only* valid representation of an empty list is NIL; in other + * words, a non-NIL list is guaranteed to have length >= 1 and + * head/tail != NULL + */ +#define NIL ((List *) NULL) + +/* + * These routines are used frequently. However, we can't implement + * them as macros, since we want to avoid double-evaluation of macro + * arguments. Therefore, we implement them using GCC inline functions, + * and as regular functions with non-GCC compilers. + */ +#ifdef __GNUC__ + +static __inline__ ListCell * +list_head(List *l) +{ + return l ? l->head : NULL; +} + +static __inline__ ListCell * +list_tail(List *l) +{ + return l ? l->tail : NULL; +} + +static __inline__ int +list_length(List *l) +{ + return l ? l->length : 0; +} +#else + +extern ListCell *list_head(List *l); +extern ListCell *list_tail(List *l); +extern int list_length(List *l); +#endif /* __GNUC__ */ + +/* + * NB: There is an unfortunate legacy from a previous incarnation of + * the List API: the macro lfirst() was used to mean "the data in this + * cons cell". To avoid changing every usage of lfirst(), that meaning + * has been kept. As a result, lfirst() takes a ListCell and returns + * the data it contains; to get the data in the first cell of a + * List, use linitial(). Worse, lsecond() is more closely related to + * linitial() than lfirst(): given a List, lsecond() returns the data + * in the second cons cell. + */ + +#define lnext(lc) ((lc)->next) +#define lfirst(lc) ((lc)->data.ptr_value) +#define lfirst_int(lc) ((lc)->data.int_value) +#define lfirst_oid(lc) ((lc)->data.oid_value) + +#define linitial(l) lfirst(list_head(l)) +#define linitial_int(l) lfirst_int(list_head(l)) +#define linitial_oid(l) lfirst_oid(list_head(l)) + +#define lsecond(l) lfirst(lnext(list_head(l))) +#define lsecond_int(l) lfirst_int(lnext(list_head(l))) +#define lsecond_oid(l) lfirst_oid(lnext(list_head(l))) + +#define lthird(l) lfirst(lnext(lnext(list_head(l)))) +#define lthird_int(l) lfirst_int(lnext(lnext(list_head(l)))) +#define lthird_oid(l) lfirst_oid(lnext(lnext(list_head(l)))) + +#define lfourth(l) lfirst(lnext(lnext(lnext(list_head(l))))) +#define lfourth_int(l) lfirst_int(lnext(lnext(lnext(list_head(l))))) +#define lfourth_oid(l) lfirst_oid(lnext(lnext(lnext(list_head(l))))) + +#define llast(l) lfirst(list_tail(l)) +#define llast_int(l) lfirst_int(list_tail(l)) +#define llast_oid(l) lfirst_oid(list_tail(l)) + +/* + * Convenience macros for building fixed-length lists + */ +#define list_make1(x1) lcons(x1, NIL) +#define list_make2(x1,x2) lcons(x1, list_make1(x2)) +#define list_make3(x1,x2,x3) lcons(x1, list_make2(x2, x3)) +#define list_make4(x1,x2,x3,x4) lcons(x1, list_make3(x2, x3, x4)) + +#define list_make1_int(x1) lcons_int(x1, NIL) +#define list_make2_int(x1,x2) lcons_int(x1, list_make1_int(x2)) +#define list_make3_int(x1,x2,x3) lcons_int(x1, list_make2_int(x2, x3)) +#define list_make4_int(x1,x2,x3,x4) lcons_int(x1, list_make3_int(x2, x3, x4)) + +#define list_make1_oid(x1) lcons_oid(x1, NIL) +#define list_make2_oid(x1,x2) lcons_oid(x1, list_make1_oid(x2)) +#define list_make3_oid(x1,x2,x3) lcons_oid(x1, list_make2_oid(x2, x3)) +#define list_make4_oid(x1,x2,x3,x4) lcons_oid(x1, list_make3_oid(x2, x3, x4)) + +/* + * Limited support for lists of TransactionIds, mapped onto lists of Oids + */ +#define lfirst_xid(lc) ((TransactionId) lfirst_oid(lc)) +#define lappend_xid(list, datum) lappend_oid(list, (Oid) (datum)) + +/* + * foreach - + * a convenience macro which loops through the list + */ +#define foreach(cell, l) \ + for ((cell) = list_head(l); (cell) != NULL; (cell) = lnext(cell)) + +/* + * for_each_cell - + * a convenience macro which loops through a list starting from a + * specified cell + */ +#define for_each_cell(cell, initcell) \ + for ((cell) = (initcell); (cell) != NULL; (cell) = lnext(cell)) + +/* + * forboth - + * a convenience macro for advancing through two linked lists + * simultaneously. This macro loops through both lists at the same + * time, stopping when either list runs out of elements. Depending + * on the requirements of the call site, it may also be wise to + * assert that the lengths of the two lists are equal. + */ +#define forboth(cell1, list1, cell2, list2) \ + for ((cell1) = list_head(list1), (cell2) = list_head(list2); \ + (cell1) != NULL && (cell2) != NULL; \ + (cell1) = lnext(cell1), (cell2) = lnext(cell2)) + +extern List *lappend(List *list, void *datum); +extern List *lappend_int(List *list, int datum); +extern List *lappend_oid(List *list, Oid datum); + +extern ListCell *lappend_cell(List *list, ListCell *prev, void *datum); +extern ListCell *lappend_cell_int(List *list, ListCell *prev, int datum); +extern ListCell *lappend_cell_oid(List *list, ListCell *prev, Oid datum); + +extern List *lcons(void *datum, List *list); +extern List *lcons_int(int datum, List *list); +extern List *lcons_oid(Oid datum, List *list); + +extern List *list_concat(List *list1, List *list2); +extern List *list_truncate(List *list, int new_size); + +extern void *list_nth(List *list, int n); +extern int list_nth_int(List *list, int n); +extern Oid list_nth_oid(List *list, int n); + +extern bool list_member(List *list, void *datum); +extern bool list_member_ptr(List *list, void *datum); +extern bool list_member_int(List *list, int datum); +extern bool list_member_oid(List *list, Oid datum); + +extern List *list_delete(List *list, void *datum); +extern List *list_delete_ptr(List *list, void *datum); +extern List *list_delete_int(List *list, int datum); +extern List *list_delete_oid(List *list, Oid datum); +extern List *list_delete_first(List *list); +extern List *list_delete_cell(List *list, ListCell *cell, ListCell *prev); + +extern List *list_union(List *list1, List *list2); +extern List *list_union_ptr(List *list1, List *list2); +extern List *list_union_int(List *list1, List *list2); +extern List *list_union_oid(List *list1, List *list2); + +extern List *list_difference(List *list1, List *list2); +extern List *list_difference_ptr(List *list1, List *list2); +extern List *list_difference_int(List *list1, List *list2); +extern List *list_difference_oid(List *list1, List *list2); + +extern List *list_append_unique(List *list, void *datum); +extern List *list_append_unique_ptr(List *list, void *datum); +extern List *list_append_unique_int(List *list, int datum); +extern List *list_append_unique_oid(List *list, Oid datum); + +extern List *list_concat_unique(List *list1, List *list2); +extern List *list_concat_unique_ptr(List *list1, List *list2); +extern List *list_concat_unique_int(List *list1, List *list2); +extern List *list_concat_unique_oid(List *list1, List *list2); + +extern void list_free(List *list); +extern void list_free_deep(List *list); + +extern List *list_copy(List *list); +extern List *list_copy_tail(List *list, int nskip); + +/* + * To ease migration to the new list API, a set of compatibility + * macros are provided that reduce the impact of the list API changes + * as far as possible. Until client code has been rewritten to use the + * new list API, the ENABLE_LIST_COMPAT symbol can be defined before + * including pg_list.h + */ +#ifdef ENABLE_LIST_COMPAT + +#define lfirsti(lc) lfirst_int(lc) +#define lfirsto(lc) lfirst_oid(lc) + +#define makeList1(x1) list_make1(x1) +#define makeList2(x1, x2) list_make2(x1, x2) +#define makeList3(x1, x2, x3) list_make3(x1, x2, x3) +#define makeList4(x1, x2, x3, x4) list_make4(x1, x2, x3, x4) + +#define makeListi1(x1) list_make1_int(x1) +#define makeListi2(x1, x2) list_make2_int(x1, x2) + +#define makeListo1(x1) list_make1_oid(x1) +#define makeListo2(x1, x2) list_make2_oid(x1, x2) + +#define lconsi(datum, list) lcons_int(datum, list) +#define lconso(datum, list) lcons_oid(datum, list) + +#define lappendi(list, datum) lappend_int(list, datum) +#define lappendo(list, datum) lappend_oid(list, datum) + +#define nconc(l1, l2) list_concat(l1, l2) + +#define nth(n, list) list_nth(list, n) + +#define member(datum, list) list_member(list, datum) +#define ptrMember(datum, list) list_member_ptr(list, datum) +#define intMember(datum, list) list_member_int(list, datum) +#define oidMember(datum, list) list_member_oid(list, datum) + +/* + * Note that the old lremove() determined equality via pointer + * comparison, whereas the new list_delete() uses equal(); in order to + * keep the same behavior, we therefore need to map lremove() calls to + * list_delete_ptr() rather than list_delete() + */ +#define lremove(elem, list) list_delete_ptr(list, elem) +#define LispRemove(elem, list) list_delete(list, elem) +#define lremovei(elem, list) list_delete_int(list, elem) +#define lremoveo(elem, list) list_delete_oid(list, elem) + +#define ltruncate(n, list) list_truncate(list, n) + +#define set_union(l1, l2) list_union(l1, l2) +#define set_uniono(l1, l2) list_union_oid(l1, l2) +#define set_ptrUnion(l1, l2) list_union_ptr(l1, l2) + +#define set_difference(l1, l2) list_difference(l1, l2) +#define set_differenceo(l1, l2) list_difference_oid(l1, l2) +#define set_ptrDifference(l1, l2) list_difference_ptr(l1, l2) + +#define equali(l1, l2) equal(l1, l2) +#define equalo(l1, l2) equal(l1, l2) + +#define freeList(list) list_free(list) + +#define listCopy(list) list_copy(list) + +extern int length(List *list); +#endif /* ENABLE_LIST_COMPAT */ + +#endif /* PG_LIST_H */ diff --git a/parser/pool_memory.c b/parser/pool_memory.c new file mode 100644 index 0000000..d4a0e52 --- /dev/null +++ b/parser/pool_memory.c @@ -0,0 +1,312 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_memory.c,v 1.10 2008/01/29 01:56:39 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_memory.c: Memory pooling module for SQL parser. + * + */ + +#include "pool.h" +#include "pool_memory.h" +#include +#include +#include + +#define ALIGN 3 +#define POOL_HEADER_SIZE (sizeof (POOL_CHUNK_HEADER)) + +POOL_MEMORY_POOL *pool_memory = NULL; + +static int get_free_index(unsigned int size); + +static int get_free_index(unsigned int size) +{ + int idx = 0; + + if (size > 0) + { + size = (size - 1) >> ALIGN; + while (size) + { + size >>= 1; + idx++; + } + } + return idx; +} + +/* + * pool_memory_alloc: + * Returns pointer to allocated memory of given size. + */ +void *pool_memory_alloc(POOL_MEMORY_POOL *pool, unsigned int size) +{ + POOL_BLOCK *block; + POOL_CHUNK *chunk; + + if ((size + POOL_HEADER_SIZE) > pool->blocksize) + { + block = malloc(sizeof(POOL_BLOCK)); + if (block == NULL) + { + pool_error("pool_memory_alloc: malloc failed: %s", strerror(errno)); + child_exit(1); + } + block->allocsize = block->size = size + POOL_HEADER_SIZE; + block->block = malloc(size + POOL_HEADER_SIZE); + if (block->block == NULL) + { + pool_error("pool_memory_alloc: malloc failed: %s", strerror(errno)); + child_exit(1); + } + block->freepoint = block + (size + POOL_HEADER_SIZE); + chunk = block->block; + chunk->header.size = size + POOL_HEADER_SIZE; + block->next = pool->largeblocks; + pool->largeblocks = block; + } + else + { + int fidx = get_free_index(size + POOL_HEADER_SIZE); + int allocsize = 1 << (fidx + ALIGN); + + /* pick up from freelist */ + if (pool->freelist[fidx] != NULL) + { + chunk = pool->freelist[fidx]; + pool->freelist[fidx] = chunk->header.next; + chunk->header.size = allocsize; + return chunk->data; + } + + block = pool->blocks; + if (block == NULL || + block->freepoint + allocsize > block->block + block->size) + { + block = malloc(sizeof(POOL_BLOCK)); + if (block == NULL) + { + pool_error("pool_memory_alloc: malloc failed: %s", strerror(errno)); + child_exit(1); + } + block->size = pool->blocksize; + block->allocsize = 0; + block->block = malloc(pool->blocksize); + if (block->block == NULL) + { + pool_error("pool_memory_alloc: malloc failed: %s", strerror(errno)); + child_exit(1); + } + block->freepoint = block->block; + block->next = pool->blocks; + pool->blocks = block; + } + + block = pool->blocks; + chunk = block->freepoint; + block->freepoint += allocsize; + block->allocsize += allocsize; + chunk->header.size = allocsize; + } + return chunk->data; +} + + +/* + * pool_memory_alloc_zero: + * Returns pointer to allocated memory of given size. + * The allocated memory is cleared. + */ +void *pool_memory_alloc_zero(POOL_MEMORY_POOL *pool, unsigned int size) +{ + void *ptr = pool_memory_alloc(pool, size); + memset(ptr, 0, size); + return ptr; +} + +/* + * pool_memory_free: + * Frees allocated memory into memory pool. + */ +void pool_memory_free(POOL_MEMORY_POOL *pool, void *ptr) +{ + POOL_CHUNK *chunk = ptr - POOL_HEADER_SIZE; + int fidx; + + if (ptr == NULL) + return; + + if (chunk->header.size > pool->blocksize) + { + POOL_BLOCK *block, *ptr = NULL; + + for (block = pool->largeblocks; block; ptr = block, block = block->next) + { + if (block->block == chunk) + break; + } + + if (block == NULL) + { + pool_log("An adress \"%p\" does not exist in memory pool.", chunk); + return; + } + + if (ptr == NULL) + { + pool->largeblocks = block->next; + } + else + { + ptr->next = block->next; + } + free(block->block); + free(block); + } + else + { + fidx = get_free_index(chunk->header.size); + chunk->header.next = pool->freelist[fidx]; + pool->freelist[fidx] = chunk; + } +} + +/* + * pool_memory_realloc: + * Returns new pointer to allocated memory of given size. + * The new memory is copied from the old memory, and the old + * memory is freed. + */ +void *pool_memory_realloc(POOL_MEMORY_POOL *pool, void *ptr, unsigned int size) +{ + int fidx; + void *p; + POOL_CHUNK *chunk = ptr - POOL_HEADER_SIZE; + + if (size <= chunk->header.size - POOL_HEADER_SIZE) + return ptr; + + fidx = get_free_index(size + POOL_HEADER_SIZE); + if (size + POOL_HEADER_SIZE <= pool->blocksize && + chunk->header.size <= pool->blocksize && + fidx == get_free_index(chunk->header.size)) + { + return ptr; + } + + p = pool_memory_alloc(pool, size); + memmove(p, ptr, chunk->header.size - POOL_HEADER_SIZE); + pool_memory_free(pool, ptr); + + return p; +} + +/* + * pool_memory_create: + * Create a new memory pool. + */ +POOL_MEMORY_POOL *pool_memory_create(int blocksize) +{ + POOL_MEMORY_POOL *pool; + int i; + + pool = malloc(sizeof(POOL_MEMORY_POOL)); + if (pool == NULL) + { + pool_error("pool_memory_create: malloc failed: %s", strerror(errno)); + child_exit(1); + } + pool->blocks = NULL; + pool->largeblocks = NULL; + pool->blocksize = blocksize; + + for (i = 0; i < SLOT_NUM; i++) + { + pool->freelist[i] = NULL; + } + + return pool; +} + +/* + * pool_memory_delete: + * Frees all memory which is allocated in the memory pool. + */ +void pool_memory_delete(POOL_MEMORY_POOL *pool_memory, int reuse) +{ + POOL_BLOCK *block, *ptr; + + /* Reuse the first memory block */ + if (reuse && pool_memory->blocks) + block = pool_memory->blocks->next; + else + block = pool_memory->blocks; + + while (block) + { + ptr = block->next; + free(block->block); + free(block); + block = ptr; + } + + for (block = pool_memory->largeblocks; block;) + { + ptr = block->next; + free(block->block); + free(block); + block = ptr; + } + + if (reuse) + { + int i; + + if (pool_memory->blocks) + { + pool_memory->blocks->next = NULL; + pool_memory->blocks->allocsize = 0; + pool_memory->blocks->freepoint = pool_memory->blocks->block; + } + pool_memory->largeblocks = NULL; + for (i = 0; i < SLOT_NUM; i++) + { + pool_memory->freelist[i] = NULL; + } + } + else + { + free(pool_memory); + pool_memory = NULL; + } +} + +/* + * pool_memory_strdup: + * Creates the new string which is copied the given string. + */ +char *pool_memory_strdup(POOL_MEMORY_POOL *pool_memory, const char *string) +{ + int len = strlen(string); + char *str = pool_memory_alloc(pool_memory, len + 1); + + memmove(str, string, len); + str[len] = '\0'; + return str; +} diff --git a/parser/pool_memory.h b/parser/pool_memory.h new file mode 100644 index 0000000..4812328 --- /dev/null +++ b/parser/pool_memory.h @@ -0,0 +1,75 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_memory.h,v 1.5 2008/01/29 01:56:39 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_memory.h: Memory pooling module for SQL parser. + * + */ + +#ifndef POOL_MEMORY_H +#define POOL_MEMORY_H + +#define SLOT_NUM 11 + +#define PARSER_BLOCK_SIZE 8192 +#define PREPARE_BLOCK_SIZE 1024 + +typedef struct POOL_BLOCK { + int size; + int allocsize; + void *block; + void *freepoint; + struct POOL_BLOCK *next; +} POOL_BLOCK; + +typedef union { + unsigned int size; + struct POOL_CHUNK *next; +} POOL_CHUNK_HEADER; + +typedef struct POOL_CHUNK { + POOL_CHUNK_HEADER header; + char data[1]; +} POOL_CHUNK; + +typedef struct { + int size; + int blocksize; + POOL_BLOCK *blocks; + POOL_BLOCK *largeblocks; + POOL_CHUNK *freelist[SLOT_NUM]; +} POOL_MEMORY_POOL; + +extern POOL_MEMORY_POOL *pool_memory; + +extern void *pool_memory_alloc(POOL_MEMORY_POOL *pool, unsigned int size); +extern void pool_memory_free(POOL_MEMORY_POOL *pool, void *ptr); +extern void *pool_memory_realloc(POOL_MEMORY_POOL *pool, void *ptr, unsigned int size); +extern POOL_MEMORY_POOL *pool_memory_create(int blocksize); +extern void pool_memory_delete(POOL_MEMORY_POOL *pool_memory, int reuse); +extern char *pool_memory_strdup(POOL_MEMORY_POOL *pool_memory, const char *string); +extern void *pool_memory_alloc_zero(POOL_MEMORY_POOL *pool_memory, unsigned int size); + +#define palloc(s) pool_memory_alloc(pool_memory, (s)) +#define pfree(p) pool_memory_free(pool_memory, (p)) +#define repalloc(p, s) pool_memory_realloc(pool_memory, (p), (s)) +#define pstrdup(s) pool_memory_strdup(pool_memory, (s)) +#define palloc0(s) pool_memory_alloc_zero(pool_memory, (s)) + +#endif /* POOL_MEMORY_H */ diff --git a/parser/pool_parser.h b/parser/pool_parser.h new file mode 100644 index 0000000..9559f29 --- /dev/null +++ b/parser/pool_parser.h @@ -0,0 +1,117 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_parser.h,v 1.5 2008/01/29 01:56:39 y-asaba Exp $ + * + * Copyright (c) 2006-2008, pgpool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + */ + +#ifndef POOL_PARSER_H +#define POOL_PARSER_H + +#include "../pool_type.h" +#include + +extern jmp_buf jmpbuffer; + +/* integer */ +typedef signed int int32; +typedef signed short int16; +typedef unsigned int PoolOid; +typedef unsigned int Index; +typedef short AttrNumber; +typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */ + +#define Oid PoolOid +#define InvalidOid ((Oid) 0) + +/* + * NAMEDATALEN is the max length for system identifiers (e.g. table names, + * attribute names, function names, etc). It must be a multiple of + * sizeof(int) (typically 4). + * + * NOTE that databases with different NAMEDATALEN's cannot interoperate! + */ +#define NAMEDATALEN 64 + + +/* date and datetime */ +#define RESERV 0 +#define MONTH 1 +#define YEAR 2 +#define DAY 3 +#define JULIAN 4 +#define TZ 5 +#define DTZ 6 +#define DTZMOD 7 +#define IGNORE_DTF 8 +#define AMPM 9 +#define HOUR 10 +#define MINUTE 11 +#define SECOND 12 +#define DOY 13 +#define DOW 14 +#define UNITS 15 +#define ADBC 16 +/* these are only for relative dates */ +#define AGO 17 +#define ABS_BEFORE 18 +#define ABS_AFTER 19 +/* generic fields to help with parsing */ +#define ISODATE 20 +#define ISOTIME 21 +/* reserved for unrecognized string values */ +#define UNKNOWN_FIELD 31 +#define MAX_TIMESTAMP_PRECISION 6 +#define MAX_INTERVAL_PRECISION 6 +#define INTERVAL_FULL_RANGE (0x7FFF) +#define INTERVAL_RANGE_MASK (0x7FFF) +#define INTERVAL_FULL_PRECISION (0xFFFF) +#define INTERVAL_PRECISION_MASK (0xFFFF) + +#define INTERVAL_MASK(b) (1 << (b)) +#define INTERVAL_TYPMOD(p,r) ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK)) +#define INTERVAL_PRECISION(t) ((t) & INTERVAL_PRECISION_MASK) +#define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK) + + +/* lock */ +/* NoLock is not a lock mode, but a flag value meaning "don't get a lock" */ +#define NoLock 0 + +#define AccessShareLock 1 /* SELECT */ +#define RowShareLock 2 /* SELECT FOR UPDATE/FOR SHARE */ +#define RowExclusiveLock 3 /* INSERT, UPDATE, DELETE */ +#define ShareUpdateExclusiveLock 4 /* VACUUM (non-FULL) */ +#define ShareLock 5 /* CREATE INDEX */ +#define ShareRowExclusiveLock 6 /* like EXCLUSIVE MODE, but allows ROW + * SHARE */ +#define ExclusiveLock 7 /* blocks ROW SHARE/SELECT...FOR + * UPDATE */ +#define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM + * FULL, and unqualified LOCK TABLE */ + +#define DEFAULT_INDEX_TYPE "btree" +#define NUMERIC_MAX_PRECISION 1000 + +#define VARHDRSZ ((int32) sizeof(int32)) + +#define MaxAttrSize (10 * 1024 * 1024) +#define BITS_PER_BYTE 8 +#define MAX_TIME_PRECISION 6 + +/* array */ +#define lengthof(array) (sizeof(array) / sizeof(((array)[0]))) +#define endof(array) (&(array)[lengthof(array)]) + +#endif /* POOL_PARSER_H */ diff --git a/parser/pool_string.c b/parser/pool_string.c new file mode 100644 index 0000000..d45b4a0 --- /dev/null +++ b/parser/pool_string.c @@ -0,0 +1,121 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_string.c,v 1.4 2008/01/29 01:56:39 y-asaba Exp $ + * + * Copyright (c) 2006-2008, pgpool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + */ +#include "pool.h" +#include "pool_parser.h" + +#include +#include +#include + +#include "pool_memory.h" +#include "pool_string.h" +#include "value.h" + +/* String Library */ +String *init_string(char *str) +{ + String *string = palloc(sizeof(String)); + int size; + + if (string == NULL) + { + pool_error("init_string: palloc failed: %s", strerror(errno)); + child_exit(1); + } + + size = (strlen(str) + 1) / STRING_SIZE + 1; + string->size = size; + string->data = palloc(STRING_SIZE * size); + if (string->data == NULL) + { + pool_error("init_string: palloc failed: %s", strerror(errno)); + pfree(string); + child_exit(1); + } + + memset(string->data, 0, STRING_SIZE * size); + + if (str == NULL) + { + string->len = 0; + } + else + { + string->len = strlen(str); + memcpy(string->data, str, string->len); + } + + return string; +} + +void string_append_string(String *string, String *data) +{ + string_append_char(string, data->data); +} + +void string_append_char(String *string, char *append_data) +{ + int len = strlen(append_data); + + if (string->len + len + 1 > string->size * STRING_SIZE) + { + int size, old_size; + size = (string->len + len + 1) / STRING_SIZE + 1; + old_size = string->size; + string->size = size; + string->data = repalloc(string->data, string->size * STRING_SIZE); + if (string->data == NULL) + { + pool_error("string_append_char: realloc failed: %s", strerror(errno)); + child_exit(1); + } + memset(string->data + (old_size * STRING_SIZE), + 0, STRING_SIZE * (string->size - old_size)); + } + memcpy(string->data + string->len, append_data, len); + string->len += len; +} + +void free_string(String *string) +{ + pfree(string->data); + pfree(string); +} + +String *copy_string(String *string) +{ + String *copy = palloc(sizeof(String)); + + if (copy == NULL) + { + pool_error("copy_string: palloc failed: %s", strerror(errno)); + child_exit(1); + } + copy->size = string->size; + copy->len = string->len; + copy->data = palloc(string->size * STRING_SIZE); + if (copy->data == NULL) + { + pool_error("copy_string: palloc failed: %s", strerror(errno)); + pfree(copy); + child_exit(1); + } + memcpy(copy->data, string->data, string->size * STRING_SIZE); + + return copy; +} diff --git a/parser/pool_string.h b/parser/pool_string.h new file mode 100644 index 0000000..b731fbe --- /dev/null +++ b/parser/pool_string.h @@ -0,0 +1,37 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/parser/pool_string.h,v 1.4 2008/01/29 01:56:39 y-asaba Exp $ + * + * Copyright (c) 2006-2008, pgpool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + */ + +#ifndef POOL_STRING_H +#define POOL_STRING_H + +#define STRING_SIZE 128 + +typedef struct +{ + int size; + int len; + char *data; +} String; + +extern String *init_string(char *str); +extern void string_append_string(String *string, String *append_data); +extern void string_append_char(String *string, char *append_data); +extern void free_string(String *string); +extern String *copy_string(String *string); + +#endif /* POOL_STRING_H */ diff --git a/parser/primnodes.h b/parser/primnodes.h new file mode 100644 index 0000000..86cad18 --- /dev/null +++ b/parser/primnodes.h @@ -0,0 +1,1100 @@ +/*------------------------------------------------------------------------- + * + * primnodes.h + * Definitions for "primitive" node types, those that are used in more + * than one of the parse/plan/execute stages of the query pipeline. + * Currently, these are mostly nodes for executable expressions + * and join trees. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.133 2007/08/26 21:44:25 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PRIMNODES_H +#define PRIMNODES_H + +#include "pg_list.h" + + +/* ---------------------------------------------------------------- + * node definitions + * ---------------------------------------------------------------- + */ + +/* + * Alias - + * specifies an alias for a range variable; the alias might also + * specify renaming of columns within the table. + * + * Note: colnames is a list of Value nodes (always strings). In Alias structs + * associated with RTEs, there may be entries corresponding to dropped + * columns; these are normally empty strings (""). See parsenodes.h for info. + */ +typedef struct Alias +{ + NodeTag type; + char *aliasname; /* aliased rel name (never qualified) */ + List *colnames; /* optional list of column aliases */ +} Alias; + +typedef enum InhOption +{ + INH_NO, /* Do NOT scan child tables */ + INH_YES, /* DO scan child tables */ + INH_DEFAULT /* Use current SQL_inheritance option */ +} InhOption; + +/* What to do at commit time for temporary relations */ +typedef enum OnCommitAction +{ + ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */ + ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */ + ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */ + ONCOMMIT_DROP /* ON COMMIT DROP */ +} OnCommitAction; + +/* + * RangeVar - range variable, used in FROM clauses + * + * Also used to represent table names in utility statements; there, the alias + * field is not used, and inhOpt shows whether to apply the operation + * recursively to child tables. In some contexts it is also useful to carry + * a TEMP table indication here. + */ +typedef struct RangeVar +{ + NodeTag type; + char *catalogname; /* the catalog (database) name, or NULL */ + char *schemaname; /* the schema name, or NULL */ + char *relname; /* the relation/sequence name */ + InhOption inhOpt; /* expand rel by inheritance? recursively act + * on children? */ + bool istemp; /* is this a temp relation/sequence? */ + Alias *alias; /* table alias & optional column aliases */ +} RangeVar; + +/* + * IntoClause - target information for SELECT INTO and CREATE TABLE AS + */ +typedef struct IntoClause +{ + NodeTag type; + + RangeVar *rel; /* target relation name */ + List *colNames; /* column names to assign, or NIL */ + List *options; /* options from WITH clause */ + OnCommitAction onCommit; /* what do we do at COMMIT? */ + char *tableSpaceName; /* table space to use, or NULL */ +} IntoClause; + + +/* ---------------------------------------------------------------- + * node types for executable expressions + * ---------------------------------------------------------------- + */ + +/* + * Expr - generic superclass for executable-expression nodes + * + * All node types that are used in executable expression trees should derive + * from Expr (that is, have Expr as their first field). Since Expr only + * contains NodeTag, this is a formality, but it is an easy form of + * documentation. See also the ExprState node types in execnodes.h. + */ +typedef struct Expr +{ + NodeTag type; +} Expr; + +/* + * Var - expression node representing a variable (ie, a table column) + * + * Note: during parsing/planning, varnoold/varoattno are always just copies + * of varno/varattno. At the tail end of planning, Var nodes appearing in + * upper-level plan nodes are reassigned to point to the outputs of their + * subplans; for example, in a join node varno becomes INNER or OUTER and + * varattno becomes the index of the proper element of that subplan's target + * list. But varnoold/varoattno continue to hold the original values. + * The code doesn't really need varnoold/varoattno, but they are very useful + * for debugging and interpreting completed plans, so we keep them around. + */ +#define INNER 65000 +#define OUTER 65001 + +#define PRS2_OLD_VARNO 1 +#define PRS2_NEW_VARNO 2 + +typedef struct Var +{ + Expr xpr; + Index varno; /* index of this var's relation in the range + * table (could also be INNER or OUTER) */ + AttrNumber varattno; /* attribute number of this var, or zero for + * all */ + Oid vartype; /* pg_type OID for the type of this var */ + int32 vartypmod; /* pg_attribute typmod value */ + Index varlevelsup; + + /* + * for subquery variables referencing outer relations; 0 in a normal var, + * >0 means N levels up + */ + Index varnoold; /* original value of varno, for debugging */ + AttrNumber varoattno; /* original value of varattno */ +} Var; + +/* + * Const + */ +typedef struct Const +{ + Expr xpr; + Oid consttype; /* pg_type OID of the constant's datatype */ + int32 consttypmod; /* typmod value, if any */ + int constlen; /* typlen of the constant's datatype */ + Datum constvalue; /* the constant's value */ + bool constisnull; /* whether the constant is null (if true, + * constvalue is undefined) */ + bool constbyval; /* whether this datatype is passed by value. + * If true, then all the information is stored + * in the Datum. If false, then the Datum + * contains a pointer to the information. */ +} Const; + +/* ---------------- + * Param + * paramkind - specifies the kind of parameter. The possible values + * for this field are: + * + * PARAM_EXTERN: The parameter value is supplied from outside the plan. + * Such parameters are numbered from 1 to n. + * + * PARAM_EXEC: The parameter is an internal executor parameter, used + * for passing values into and out of sub-queries. + * For historical reasons, such parameters are numbered from 0. + * These numbers are independent of PARAM_EXTERN numbers. + * + * PARAM_SUBLINK: The parameter represents an output column of a SubLink + * node's sub-select. The column number is contained in the + * `paramid' field. (This type of Param is converted to + * PARAM_EXEC during planning.) + * + * Note: currently, paramtypmod is valid for PARAM_SUBLINK Params, and for + * PARAM_EXEC Params generated from them; it is always -1 for PARAM_EXTERN + * params, since the APIs that supply values for such parameters don't carry + * any typmod info. + * ---------------- + */ +typedef enum ParamKind +{ + PARAM_EXTERN, + PARAM_EXEC, + PARAM_SUBLINK +} ParamKind; + +typedef struct Param +{ + Expr xpr; + ParamKind paramkind; /* kind of parameter. See above */ + int paramid; /* numeric ID for parameter */ + Oid paramtype; /* pg_type OID of parameter's datatype */ + int32 paramtypmod; /* typmod value, if known */ +} Param; + +/* + * Aggref + */ +typedef struct Aggref +{ + Expr xpr; + Oid aggfnoid; /* pg_proc Oid of the aggregate */ + Oid aggtype; /* type Oid of result of the aggregate */ + List *args; /* arguments to the aggregate */ + Index agglevelsup; /* > 0 if agg belongs to outer query */ + bool aggstar; /* TRUE if argument list was really '*' */ + bool aggdistinct; /* TRUE if it's agg(DISTINCT ...) */ +} Aggref; + +/* ---------------- + * ArrayRef: describes an array subscripting operation + * + * An ArrayRef can describe fetching a single element from an array, + * fetching a subarray (array slice), storing a single element into + * an array, or storing a slice. The "store" cases work with an + * initial array value and a source value that is inserted into the + * appropriate part of the array; the result of the operation is an + * entire new modified array value. + * + * If reflowerindexpr = NIL, then we are fetching or storing a single array + * element at the subscripts given by refupperindexpr. Otherwise we are + * fetching or storing an array slice, that is a rectangular subarray + * with lower and upper bounds given by the index expressions. + * reflowerindexpr must be the same length as refupperindexpr when it + * is not NIL. + * + * Note: the result datatype is the element type when fetching a single + * element; but it is the array type when doing subarray fetch or either + * type of store. + * ---------------- + */ +typedef struct ArrayRef +{ + Expr xpr; + Oid refarraytype; /* type of the array proper */ + Oid refelemtype; /* type of the array elements */ + int32 reftypmod; /* typmod of the array (and elements too) */ + List *refupperindexpr;/* expressions that evaluate to upper array + * indexes */ + List *reflowerindexpr;/* expressions that evaluate to lower array + * indexes */ + Expr *refexpr; /* the expression that evaluates to an array + * value */ + Expr *refassgnexpr; /* expression for the source value, or NULL if + * fetch */ +} ArrayRef; + +/* + * CoercionContext - distinguishes the allowed set of type casts + * + * NB: ordering of the alternatives is significant; later (larger) values + * allow more casts than earlier ones. + */ +typedef enum CoercionContext +{ + COERCION_IMPLICIT, /* coercion in context of expression */ + COERCION_ASSIGNMENT, /* coercion in context of assignment */ + COERCION_EXPLICIT /* explicit cast operation */ +} CoercionContext; + +/* + * CoercionForm - information showing how to display a function-call node + */ +typedef enum CoercionForm +{ + COERCE_EXPLICIT_CALL, /* display as a function call */ + COERCE_EXPLICIT_CAST, /* display as an explicit cast */ + COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */ + COERCE_DONTCARE /* special case for planner */ +} CoercionForm; + +/* + * FuncExpr - expression node for a function call + */ +typedef struct FuncExpr +{ + Expr xpr; + Oid funcid; /* PG_PROC OID of the function */ + Oid funcresulttype; /* PG_TYPE OID of result value */ + bool funcretset; /* true if function returns set */ + CoercionForm funcformat; /* how to display this function call */ + List *args; /* arguments to the function */ +} FuncExpr; + +/* + * OpExpr - expression node for an operator invocation + * + * Semantically, this is essentially the same as a function call. + * + * Note that opfuncid is not necessarily filled in immediately on creation + * of the node. The planner makes sure it is valid before passing the node + * tree to the executor, but during parsing/planning opfuncid is typically 0. + */ +typedef struct OpExpr +{ + Expr xpr; + Oid opno; /* PG_OPERATOR OID of the operator */ + Oid opfuncid; /* PG_PROC OID of underlying function */ + Oid opresulttype; /* PG_TYPE OID of result value */ + bool opretset; /* true if operator returns set */ + List *args; /* arguments to the operator (1 or 2) */ +} OpExpr; + +/* + * DistinctExpr - expression node for "x IS DISTINCT FROM y" + * + * Except for the nodetag, this is represented identically to an OpExpr + * referencing the "=" operator for x and y. + * We use "=", not the more obvious "<>", because more datatypes have "=" + * than "<>". This means the executor must invert the operator result. + * Note that the operator function won't be called at all if either input + * is NULL, since then the result can be determined directly. + */ +typedef OpExpr DistinctExpr; + +/* + * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)" + * + * The operator must yield boolean. It is applied to the left operand + * and each element of the righthand array, and the results are combined + * with OR or AND (for ANY or ALL respectively). The node representation + * is almost the same as for the underlying operator, but we need a useOr + * flag to remember whether it's ANY or ALL, and we don't have to store + * the result type because it must be boolean. + */ +typedef struct ScalarArrayOpExpr +{ + Expr xpr; + Oid opno; /* PG_OPERATOR OID of the operator */ + Oid opfuncid; /* PG_PROC OID of underlying function */ + bool useOr; /* true for ANY, false for ALL */ + List *args; /* the scalar and array operands */ +} ScalarArrayOpExpr; + +/* + * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT + * + * Notice the arguments are given as a List. For NOT, of course the list + * must always have exactly one element. For AND and OR, the executor can + * handle any number of arguments. The parser treats AND and OR as binary + * and so it only produces two-element lists, but the optimizer will flatten + * trees of AND and OR nodes to produce longer lists when possible. + */ +typedef enum BoolExprType +{ + AND_EXPR, OR_EXPR, NOT_EXPR +} BoolExprType; + +typedef struct BoolExpr +{ + Expr xpr; + BoolExprType boolop; + List *args; /* arguments to this expression */ +} BoolExpr; + +/* + * SubLink + * + * A SubLink represents a subselect appearing in an expression, and in some + * cases also the combining operator(s) just above it. The subLinkType + * indicates the form of the expression represented: + * EXISTS_SUBLINK EXISTS(SELECT ...) + * ALL_SUBLINK (lefthand) op ALL (SELECT ...) + * ANY_SUBLINK (lefthand) op ANY (SELECT ...) + * ROWCOMPARE_SUBLINK (lefthand) op (SELECT ...) + * EXPR_SUBLINK (SELECT with single targetlist item ...) + * ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...) + * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the + * same length as the subselect's targetlist. ROWCOMPARE will *always* have + * a list with more than one entry; if the subselect has just one target + * then the parser will create an EXPR_SUBLINK instead (and any operator + * above the subselect will be represented separately). Note that both + * ROWCOMPARE and EXPR require the subselect to deliver only one row. + * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean + * results. ALL and ANY combine the per-row results using AND and OR + * semantics respectively. + * ARRAY requires just one target column, and creates an array of the target + * column's type using any number of rows resulting from the subselect. + * + * SubLink is classed as an Expr node, but it is not actually executable; + * it must be replaced in the expression tree by a SubPlan node during + * planning. + * + * NOTE: in the raw output of gram.y, testexpr contains just the raw form + * of the lefthand expression (if any), and operName is the String name of + * the combining operator. Also, subselect is a raw parsetree. During parse + * analysis, the parser transforms testexpr into a complete boolean expression + * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the + * output columns of the subselect. And subselect is transformed to a Query. + * This is the representation seen in saved rules and in the rewriter. + * + * In EXISTS, EXPR, and ARRAY SubLinks, testexpr and operName are unused and + * are always null. + */ +typedef enum SubLinkType +{ + EXISTS_SUBLINK, + ALL_SUBLINK, + ANY_SUBLINK, + ROWCOMPARE_SUBLINK, + EXPR_SUBLINK, + ARRAY_SUBLINK +} SubLinkType; + + +typedef struct SubLink +{ + Expr xpr; + SubLinkType subLinkType; /* see above */ + Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */ + List *operName; /* originally specified operator name */ + Node *subselect; /* subselect as Query* or parsetree */ +} SubLink; + +/* + * SubPlan - executable expression node for a subplan (sub-SELECT) + * + * The planner replaces SubLink nodes in expression trees with SubPlan + * nodes after it has finished planning the subquery. SubPlan references + * a sub-plantree stored in the subplans list of the toplevel PlannedStmt. + * (We avoid a direct link to make it easier to copy expression trees + * without causing multiple processing of the subplan.) + * + * In an ordinary subplan, testexpr points to an executable expression + * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining + * operator(s); the left-hand arguments are the original lefthand expressions, + * and the right-hand arguments are PARAM_EXEC Param nodes representing the + * outputs of the sub-select. (NOTE: runtime coercion functions may be + * inserted as well.) This is just the same expression tree as testexpr in + * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by + * suitably numbered PARAM_EXEC nodes. + * + * If the sub-select becomes an initplan rather than a subplan, the executable + * expression is part of the outer plan's expression tree (and the SubPlan + * node itself is not). In this case testexpr is NULL to avoid duplication. + * + * The planner also derives lists of the values that need to be passed into + * and out of the subplan. Input values are represented as a list "args" of + * expressions to be evaluated in the outer-query context (currently these + * args are always just Vars, but in principle they could be any expression). + * The values are assigned to the global PARAM_EXEC params indexed by parParam + * (the parParam and args lists must have the same ordering). setParam is a + * list of the PARAM_EXEC params that are computed by the sub-select, if it + * is an initplan; they are listed in order by sub-select output column + * position. (parParam and setParam are integer Lists, not Bitmapsets, + * because their ordering is significant.) + */ +typedef struct SubPlan +{ + Expr xpr; + /* Fields copied from original SubLink: */ + SubLinkType subLinkType; /* see above */ + /* The combining operators, transformed to an executable expression: */ + Node *testexpr; /* OpExpr or RowCompareExpr expression tree */ + List *paramIds; /* IDs of Params embedded in the above */ + /* Identification of the Plan tree to use: */ + int plan_id; /* Index (from 1) in PlannedStmt.subplans */ + /* Extra data useful for determining subplan's output type: */ + Oid firstColType; /* Type of first column of subplan result */ + /* Information about execution strategy: */ + bool useHashTable; /* TRUE to store subselect output in a hash + * table (implies we are doing "IN") */ + bool unknownEqFalse; /* TRUE if it's okay to return FALSE when the + * spec result is UNKNOWN; this allows much + * simpler handling of null values */ + /* Information for passing params into and out of the subselect: */ + /* setParam and parParam are lists of integers (param IDs) */ + List *setParam; /* initplan subqueries have to set these + * Params for parent plan */ + List *parParam; /* indices of input Params from parent plan */ + List *args; /* exprs to pass as parParam values */ +} SubPlan; + +/* ---------------- + * FieldSelect + * + * FieldSelect represents the operation of extracting one field from a tuple + * value. At runtime, the input expression is expected to yield a rowtype + * Datum. The specified field number is extracted and returned as a Datum. + * ---------------- + */ + +typedef struct FieldSelect +{ + Expr xpr; + Expr *arg; /* input expression */ + AttrNumber fieldnum; /* attribute number of field to extract */ + Oid resulttype; /* type of the field (result type of this + * node) */ + int32 resulttypmod; /* output typmod (usually -1) */ +} FieldSelect; + +/* ---------------- + * FieldStore + * + * FieldStore represents the operation of modifying one field in a tuple + * value, yielding a new tuple value (the input is not touched!). Like + * the assign case of ArrayRef, this is used to implement UPDATE of a + * portion of a column. + * + * A single FieldStore can actually represent updates of several different + * fields. The parser only generates FieldStores with single-element lists, + * but the planner will collapse multiple updates of the same base column + * into one FieldStore. + * ---------------- + */ + +typedef struct FieldStore +{ + Expr xpr; + Expr *arg; /* input tuple value */ + List *newvals; /* new value(s) for field(s) */ + List *fieldnums; /* integer list of field attnums */ + Oid resulttype; /* type of result (same as type of arg) */ + /* Like RowExpr, we deliberately omit a typmod here */ +} FieldStore; + +/* ---------------- + * RelabelType + * + * RelabelType represents a "dummy" type coercion between two binary- + * compatible datatypes, such as reinterpreting the result of an OID + * expression as an int4. It is a no-op at runtime; we only need it + * to provide a place to store the correct type to be attributed to + * the expression result during type resolution. (We can't get away + * with just overwriting the type field of the input expression node, + * so we need a separate node to show the coercion's result type.) + * ---------------- + */ + +typedef struct RelabelType +{ + Expr xpr; + Expr *arg; /* input expression */ + Oid resulttype; /* output type of coercion expression */ + int32 resulttypmod; /* output typmod (usually -1) */ + CoercionForm relabelformat; /* how to display this node */ +} RelabelType; + +/* ---------------- + * CoerceViaIO + * + * CoerceViaIO represents a type coercion between two types whose textual + * representations are compatible, implemented by invoking the source type's + * typoutput function then the destination type's typinput function. + * ---------------- + */ + +typedef struct CoerceViaIO +{ + Expr xpr; + Expr *arg; /* input expression */ + Oid resulttype; /* output type of coercion */ + /* output typmod is not stored, but is presumed -1 */ + CoercionForm coerceformat; /* how to display this node */ +} CoerceViaIO; + +/* ---------------- + * ArrayCoerceExpr + * + * ArrayCoerceExpr represents a type coercion from one array type to another, + * which is implemented by applying the indicated element-type coercion + * function to each element of the source array. If elemfuncid is InvalidOid + * then the element types are binary-compatible, but the coercion still + * requires some effort (we have to fix the element type ID stored in the + * array header). + * ---------------- + */ + +typedef struct ArrayCoerceExpr +{ + Expr xpr; + Expr *arg; /* input expression (yields an array) */ + Oid elemfuncid; /* OID of element coercion function, or 0 */ + Oid resulttype; /* output type of coercion (an array type) */ + int32 resulttypmod; /* output typmod (also element typmod) */ + bool isExplicit; /* conversion semantics flag to pass to func */ + CoercionForm coerceformat; /* how to display this node */ +} ArrayCoerceExpr; + +/* ---------------- + * ConvertRowtypeExpr + * + * ConvertRowtypeExpr represents a type coercion from one composite type + * to another, where the source type is guaranteed to contain all the columns + * needed for the destination type plus possibly others; the columns need not + * be in the same positions, but are matched up by name. This is primarily + * used to convert a whole-row value of an inheritance child table into a + * valid whole-row value of its parent table's rowtype. + * ---------------- + */ + +typedef struct ConvertRowtypeExpr +{ + Expr xpr; + Expr *arg; /* input expression */ + Oid resulttype; /* output type (always a composite type) */ + /* result typmod is not stored, but must be -1; see RowExpr comments */ + CoercionForm convertformat; /* how to display this node */ +} ConvertRowtypeExpr; + +/*---------- + * CaseExpr - a CASE expression + * + * We support two distinct forms of CASE expression: + * CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ] + * CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ] + * These are distinguishable by the "arg" field being NULL in the first case + * and the testexpr in the second case. + * + * In the raw grammar output for the second form, the condition expressions + * of the WHEN clauses are just the comparison values. Parse analysis + * converts these to valid boolean expressions of the form + * CaseTestExpr '=' compexpr + * where the CaseTestExpr node is a placeholder that emits the correct + * value at runtime. This structure is used so that the testexpr need be + * evaluated only once. Note that after parse analysis, the condition + * expressions always yield boolean. + * + * Note: we can test whether a CaseExpr has been through parse analysis + * yet by checking whether casetype is InvalidOid or not. + *---------- + */ +typedef struct CaseExpr +{ + Expr xpr; + Oid casetype; /* type of expression result */ + Expr *arg; /* implicit equality comparison argument */ + List *args; /* the arguments (list of WHEN clauses) */ + Expr *defresult; /* the default result (ELSE clause) */ +} CaseExpr; + +/* + * CaseWhen - one arm of a CASE expression + */ +typedef struct CaseWhen +{ + Expr xpr; + Expr *expr; /* condition expression */ + Expr *result; /* substitution result */ +} CaseWhen; + +/* + * Placeholder node for the test value to be processed by a CASE expression. + * This is effectively like a Param, but can be implemented more simply + * since we need only one replacement value at a time. + * + * We also use this in nested UPDATE expressions. + * See transformAssignmentIndirection(). + */ +typedef struct CaseTestExpr +{ + Expr xpr; + Oid typeId; /* type for substituted value */ + int32 typeMod; /* typemod for substituted value */ +} CaseTestExpr; + +/* + * ArrayExpr - an ARRAY[] expression + * + * Note: if multidims is false, the constituent expressions all yield the + * scalar type identified by element_typeid. If multidims is true, the + * constituent expressions all yield arrays of element_typeid (ie, the same + * type as array_typeid); at runtime we must check for compatible subscripts. + */ +typedef struct ArrayExpr +{ + Expr xpr; + Oid array_typeid; /* type of expression result */ + Oid element_typeid; /* common type of array elements */ + List *elements; /* the array elements or sub-arrays */ + bool multidims; /* true if elements are sub-arrays */ +} ArrayExpr; + +/* + * RowExpr - a ROW() expression + * + * Note: the list of fields must have a one-for-one correspondence with + * physical fields of the associated rowtype, although it is okay for it + * to be shorter than the rowtype. That is, the N'th list element must + * match up with the N'th physical field. When the N'th physical field + * is a dropped column (attisdropped) then the N'th list element can just + * be a NULL constant. (This case can only occur for named composite types, + * not RECORD types, since those are built from the RowExpr itself rather + * than vice versa.) It is important not to assume that length(args) is + * the same as the number of columns logically present in the rowtype. + */ +typedef struct RowExpr +{ + Expr xpr; + List *args; /* the fields */ + Oid row_typeid; /* RECORDOID or a composite type's ID */ + + /* + * Note: we deliberately do NOT store a typmod. Although a typmod will be + * associated with specific RECORD types at runtime, it will differ for + * different backends, and so cannot safely be stored in stored + * parsetrees. We must assume typmod -1 for a RowExpr node. + */ + CoercionForm row_format; /* how to display this node */ +} RowExpr; + +/* + * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2) + * + * We support row comparison for any operator that can be determined to + * act like =, <>, <, <=, >, or >= (we determine this by looking for the + * operator in btree opfamilies). Note that the same operator name might + * map to a different operator for each pair of row elements, since the + * element datatypes can vary. + * + * A RowCompareExpr node is only generated for the < <= > >= cases; + * the = and <> cases are translated to simple AND or OR combinations + * of the pairwise comparisons. However, we include = and <> in the + * RowCompareType enum for the convenience of parser logic. + */ +typedef enum RowCompareType +{ + /* Values of this enum are chosen to match btree strategy numbers */ + ROWCOMPARE_LT = 1, /* BTLessStrategyNumber */ + ROWCOMPARE_LE = 2, /* BTLessEqualStrategyNumber */ + ROWCOMPARE_EQ = 3, /* BTEqualStrategyNumber */ + ROWCOMPARE_GE = 4, /* BTGreaterEqualStrategyNumber */ + ROWCOMPARE_GT = 5, /* BTGreaterStrategyNumber */ + ROWCOMPARE_NE = 6 /* no such btree strategy */ +} RowCompareType; + +typedef struct RowCompareExpr +{ + Expr xpr; + RowCompareType rctype; /* LT LE GE or GT, never EQ or NE */ + List *opnos; /* OID list of pairwise comparison ops */ + List *opfamilies; /* OID list of containing operator families */ + List *largs; /* the left-hand input arguments */ + List *rargs; /* the right-hand input arguments */ +} RowCompareExpr; + +/* + * CoalesceExpr - a COALESCE expression + */ +typedef struct CoalesceExpr +{ + Expr xpr; + Oid coalescetype; /* type of expression result */ + List *args; /* the arguments */ +} CoalesceExpr; + +/* + * MinMaxExpr - a GREATEST or LEAST function + */ +typedef enum MinMaxOp +{ + IS_GREATEST, + IS_LEAST +} MinMaxOp; + +typedef struct MinMaxExpr +{ + Expr xpr; + Oid minmaxtype; /* common type of arguments and result */ + MinMaxOp op; /* function to execute */ + List *args; /* the arguments */ +} MinMaxExpr; + +/* + * XmlExpr - various SQL/XML functions requiring special grammar productions + * + * 'name' carries the "NAME foo" argument (already XML-escaped). + * 'named_args' and 'arg_names' represent an xml_attribute list. + * 'args' carries all other arguments. + */ +typedef enum XmlExprOp +{ + IS_XMLCONCAT, /* XMLCONCAT(args) */ + IS_XMLELEMENT, /* XMLELEMENT(name, xml_attributes, args) */ + IS_XMLFOREST, /* XMLFOREST(xml_attributes) */ + IS_XMLPARSE, /* XMLPARSE(text, is_doc, preserve_ws) */ + IS_XMLPI, /* XMLPI(name [, args]) */ + IS_XMLROOT, /* XMLROOT(xml, version, standalone) */ + IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval) */ + IS_DOCUMENT /* xmlval IS DOCUMENT */ +} XmlExprOp; + +typedef enum +{ + XMLOPTION_DOCUMENT, + XMLOPTION_CONTENT +} XmlOptionType; + +typedef struct XmlExpr +{ + Expr xpr; + XmlExprOp op; /* xml function ID */ + char *name; /* name in xml(NAME foo ...) syntaxes */ + List *named_args; /* non-XML expressions for xml_attributes */ + List *arg_names; /* parallel list of Value strings */ + List *args; /* list of expressions */ + XmlOptionType xmloption; /* DOCUMENT or CONTENT */ + Oid type; /* target type for XMLSERIALIZE */ + int32 typmod; +} XmlExpr; + +/* + * NullIfExpr - a NULLIF expression + * + * Like DistinctExpr, this is represented the same as an OpExpr referencing + * the "=" operator for x and y. + */ +typedef OpExpr NullIfExpr; + +/* ---------------- + * NullTest + * + * NullTest represents the operation of testing a value for NULLness. + * The appropriate test is performed and returned as a boolean Datum. + * + * NOTE: the semantics of this for rowtype inputs are noticeably different + * from the scalar case. It would probably be a good idea to include an + * "argisrow" flag in the struct to reflect that, but for the moment, + * we do not do so to avoid forcing an initdb during 8.2beta. + * ---------------- + */ + +typedef enum NullTestType +{ + IS_NULL, IS_NOT_NULL +} NullTestType; + +typedef struct NullTest +{ + Expr xpr; + Expr *arg; /* input expression */ + NullTestType nulltesttype; /* IS NULL, IS NOT NULL */ +} NullTest; + +/* + * BooleanTest + * + * BooleanTest represents the operation of determining whether a boolean + * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations + * are supported. Note that a NULL input does *not* cause a NULL result. + * The appropriate test is performed and returned as a boolean Datum. + */ + +typedef enum BoolTestType +{ + IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN +} BoolTestType; + +typedef struct BooleanTest +{ + Expr xpr; + Expr *arg; /* input expression */ + BoolTestType booltesttype; /* test type */ +} BooleanTest; + +/* + * CoerceToDomain + * + * CoerceToDomain represents the operation of coercing a value to a domain + * type. At runtime (and not before) the precise set of constraints to be + * checked will be determined. If the value passes, it is returned as the + * result; if not, an error is raised. Note that this is equivalent to + * RelabelType in the scenario where no constraints are applied. + */ +typedef struct CoerceToDomain +{ + Expr xpr; + Expr *arg; /* input expression */ + Oid resulttype; /* domain type ID (result type) */ + int32 resulttypmod; /* output typmod (currently always -1) */ + CoercionForm coercionformat; /* how to display this node */ +} CoerceToDomain; + +/* + * Placeholder node for the value to be processed by a domain's check + * constraint. This is effectively like a Param, but can be implemented more + * simply since we need only one replacement value at a time. + * + * Note: the typeId/typeMod will be set from the domain's base type, not + * the domain itself. This is because we shouldn't consider the value to + * be a member of the domain if we haven't yet checked its constraints. + */ +typedef struct CoerceToDomainValue +{ + Expr xpr; + Oid typeId; /* type for substituted value */ + int32 typeMod; /* typemod for substituted value */ +} CoerceToDomainValue; + +/* + * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command. + * + * This is not an executable expression: it must be replaced by the actual + * column default expression during rewriting. But it is convenient to + * treat it as an expression node during parsing and rewriting. + */ +typedef struct SetToDefault +{ + Expr xpr; + Oid typeId; /* type for substituted value */ + int32 typeMod; /* typemod for substituted value */ +} SetToDefault; + +/* + * Node representing [WHERE] CURRENT OF cursor_name + * + * CURRENT OF is a bit like a Var, in that it carries the rangetable index + * of the target relation being constrained; this aids placing the expression + * correctly during planning. We can assume however that its "levelsup" is + * always zero, due to the syntactic constraints on where it can appear. + * + * The referenced cursor can be represented either as a hardwired string + * or as a reference to a run-time parameter of type REFCURSOR. The latter + * case is for the convenience of plpgsql. + */ +typedef struct CurrentOfExpr +{ + Expr xpr; + Index cvarno; /* RT index of target relation */ + char *cursor_name; /* name of referenced cursor, or NULL */ + int cursor_param; /* refcursor parameter number, or 0 */ +} CurrentOfExpr; + +/*-------------------- + * TargetEntry - + * a target entry (used in query target lists) + * + * Strictly speaking, a TargetEntry isn't an expression node (since it can't + * be evaluated by ExecEvalExpr). But we treat it as one anyway, since in + * very many places it's convenient to process a whole query targetlist as a + * single expression tree. + * + * In a SELECT's targetlist, resno should always be equal to the item's + * ordinal position (counting from 1). However, in an INSERT or UPDATE + * targetlist, resno represents the attribute number of the destination + * column for the item; so there may be missing or out-of-order resnos. + * It is even legal to have duplicated resnos; consider + * UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ... + * The two meanings come together in the executor, because the planner + * transforms INSERT/UPDATE tlists into a normalized form with exactly + * one entry for each column of the destination table. Before that's + * happened, however, it is risky to assume that resno == position. + * Generally get_tle_by_resno() should be used rather than list_nth() + * to fetch tlist entries by resno, and only in SELECT should you assume + * that resno is a unique identifier. + * + * resname is required to represent the correct column name in non-resjunk + * entries of top-level SELECT targetlists, since it will be used as the + * column title sent to the frontend. In most other contexts it is only + * a debugging aid, and may be wrong or even NULL. (In particular, it may + * be wrong in a tlist from a stored rule, if the referenced column has been + * renamed by ALTER TABLE since the rule was made. Also, the planner tends + * to store NULL rather than look up a valid name for tlist entries in + * non-toplevel plan nodes.) In resjunk entries, resname should be either + * a specific system-generated name (such as "ctid") or NULL; anything else + * risks confusing ExecGetJunkAttribute! + * + * ressortgroupref is used in the representation of ORDER BY and + * GROUP BY items. Targetlist entries with ressortgroupref=0 are not + * sort/group items. If ressortgroupref>0, then this item is an ORDER BY or + * GROUP BY value. No two entries in a targetlist may have the same nonzero + * ressortgroupref --- but there is no particular meaning to the nonzero + * values, except as tags. (For example, one must not assume that lower + * ressortgroupref means a more significant sort key.) The order of the + * associated SortClause or GroupClause lists determine the semantics. + * + * resorigtbl/resorigcol identify the source of the column, if it is a + * simple reference to a column of a base table (or view). If it is not + * a simple reference, these fields are zeroes. + * + * If resjunk is true then the column is a working column (such as a sort key) + * that should be removed from the final output of the query. Resjunk columns + * must have resnos that cannot duplicate any regular column's resno. Also + * note that there are places that assume resjunk columns come after non-junk + * columns. + *-------------------- + */ +typedef struct TargetEntry +{ + Expr xpr; + Expr *expr; /* expression to evaluate */ + AttrNumber resno; /* attribute number (see notes above) */ + char *resname; /* name of the column (could be NULL) */ + Index ressortgroupref;/* nonzero if referenced by a sort/group + * clause */ + Oid resorigtbl; /* OID of column's source table */ + AttrNumber resorigcol; /* column's number in source table */ + bool resjunk; /* set to true to eliminate the attribute from + * final target list */ +} TargetEntry; + + +/* ---------------------------------------------------------------- + * node types for join trees + * + * The leaves of a join tree structure are RangeTblRef nodes. Above + * these, JoinExpr nodes can appear to denote a specific kind of join + * or qualified join. Also, FromExpr nodes can appear to denote an + * ordinary cross-product join ("FROM foo, bar, baz WHERE ..."). + * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it + * may have any number of child nodes, not just two. + * + * NOTE: the top level of a Query's jointree is always a FromExpr. + * Even if the jointree contains no rels, there will be a FromExpr. + * + * NOTE: the qualification expressions present in JoinExpr nodes are + * *in addition to* the query's main WHERE clause, which appears as the + * qual of the top-level FromExpr. The reason for associating quals with + * specific nodes in the jointree is that the position of a qual is critical + * when outer joins are present. (If we enforce a qual too soon or too late, + * that may cause the outer join to produce the wrong set of NULL-extended + * rows.) If all joins are inner joins then all the qual positions are + * semantically interchangeable. + * + * NOTE: in the raw output of gram.y, a join tree contains RangeVar, + * RangeSubselect, and RangeFunction nodes, which are all replaced by + * RangeTblRef nodes during the parse analysis phase. Also, the top-level + * FromExpr is added during parse analysis; the grammar regards FROM and + * WHERE as separate. + * ---------------------------------------------------------------- + */ + +/* + * RangeTblRef - reference to an entry in the query's rangetable + * + * We could use direct pointers to the RT entries and skip having these + * nodes, but multiple pointers to the same node in a querytree cause + * lots of headaches, so it seems better to store an index into the RT. + */ +typedef struct RangeTblRef +{ + NodeTag type; + int rtindex; +} RangeTblRef; + +/*---------- + * JoinExpr - for SQL JOIN expressions + * + * isNatural, using, and quals are interdependent. The user can write only + * one of NATURAL, USING(), or ON() (this is enforced by the grammar). + * If he writes NATURAL then parse analysis generates the equivalent USING() + * list, and from that fills in "quals" with the right equality comparisons. + * If he writes USING() then "quals" is filled with equality comparisons. + * If he writes ON() then only "quals" is set. Note that NATURAL/USING + * are not equivalent to ON() since they also affect the output column list. + * + * alias is an Alias node representing the AS alias-clause attached to the + * join expression, or NULL if no clause. NB: presence or absence of the + * alias has a critical impact on semantics, because a join with an alias + * restricts visibility of the tables/columns inside it. + * + * During parse analysis, an RTE is created for the Join, and its index + * is filled into rtindex. This RTE is present mainly so that Vars can + * be created that refer to the outputs of the join. + *---------- + */ +typedef struct JoinExpr +{ + NodeTag type; + JoinType jointype; /* type of join */ + bool isNatural; /* Natural join? Will need to shape table */ + Node *larg; /* left subtree */ + Node *rarg; /* right subtree */ + List *using; /* USING clause, if any (list of String) */ + Node *quals; /* qualifiers on join, if any */ + Alias *alias; /* user-written alias clause, if any */ + int rtindex; /* RT index assigned for join */ +} JoinExpr; + +/*---------- + * FromExpr - represents a FROM ... WHERE ... construct + * + * This is both more flexible than a JoinExpr (it can have any number of + * children, including zero) and less so --- we don't need to deal with + * aliases and so on. The output column set is implicitly just the union + * of the outputs of the children. + *---------- + */ +typedef struct FromExpr +{ + NodeTag type; + List *fromlist; /* List of join subtrees */ + Node *quals; /* qualifiers on join, if any */ +} FromExpr; + +#endif /* PRIMNODES_H */ diff --git a/parser/scan.c b/parser/scan.c new file mode 100644 index 0000000..cf0470e --- /dev/null +++ b/parser/scan.c @@ -0,0 +1,3072 @@ +#line 2 "scan.c" + +#line 4 "scan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 33 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE base_yyrestart(base_yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int base_yyleng; + +extern FILE *base_yyin, *base_yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up base_yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up base_yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via base_yyrestart()), so that the user can continue scanning by + * just pointing base_yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when base_yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int base_yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow base_yywrap()'s to do buffer switches + * instead of setting up a fresh base_yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void base_yyrestart (FILE *input_file ); +void base_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE base_yy_create_buffer (FILE *file,int size ); +void base_yy_delete_buffer (YY_BUFFER_STATE b ); +void base_yy_flush_buffer (YY_BUFFER_STATE b ); +void base_yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void base_yypop_buffer_state (void ); + +static void base_yyensure_buffer_stack (void ); +static void base_yy_load_buffer_state (void ); +static void base_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER base_yy_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE base_yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE base_yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE base_yy_scan_bytes (yyconst char *bytes,int len ); + +void *base_yyalloc (yy_size_t ); +void *base_yyrealloc (void *,yy_size_t ); +void base_yyfree (void * ); + +#define yy_new_buffer base_yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + base_yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + base_yy_create_buffer(base_yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + base_yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + base_yy_create_buffer(base_yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define base_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *base_yyin = (FILE *) 0, *base_yyout = (FILE *) 0; + +typedef int yy_state_type; + +extern int base_yylineno; + +int base_yylineno = 1; + +extern char *base_yytext; +#define yytext_ptr base_yytext + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up base_yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + base_yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 52 +#define YY_END_OF_BUFFER 53 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[155] = + { 0, + 0, 0, 12, 12, 0, 0, 0, 0, 11, 11, + 0, 0, 0, 0, 0, 0, 53, 51, 1, 1, + 43, 37, 51, 42, 19, 42, 42, 42, 42, 45, + 42, 50, 50, 50, 50, 50, 12, 9, 5, 5, + 6, 6, 40, 38, 11, 16, 25, 25, 21, 30, + 24, 21, 34, 34, 36, 1, 43, 31, 44, 32, + 1, 46, 2, 46, 45, 48, 41, 50, 8, 20, + 18, 15, 12, 9, 9, 10, 5, 7, 4, 3, + 40, 39, 11, 16, 16, 17, 25, 21, 21, 23, + 22, 26, 27, 26, 24, 34, 33, 35, 32, 1, + + 1, 2, 46, 49, 47, 9, 14, 10, 9, 3, + 16, 13, 17, 16, 21, 29, 22, 21, 27, 28, + 35, 9, 9, 9, 9, 16, 16, 16, 16, 21, + 21, 21, 21, 27, 28, 9, 9, 9, 9, 9, + 16, 16, 16, 16, 16, 21, 21, 21, 21, 21, + 9, 16, 21, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 6, 5, 7, 8, 5, 9, 10, + 10, 11, 12, 10, 13, 14, 15, 16, 16, 16, + 16, 16, 16, 16, 16, 17, 17, 18, 10, 8, + 8, 8, 5, 5, 19, 20, 19, 19, 21, 19, + 22, 22, 22, 22, 22, 22, 22, 23, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 24, 22, 22, + 10, 25, 10, 8, 22, 5, 19, 20, 19, 19, + + 21, 19, 22, 22, 22, 22, 22, 22, 22, 23, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 26, + 22, 22, 1, 5, 1, 5, 1, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22 + } ; + +static yyconst flex_int32_t yy_meta[27] = + { 0, + 1, 2, 3, 3, 4, 5, 6, 4, 7, 1, + 8, 4, 9, 1, 8, 10, 10, 1, 11, 11, + 11, 12, 12, 12, 13, 12 + } ; + +static yyconst flex_int16_t yy_base[190] = + { 0, + 0, 0, 162, 161, 22, 33, 163, 162, 154, 153, + 33, 40, 152, 151, 25, 44, 159, 867, 50, 53, + 0, 867, 43, 0, 867, 867, 145, 23, 146, 52, + 138, 0, 142, 141, 138, 137, 0, 72, 0, 0, + 52, 128, 0, 132, 0, 84, 0, 0, 96, 45, + 0, 0, 0, 0, 122, 75, 0, 867, 64, 112, + 105, 73, 0, 75, 0, 109, 867, 0, 867, 867, + 867, 867, 0, 0, 93, 101, 0, 92, 867, 0, + 0, 867, 0, 0, 95, 99, 0, 92, 102, 867, + 82, 867, 77, 0, 0, 0, 867, 77, 65, 0, + + 122, 0, 107, 66, 115, 127, 867, 57, 139, 0, + 135, 867, 51, 151, 136, 867, 49, 163, 15, 0, + 22, 175, 187, 199, 211, 223, 235, 247, 259, 271, + 283, 295, 307, 867, 867, 319, 331, 0, 343, 355, + 367, 379, 0, 391, 403, 415, 427, 0, 439, 451, + 463, 475, 487, 867, 500, 513, 526, 539, 552, 565, + 578, 588, 592, 599, 611, 624, 637, 650, 663, 675, + 688, 701, 709, 716, 728, 738, 746, 752, 760, 768, + 768, 774, 786, 799, 812, 816, 827, 840, 853 + } ; + +static yyconst flex_int16_t yy_def[190] = + { 0, + 154, 1, 155, 155, 156, 156, 157, 157, 158, 158, + 159, 159, 160, 160, 161, 161, 154, 154, 154, 154, + 162, 154, 163, 162, 154, 154, 162, 154, 162, 154, + 154, 164, 164, 164, 164, 164, 165, 154, 166, 166, + 154, 154, 167, 154, 168, 154, 169, 169, 154, 170, + 171, 49, 172, 172, 173, 154, 162, 154, 154, 174, + 175, 154, 176, 154, 30, 154, 154, 164, 154, 154, + 154, 154, 165, 38, 177, 154, 166, 154, 154, 178, + 167, 154, 168, 46, 179, 154, 169, 49, 180, 154, + 154, 154, 154, 181, 171, 172, 154, 182, 174, 175, + + 175, 176, 154, 154, 154, 177, 154, 154, 183, 178, + 179, 154, 154, 184, 180, 154, 154, 185, 154, 186, + 182, 187, 183, 183, 183, 188, 184, 184, 184, 189, + 185, 185, 185, 154, 154, 187, 187, 106, 187, 183, + 188, 188, 111, 188, 184, 189, 189, 115, 189, 185, + 187, 188, 189, 0, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154 + } ; + +static yyconst flex_int16_t yy_nxt[894] = + { 0, + 18, 19, 20, 19, 21, 22, 23, 24, 25, 26, + 24, 24, 27, 28, 29, 30, 30, 31, 32, 33, + 34, 32, 35, 36, 18, 36, 40, 54, 97, 40, + 134, 55, 41, 40, 40, 48, 42, 40, 62, 62, + 40, 49, 48, 41, 40, 40, 54, 42, 49, 58, + 55, 56, 56, 56, 56, 56, 56, 50, 59, 59, + 93, 130, 78, 126, 50, 64, 79, 65, 65, 122, + 94, 58, 66, 74, 75, 75, 56, 56, 56, 59, + 59, 105, 105, 97, 76, 84, 85, 85, 62, 62, + 103, 103, 119, 66, 118, 66, 86, 88, 89, 89, + + 154, 107, 78, 112, 90, 108, 79, 113, 91, 101, + 116, 114, 101, 109, 117, 101, 101, 101, 58, 101, + 104, 104, 103, 103, 105, 105, 101, 66, 97, 101, + 105, 105, 101, 101, 101, 107, 101, 82, 80, 108, + 124, 75, 75, 112, 116, 72, 71, 113, 117, 70, + 69, 125, 128, 85, 85, 67, 63, 61, 154, 52, + 52, 46, 46, 129, 132, 89, 89, 44, 44, 38, + 38, 154, 154, 154, 154, 133, 137, 138, 138, 154, + 154, 154, 154, 154, 154, 154, 154, 139, 124, 75, + 75, 154, 154, 154, 154, 154, 154, 154, 154, 125, + + 124, 75, 75, 154, 154, 154, 154, 154, 154, 154, + 154, 125, 124, 75, 75, 154, 154, 154, 154, 154, + 154, 154, 154, 140, 142, 143, 143, 154, 154, 154, + 154, 154, 154, 154, 154, 144, 128, 85, 85, 154, + 154, 154, 154, 154, 154, 154, 154, 129, 128, 85, + 85, 154, 154, 154, 154, 154, 154, 154, 154, 129, + 128, 85, 85, 154, 154, 154, 154, 154, 154, 154, + 154, 145, 147, 148, 148, 154, 154, 154, 154, 154, + 154, 154, 154, 149, 132, 89, 89, 154, 154, 154, + 154, 154, 154, 154, 154, 133, 132, 89, 89, 154, + + 154, 154, 154, 154, 154, 154, 154, 133, 132, 89, + 89, 154, 154, 154, 154, 154, 154, 154, 154, 150, + 137, 138, 138, 154, 154, 154, 154, 154, 154, 154, + 154, 139, 137, 138, 138, 154, 154, 154, 154, 154, + 154, 154, 154, 139, 137, 138, 138, 154, 154, 154, + 154, 154, 154, 154, 154, 151, 124, 75, 75, 154, + 154, 154, 154, 154, 154, 154, 154, 140, 142, 143, + 143, 154, 154, 154, 154, 154, 154, 154, 154, 144, + 142, 143, 143, 154, 154, 154, 154, 154, 154, 154, + 154, 144, 142, 143, 143, 154, 154, 154, 154, 154, + + 154, 154, 154, 152, 128, 85, 85, 154, 154, 154, + 154, 154, 154, 154, 154, 145, 147, 148, 148, 154, + 154, 154, 154, 154, 154, 154, 154, 149, 147, 148, + 148, 154, 154, 154, 154, 154, 154, 154, 154, 149, + 147, 148, 148, 154, 154, 154, 154, 154, 154, 154, + 154, 153, 132, 89, 89, 154, 154, 154, 154, 154, + 154, 154, 154, 150, 137, 138, 138, 154, 154, 154, + 154, 154, 154, 154, 154, 151, 142, 143, 143, 154, + 154, 154, 154, 154, 154, 154, 154, 152, 147, 148, + 148, 154, 154, 154, 154, 154, 154, 154, 154, 153, + + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + 37, 37, 37, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 57, 154, 154, 154, 57, 57, 60, 154, 154, + + 154, 60, 60, 60, 68, 154, 154, 154, 68, 68, + 68, 73, 73, 73, 73, 73, 73, 154, 73, 73, + 73, 73, 73, 73, 77, 77, 77, 77, 77, 77, + 77, 154, 77, 77, 77, 77, 77, 81, 81, 81, + 81, 154, 81, 81, 81, 81, 81, 81, 81, 81, + 83, 83, 83, 83, 83, 83, 154, 83, 83, 83, + 83, 83, 83, 87, 87, 87, 87, 87, 87, 154, + 87, 87, 87, 87, 87, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 95, 95, + 95, 95, 95, 95, 154, 95, 95, 95, 95, 95, + + 95, 96, 96, 96, 96, 96, 154, 96, 96, 96, + 96, 96, 96, 96, 98, 154, 154, 154, 154, 98, + 98, 99, 154, 154, 154, 99, 99, 99, 100, 100, + 154, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 102, 154, 154, 154, 102, 102, 106, 106, 154, + 154, 154, 106, 154, 106, 110, 154, 154, 154, 110, + 110, 111, 111, 154, 154, 154, 111, 154, 111, 115, + 115, 154, 154, 154, 115, 154, 115, 120, 120, 121, + 154, 154, 154, 121, 121, 121, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 127, + + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 131, 131, 131, 131, 131, 131, 131, 131, + 131, 131, 131, 131, 131, 135, 135, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, + 141, 141, 141, 146, 146, 146, 146, 146, 146, 146, + 146, 146, 146, 146, 146, 146, 17, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154 + + } ; + +static yyconst flex_int16_t yy_chk[894] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 5, 15, 121, 5, + 119, 15, 5, 5, 5, 11, 5, 6, 28, 28, + 6, 11, 12, 6, 6, 6, 16, 6, 12, 23, + 16, 19, 19, 19, 20, 20, 20, 11, 23, 23, + 50, 117, 41, 113, 12, 30, 41, 30, 30, 108, + 50, 99, 30, 38, 38, 38, 56, 56, 56, 59, + 59, 104, 104, 98, 38, 46, 46, 46, 62, 62, + 64, 64, 93, 62, 91, 64, 46, 49, 49, 49, + + 88, 75, 78, 85, 49, 75, 78, 85, 49, 61, + 89, 86, 61, 76, 89, 61, 61, 61, 60, 61, + 66, 66, 103, 103, 66, 66, 101, 103, 55, 101, + 105, 105, 101, 101, 101, 106, 101, 44, 42, 106, + 109, 109, 109, 111, 115, 36, 35, 111, 115, 34, + 33, 109, 114, 114, 114, 31, 29, 27, 17, 14, + 13, 10, 9, 114, 118, 118, 118, 8, 7, 4, + 3, 0, 0, 0, 0, 118, 122, 122, 122, 0, + 0, 0, 0, 0, 0, 0, 0, 122, 123, 123, + 123, 0, 0, 0, 0, 0, 0, 0, 0, 123, + + 124, 124, 124, 0, 0, 0, 0, 0, 0, 0, + 0, 124, 125, 125, 125, 0, 0, 0, 0, 0, + 0, 0, 0, 125, 126, 126, 126, 0, 0, 0, + 0, 0, 0, 0, 0, 126, 127, 127, 127, 0, + 0, 0, 0, 0, 0, 0, 0, 127, 128, 128, + 128, 0, 0, 0, 0, 0, 0, 0, 0, 128, + 129, 129, 129, 0, 0, 0, 0, 0, 0, 0, + 0, 129, 130, 130, 130, 0, 0, 0, 0, 0, + 0, 0, 0, 130, 131, 131, 131, 0, 0, 0, + 0, 0, 0, 0, 0, 131, 132, 132, 132, 0, + + 0, 0, 0, 0, 0, 0, 0, 132, 133, 133, + 133, 0, 0, 0, 0, 0, 0, 0, 0, 133, + 136, 136, 136, 0, 0, 0, 0, 0, 0, 0, + 0, 136, 137, 137, 137, 0, 0, 0, 0, 0, + 0, 0, 0, 137, 139, 139, 139, 0, 0, 0, + 0, 0, 0, 0, 0, 139, 140, 140, 140, 0, + 0, 0, 0, 0, 0, 0, 0, 140, 141, 141, + 141, 0, 0, 0, 0, 0, 0, 0, 0, 141, + 142, 142, 142, 0, 0, 0, 0, 0, 0, 0, + 0, 142, 144, 144, 144, 0, 0, 0, 0, 0, + + 0, 0, 0, 144, 145, 145, 145, 0, 0, 0, + 0, 0, 0, 0, 0, 145, 146, 146, 146, 0, + 0, 0, 0, 0, 0, 0, 0, 146, 147, 147, + 147, 0, 0, 0, 0, 0, 0, 0, 0, 147, + 149, 149, 149, 0, 0, 0, 0, 0, 0, 0, + 0, 149, 150, 150, 150, 0, 0, 0, 0, 0, + 0, 0, 0, 150, 151, 151, 151, 0, 0, 0, + 0, 0, 0, 0, 0, 151, 152, 152, 152, 0, + 0, 0, 0, 0, 0, 0, 0, 152, 153, 153, + 153, 0, 0, 0, 0, 0, 0, 0, 0, 153, + + 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, + 155, 155, 155, 156, 156, 156, 156, 156, 156, 156, + 156, 156, 156, 156, 156, 156, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 158, + 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 158, 158, 159, 159, 159, 159, 159, 159, 159, 159, + 159, 159, 159, 159, 159, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 161, 161, + 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, + 161, 162, 0, 0, 0, 162, 162, 163, 0, 0, + + 0, 163, 163, 163, 164, 0, 0, 0, 164, 164, + 164, 165, 165, 165, 165, 165, 165, 0, 165, 165, + 165, 165, 165, 165, 166, 166, 166, 166, 166, 166, + 166, 0, 166, 166, 166, 166, 166, 167, 167, 167, + 167, 0, 167, 167, 167, 167, 167, 167, 167, 167, + 168, 168, 168, 168, 168, 168, 0, 168, 168, 168, + 168, 168, 168, 169, 169, 169, 169, 169, 169, 0, + 169, 169, 169, 169, 169, 170, 170, 170, 170, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 171, 171, + 171, 171, 171, 171, 0, 171, 171, 171, 171, 171, + + 171, 172, 172, 172, 172, 172, 0, 172, 172, 172, + 172, 172, 172, 172, 173, 0, 0, 0, 0, 173, + 173, 174, 0, 0, 0, 174, 174, 174, 175, 175, + 0, 175, 175, 175, 175, 175, 175, 175, 175, 175, + 175, 176, 0, 0, 0, 176, 176, 177, 177, 0, + 0, 0, 177, 0, 177, 178, 0, 0, 0, 178, + 178, 179, 179, 0, 0, 0, 179, 0, 179, 180, + 180, 0, 0, 0, 180, 0, 180, 181, 181, 182, + 0, 0, 0, 182, 182, 182, 183, 183, 183, 183, + 183, 183, 183, 183, 183, 183, 183, 183, 183, 184, + + 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, + 184, 184, 185, 185, 185, 185, 185, 185, 185, 185, + 185, 185, 185, 185, 185, 186, 186, 187, 187, 187, + 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, + 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, + 188, 188, 188, 189, 189, 189, 189, 189, 189, 189, + 189, 189, 189, 189, 189, 189, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, + 154, 154, 154 + + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int base_yy_flex_debug; +int base_yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *base_yytext; +#line 1 "scan.l" +#line 2 "scan.l" +/*------------------------------------------------------------------------- + * + * scan.l + * lexical scanner for PostgreSQL + * + * NOTE NOTE NOTE: + * + * The rules in this file must be kept in sync with psql's lexer!!! + * + * The rules are designed so that the scanner never has to backtrack, + * in the sense that there is always a rule that can match the input + * consumed so far (the rule action may internally throw back some input + * with yyless(), however). As explained in the flex manual, this makes + * for a useful speed increase --- about a third faster than a plain -CF + * lexer, in simple testing. The extra complexity is mostly in the rules + * for handling float numbers and continued string literals. If you change + * the lexical rules, verify that you haven't broken the no-backtrack + * property by running flex with the "-b" option and checking that the + * resulting "lex.backup" file says that no backing up is needed. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.141 2007/09/12 20:49:27 adunstan Exp $ + * + *------------------------------------------------------------------------- + */ +#include "pool_parser.h" + +#include +#include +#include +#include +#include + +#ifndef ereport +#define ereport(a,b) yyerror("") +#endif +#define IS_HIGHBIT_SET(c) 0 + +#include "gramparse.h" +#include "keywords.h" +/* Not needed now that this file is compiled as part of gram.y */ +/* #include "parser/parse.h" */ +#include "gram.h" +#include "scansup.h" + +#include "pool_memory.h" + + +/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ +/* +#undef fprintf +#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) +*/ + +static int xcdepth = 0; /* depth of nesting in slash-star comments */ +static char *dolqstart; /* current $foo$ quote start string */ + +/* + * GUC variables. This is a DIRECT violation of the warning given at the + * head of gram.y, ie flex/bison code must not depend on any GUC variables; + * as such, changing their values can induce very unintuitive behavior. + * But we shall have to live with it as a short-term thing until the switch + * to SQL-standard string syntax is complete. + */ +typedef enum +{ + BACKSLASH_QUOTE_OFF, + BACKSLASH_QUOTE_ON, + BACKSLASH_QUOTE_SAFE_ENCODING +} BackslashQuoteType; + +BackslashQuoteType backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING; +int escape_string_warning = true; +int standard_conforming_strings = false; + +static bool warn_on_first_escape; +static bool saw_high_bit = false; + +/* + * literalbuf is used to accumulate literal values when multiple rules + * are needed to parse a single literal. Call startlit to reset buffer + * to empty, addlit to add text. Note that the buffer is palloc'd and + * starts life afresh on every parse cycle. + */ +static char *literalbuf; /* expandable buffer */ +static int literallen; /* actual current length */ +static int literalalloc; /* current allocated buffer size */ + +#define startlit() (literalbuf[0] = '\0', literallen = 0) +static void addlit(char *ytext, int yleng); +static void addlitchar(unsigned char ychar); +static char *litbufdup(void); + +#if 0 +static int lexer_errposition(void); +#endif +static void check_escape_warning(void); +static void check_string_escape_warning(unsigned char ychar); + +extern char *base_yytext; + +/* + * Each call to base_yylex must set yylloc to the location of the found token + * (expressed as a byte offset from the start of the input text). + * When we parse a token that requires multiple lexer rules to process, + * this should be done in the first such rule, else yylloc will point + * into the middle of the token. + */ +#define SET_YYLLOC() (yylloc = base_yytext - scanbuf) + +/* Handles to the buffer that the lexer uses internally */ +static YY_BUFFER_STATE scanbufhandle; +static char *scanbuf; + +static unsigned char unescape_single_char(unsigned char c); +void yyerror(const char *s); + +/* + * OK, here is a short description of lex/flex rules behavior. + * The longest pattern which matches an input string is always chosen. + * For equal-length patterns, the first occurring in the rules list is chosen. + * INITIAL is the starting state, to which all non-conditional rules apply. + * Exclusive states change parsing rules while the state is active. When in + * an exclusive state, only those rules defined for that state apply. + * + * We use exclusive states for quoted strings, extended comments, + * and to eliminate parsing troubles for numeric strings. + * Exclusive states: + * bit string literal + * extended C-style comments + * delimited identifiers (double-quoted identifiers) + * hexadecimal numeric string + * standard quoted strings + * extended quoted strings (support backslash escape sequences) + * $foo$ quoted strings + */ + + + + + + + +/* + * In order to make the world safe for Windows and Mac clients as well as + * Unix ones, we accept either \n or \r as a newline. A DOS-style \r\n + * sequence will be seen as two successive newlines, but that doesn't cause + * any problems. Comments that start with -- and extend to the next + * newline are treated as equivalent to a single whitespace character. + * + * NOTE a fine point: if there is no newline following --, we will absorb + * everything to the end of the input as a comment. This is correct. Older + * versions of Postgres failed to recognize -- as a comment if the input + * did not end with a newline. + * + * XXX perhaps \f (formfeed) should be treated as a newline as well? + * + * XXX if you change the set of whitespace characters, fix scanner_isspace() + * to agree, and see also the plpgsql lexer. + */ +/* + * SQL requires at least one newline in the whitespace separating + * string literals that are to be concatenated. Silly, but who are we + * to argue? Note that {whitespace_with_newline} should not have * after + * it, whereas {whitespace} should generally have a * after it... + */ +/* + * To ensure that {quotecontinue} can be scanned without having to back up + * if the full pattern isn't matched, we include trailing whitespace in + * {quotestop}. This matches all cases where {quotecontinue} fails to match, + * except for {quote} followed by whitespace and just one "-" (not two, + * which would start a {comment}). To cover that we have {quotefail}. + * The actions for {quotestop} and {quotefail} must throw back characters + * beyond the quote proper. + */ +/* Bit string + * It is tempting to scan the string for only those characters + * which are allowed. However, this leads to silently swallowed + * characters if illegal characters are included in the string. + * For example, if xbinside is [01] then B'ABCD' is interpreted + * as a zero-length string, and the ABCD' is lost! + * Better to pass the string forward and let the input routines + * validate the contents. + */ +/* Hexadecimal number */ +/* National character */ +/* Quoted string that allows backslash escapes */ +/* Extended quote + * xqdouble implements embedded quote, '''' + */ +/* $foo$ style quotes ("dollar quoting") + * The quoted string starts with $foo$ where "foo" is an optional string + * in the form of an identifier, except that it may not contain "$", + * and extends to the first occurrence of an identical string. + * There is *no* processing of the quoted text. + * + * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim} + * fails to match its trailing "$". + */ +/* Double quote + * Allows embedded spaces and other special characters into identifiers. + */ +/* C-style comments + * + * The "extended comment" syntax closely resembles allowable operator syntax. + * The tricky part here is to get lex to recognize a string starting with + * slash-star as a comment, when interpreting it as an operator would produce + * a longer match --- remember lex will prefer a longer match! Also, if we + * have something like plus-slash-star, lex will think this is a 3-character + * operator whereas we want to see it as a + operator and a comment start. + * The solution is two-fold: + * 1. append {op_chars}* to xcstart so that it matches as much text as + * {operator} would. Then the tie-breaker (first matching rule of same + * length) ensures xcstart wins. We put back the extra stuff with yyless() + * in case it contains a star-slash that should terminate the comment. + * 2. In the operator rule, check for slash-star within the operator, and + * if found throw it back with yyless(). This handles the plus-slash-star + * problem. + * Dash-dash comments have similar interactions with the operator rule. + */ +/* + * "self" is the set of chars that should be returned as single-character + * tokens. "op_chars" is the set of chars that can make up "Op" tokens, + * which can be one or more characters long (but if a single-char token + * appears in the "self" set, it is not to be returned as an Op). Note + * that the sets overlap, but each has some chars that are not in the other. + * + * If you change either set, adjust the character lists appearing in the + * rule for "operator"! + */ +/* we no longer allow unary minus in numbers. + * instead we pass it separately to parser. there it gets + * coerced via doNegate() -- Leon aug 20 1999 + * + * {realfail1} and {realfail2} are added to prevent the need for scanner + * backup when the {real} rule fails to match completely. + */ +/* + * Dollar quoted strings are totally opaque, and no escaping is done on them. + * Other quoted strings must allow some special characters such as single-quote + * and newline. + * Embedded single-quotes are implemented both in the SQL standard + * style of two adjacent single quotes "''" and in the Postgres/Java style + * of escaped-quote "\'". + * Other embedded escaped characters are matched explicitly and the leading + * backslash is dropped from the string. + * Note that xcstart must appear before operator, as explained above! + * Also whitespace (comment) must appear before operator. + */ +#line 964 "scan.c" + +#define INITIAL 0 +#define xb 1 +#define xc 2 +#define xd 3 +#define xh 4 +#define xe 5 +#define xq 6 +#define xdolq 7 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int base_yywrap (void ); +#else +extern int base_yywrap (void ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( base_yytext, base_yyleng, 1, base_yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( base_yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( base_yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, base_yyin))==0 && ferror(base_yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(base_yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int base_yylex (void); + +#define YY_DECL int base_yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after base_yytext and base_yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 345 "scan.l" + + +#line 1125 "scan.c" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! base_yyin ) + base_yyin = stdin; + + if ( ! base_yyout ) + base_yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + base_yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + base_yy_create_buffer(base_yyin,YY_BUF_SIZE ); + } + + base_yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of base_yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 155 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 154 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +/* rule 1 can match eol */ +YY_RULE_SETUP +#line 347 "scan.l" +{ + /* ignore */ + } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 351 "scan.l" +{ + /* Set location in case of syntax error in comment */ + SET_YYLLOC(); + xcdepth = 0; + BEGIN(xc); + /* Put back any characters past slash-star; see above */ + yyless(2); + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 360 "scan.l" +{ + xcdepth++; + /* Put back any characters past slash-star; see above */ + yyless(2); + } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 366 "scan.l" +{ + if (xcdepth <= 0) + BEGIN(INITIAL); + else + xcdepth--; + } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 373 "scan.l" +{ + /* ignore */ + } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 377 "scan.l" +{ + /* ignore */ + } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 381 "scan.l" +{ + /* ignore */ + } + YY_BREAK +case YY_STATE_EOF(xc): +#line 385 "scan.l" +{ yyerror("unterminated /* comment"); } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 387 "scan.l" +{ + /* Binary bit type. + * At some point we should simply pass the string + * forward to the parser and label it there. + * In the meantime, place a leading "b" on the string + * to mark it for the input routine as a binary string. + */ + SET_YYLLOC(); + BEGIN(xb); + startlit(); + addlitchar('b'); + } + YY_BREAK +case 9: +/* rule 9 can match eol */ +#line 400 "scan.l" +case 10: +/* rule 10 can match eol */ +YY_RULE_SETUP +#line 400 "scan.l" +{ + yyless(1); + BEGIN(INITIAL); + yylval.str = litbufdup(); + return BCONST; + } + YY_BREAK +case 11: +/* rule 11 can match eol */ +#line 407 "scan.l" +case 12: +/* rule 12 can match eol */ +YY_RULE_SETUP +#line 407 "scan.l" +{ + addlit(base_yytext, base_yyleng); + } + YY_BREAK +case 13: +/* rule 13 can match eol */ +#line 411 "scan.l" +case 14: +/* rule 14 can match eol */ +YY_RULE_SETUP +#line 411 "scan.l" +{ + /* ignore */ + } + YY_BREAK +case YY_STATE_EOF(xb): +#line 414 "scan.l" +{ yyerror("unterminated bit string literal"); } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 416 "scan.l" +{ + /* Hexadecimal bit type. + * At some point we should simply pass the string + * forward to the parser and label it there. + * In the meantime, place a leading "x" on the string + * to mark it for the input routine as a hex string. + */ + SET_YYLLOC(); + BEGIN(xh); + startlit(); + addlitchar('x'); + } + YY_BREAK +case 16: +/* rule 16 can match eol */ +#line 429 "scan.l" +case 17: +/* rule 17 can match eol */ +YY_RULE_SETUP +#line 429 "scan.l" +{ + yyless(1); + BEGIN(INITIAL); + yylval.str = litbufdup(); + return XCONST; + } + YY_BREAK +case YY_STATE_EOF(xh): +#line 435 "scan.l" +{ yyerror("unterminated hexadecimal string literal"); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 437 "scan.l" +{ + /* National character. + * We will pass this along as a normal character string, + * but preceded with an internally-generated "NCHAR". + */ + const ScanKeyword *keyword; + + SET_YYLLOC(); + yyless(1); /* eat only 'n' this time */ + /* nchar had better be a keyword! */ + keyword = ScanKeywordLookup("nchar"); + yylval.keyword = keyword->name; + return keyword->value; + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 452 "scan.l" +{ + warn_on_first_escape = true; + saw_high_bit = false; + SET_YYLLOC(); + if (standard_conforming_strings) + BEGIN(xq); + else + BEGIN(xe); + startlit(); + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 462 "scan.l" +{ + warn_on_first_escape = false; + saw_high_bit = false; + SET_YYLLOC(); + BEGIN(xe); + startlit(); + } + YY_BREAK +case 21: +/* rule 21 can match eol */ +#line 470 "scan.l" +case 22: +/* rule 22 can match eol */ +YY_RULE_SETUP +#line 470 "scan.l" +{ + yyless(1); + BEGIN(INITIAL); + /* check that the data remains valid if it might have been + * made invalid by unescaping any chars. + */ + if (saw_high_bit); +/* pg_verifymbstr(literalbuf, literallen, false);*/ + yylval.str = litbufdup(); + return SCONST; + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 481 "scan.l" +{ + addlitchar('\''); + } + YY_BREAK +case 24: +/* rule 24 can match eol */ +YY_RULE_SETUP +#line 484 "scan.l" +{ + addlit(base_yytext, base_yyleng); + } + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 487 "scan.l" +{ + addlit(base_yytext, base_yyleng); + } + YY_BREAK +case 26: +/* rule 26 can match eol */ +YY_RULE_SETUP +#line 490 "scan.l" +{ + if (base_yytext[1] == '\'') + { +#if 0 + if (backslash_quote == BACKSLASH_QUOTE_OFF || + (backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING && + PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding()))) + ereport(ERROR, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("unsafe use of \\' in a string literal"), + errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."), + lexer_errposition())); +#endif + } + check_string_escape_warning(base_yytext[1]); + addlitchar(unescape_single_char(base_yytext[1])); + } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 507 "scan.l" +{ + unsigned char c = strtoul(base_yytext+1, NULL, 8); + + check_escape_warning(); + addlitchar(c); + if (IS_HIGHBIT_SET(c)) + saw_high_bit = true; + } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 515 "scan.l" +{ + unsigned char c = strtoul(base_yytext+2, NULL, 16); + + check_escape_warning(); + addlitchar(c); + if (IS_HIGHBIT_SET(c)) + saw_high_bit = true; + } + YY_BREAK +case 29: +/* rule 29 can match eol */ +YY_RULE_SETUP +#line 523 "scan.l" +{ + /* ignore */ + } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 526 "scan.l" +{ + /* This is only needed for \ just before EOF */ + addlitchar(base_yytext[0]); + } + YY_BREAK +case YY_STATE_EOF(xq): +case YY_STATE_EOF(xe): +#line 530 "scan.l" +{ yyerror("unterminated quoted string"); } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 532 "scan.l" +{ + SET_YYLLOC(); + dolqstart = pstrdup(base_yytext); + BEGIN(xdolq); + startlit(); + } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 538 "scan.l" +{ + /* throw back all but the initial "$" */ + yyless(1); + /* and treat it as {other} */ + return base_yytext[0]; + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 544 "scan.l" +{ + if (strcmp(base_yytext, dolqstart) == 0) + { + pfree(dolqstart); + BEGIN(INITIAL); + yylval.str = litbufdup(); + return SCONST; + } + else + { + /* + * When we fail to match $...$ to dolqstart, transfer + * the $... part to the output, but put back the final + * $ for rescanning. Consider $delim$...$junk$delim$ + */ + addlit(base_yytext, base_yyleng-1); + yyless(base_yyleng-1); + } + } + YY_BREAK +case 34: +/* rule 34 can match eol */ +YY_RULE_SETUP +#line 563 "scan.l" +{ + addlit(base_yytext, base_yyleng); + } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 566 "scan.l" +{ + addlit(base_yytext, base_yyleng); + } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 569 "scan.l" +{ + /* This is only needed for $ inside the quoted text */ + addlitchar(base_yytext[0]); + } + YY_BREAK +case YY_STATE_EOF(xdolq): +#line 573 "scan.l" +{ yyerror("unterminated dollar-quoted string"); } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 575 "scan.l" +{ + SET_YYLLOC(); + BEGIN(xd); + startlit(); + } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 580 "scan.l" +{ + char *ident; + + BEGIN(INITIAL); + if (literallen == 0) + yyerror("zero-length delimited identifier"); + ident = litbufdup(); + if (literallen >= NAMEDATALEN) + truncate_identifier(ident, literallen, true); + yylval.str = ident; + return IDENT; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 592 "scan.l" +{ + addlitchar('"'); + } + YY_BREAK +case 40: +/* rule 40 can match eol */ +YY_RULE_SETUP +#line 595 "scan.l" +{ + addlit(base_yytext, base_yyleng); + } + YY_BREAK +case YY_STATE_EOF(xd): +#line 598 "scan.l" +{ yyerror("unterminated quoted identifier"); } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 600 "scan.l" +{ + SET_YYLLOC(); + return TYPECAST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 605 "scan.l" +{ + SET_YYLLOC(); + return base_yytext[0]; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 610 "scan.l" +{ + /* + * Check for embedded slash-star or dash-dash; those + * are comment starts, so operator must stop there. + * Note that slash-star or dash-dash at the first + * character will match a prior rule, not this one. + */ + int nchars = base_yyleng; + char *slashstar = strstr(base_yytext, "/*"); + char *dashdash = strstr(base_yytext, "--"); + + if (slashstar && dashdash) + { + /* if both appear, take the first one */ + if (slashstar > dashdash) + slashstar = dashdash; + } + else if (!slashstar) + slashstar = dashdash; + if (slashstar) + nchars = slashstar - base_yytext; + + /* + * For SQL compatibility, '+' and '-' cannot be the + * last char of a multi-char operator unless the operator + * contains chars that are not in SQL operators. + * The idea is to lex '=-' as two operators, but not + * to forbid operator names like '?-' that could not be + * sequences of SQL operators. + */ + while (nchars > 1 && + (base_yytext[nchars-1] == '+' || + base_yytext[nchars-1] == '-')) + { + int ic; + + for (ic = nchars-2; ic >= 0; ic--) + { + if (strchr("~!@#^&|`?%", base_yytext[ic])) + break; + } + if (ic >= 0) + break; /* found a char that makes it OK */ + nchars--; /* else remove the +/-, and check again */ + } + + SET_YYLLOC(); + + if (nchars < base_yyleng) + { + /* Strip the unwanted chars from the token */ + yyless(nchars); + /* + * If what we have left is only one char, and it's + * one of the characters matching "self", then + * return it as a character token the same way + * that the "self" rule would have. + */ + if (nchars == 1 && + strchr(",()[].;:+-*/%^<>=", base_yytext[0])) + return base_yytext[0]; + } + + /* + * Complain if operator is too long. Unlike the case + * for identifiers, we make this an error not a notice- + * and-truncate, because the odds are we are looking at + * a syntactic mistake anyway. + */ + if (nchars >= NAMEDATALEN) + yyerror("operator too long"); + + /* Convert "!=" operator to "<>" for compatibility */ + if (strcmp(base_yytext, "!=") == 0) + yylval.str = pstrdup("<>"); + else + yylval.str = pstrdup(base_yytext); + return Op; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 690 "scan.l" +{ + SET_YYLLOC(); + yylval.ival = atol(base_yytext + 1); + return PARAM; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 696 "scan.l" +{ + long val; + char* endptr; + + SET_YYLLOC(); + errno = 0; + val = strtol(base_yytext, &endptr, 10); + if (*endptr != '\0' || errno == ERANGE +#ifdef HAVE_LONG_INT_64 + /* if long > 32 bits, check for overflow of int4 */ + || val != (long) ((int32) val) +#endif + ) + { + /* integer too large, treat it as a float */ + yylval.str = pstrdup(base_yytext); + return FCONST; + } + yylval.ival = val; + return ICONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 717 "scan.l" +{ + SET_YYLLOC(); + yylval.str = pstrdup(base_yytext); + return FCONST; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 722 "scan.l" +{ + SET_YYLLOC(); + yylval.str = pstrdup(base_yytext); + return FCONST; + } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 727 "scan.l" +{ + /* + * throw back the [Ee], and treat as {decimal}. Note + * that it is possible the input is actually {integer}, + * but since this case will almost certainly lead to a + * syntax error anyway, we don't bother to distinguish. + */ + yyless(base_yyleng-1); + SET_YYLLOC(); + yylval.str = pstrdup(base_yytext); + return FCONST; + } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 739 "scan.l" +{ + /* throw back the [Ee][+-], and proceed as above */ + yyless(base_yyleng-2); + SET_YYLLOC(); + yylval.str = pstrdup(base_yytext); + return FCONST; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 748 "scan.l" +{ + const ScanKeyword *keyword; + char *ident; + + SET_YYLLOC(); + + /* Is it a keyword? */ + keyword = ScanKeywordLookup(base_yytext); + if (keyword != NULL) + { + yylval.keyword = keyword->name; + return keyword->value; + } + + /* + * No. Convert the identifier to lower case, and truncate + * if necessary. + */ + ident = downcase_truncate_identifier(base_yytext, base_yyleng, true); + yylval.str = ident; + return IDENT; + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 771 "scan.l" +{ + SET_YYLLOC(); + return base_yytext[0]; + } + YY_BREAK +case YY_STATE_EOF(INITIAL): +#line 776 "scan.l" +{ + SET_YYLLOC(); + yyterminate(); + } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 781 "scan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1849 "scan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed base_yyin at a new source and called + * base_yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = base_yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( base_yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * base_yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of base_yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + base_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + base_yyrestart(base_yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 155 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 155 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 154); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + base_yyrestart(base_yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( base_yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve base_yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void base_yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + base_yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + base_yy_create_buffer(base_yyin,YY_BUF_SIZE ); + } + + base_yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + base_yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void base_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * base_yypop_buffer_state(); + * base_yypush_buffer_state(new_buffer); + */ + base_yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + base_yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (base_yywrap()) processing, but the only time this flag + * is looked at is after base_yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void base_yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + base_yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE base_yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) base_yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in base_yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) base_yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in base_yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + base_yy_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with base_yy_create_buffer() + * + */ + void base_yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + base_yyfree((void *) b->yy_ch_buf ); + + base_yyfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a base_yyrestart() or at EOF. + */ + static void base_yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + base_yy_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then base_yy_init_buffer was _probably_ + * called from base_yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void base_yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + base_yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void base_yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + base_yyensure_buffer_stack(); + + /* This block is copied from base_yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from base_yy_switch_to_buffer. */ + base_yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void base_yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + base_yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + base_yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void base_yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)base_yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)base_yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE base_yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) base_yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in base_yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + base_yy_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to base_yylex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * base_yy_scan_bytes() instead. + */ +YY_BUFFER_STATE base_yy_scan_string (yyconst char * yystr ) +{ + + return base_yy_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to base_yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE base_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) base_yyalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in base_yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = base_yy_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in base_yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up base_yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + base_yytext[base_yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = base_yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + base_yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int base_yyget_lineno (void) +{ + + return base_yylineno; +} + +/** Get the input stream. + * + */ +FILE *base_yyget_in (void) +{ + return base_yyin; +} + +/** Get the output stream. + * + */ +FILE *base_yyget_out (void) +{ + return base_yyout; +} + +/** Get the length of the current token. + * + */ +int base_yyget_leng (void) +{ + return base_yyleng; +} + +/** Get the current token. + * + */ + +char *base_yyget_text (void) +{ + return base_yytext; +} + +/** Set the current line number. + * @param line_number + * + */ +void base_yyset_lineno (int line_number ) +{ + + base_yylineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see base_yy_switch_to_buffer + */ +void base_yyset_in (FILE * in_str ) +{ + base_yyin = in_str ; +} + +void base_yyset_out (FILE * out_str ) +{ + base_yyout = out_str ; +} + +int base_yyget_debug (void) +{ + return base_yy_flex_debug; +} + +void base_yyset_debug (int bdebug ) +{ + base_yy_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from base_yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + base_yyin = stdin; + base_yyout = stdout; +#else + base_yyin = (FILE *) 0; + base_yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * base_yylex_init() + */ + return 0; +} + +/* base_yylex_destroy is for both reentrant and non-reentrant scanners. */ +int base_yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + base_yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + base_yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + base_yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * base_yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *base_yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *base_yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void base_yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see base_yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 781 "scan.l" + + + +/* + * lexer_errposition + * Report a lexical-analysis-time cursor position, if possible. + * + * This is expected to be used within an ereport() call. The return value + * is a dummy (always 0, in fact). + * + * Note that this can only be used for messages from the lexer itself, + * since it depends on scanbuf to still be valid. + */ +#if 0 +static int +lexer_errposition(void) +{ + int pos; + + /* Convert byte offset to character number */ + pos = pg_mbstrlen_with_len(scanbuf, yylloc) + 1; + /* And pass it to the ereport mechanism */ + return errposition(pos); +} +#endif + +/* + * yyerror + * Report a lexer or grammar error. + * + * The message's cursor position identifies the most recently lexed token. + * This is OK for syntax error messages from the Bison parser, because Bison + * parsers report error as soon as the first unparsable token is reached. + * Beware of using yyerror for other purposes, as the cursor position might + * be misleading! + */ +void +yyerror(const char *message) +{ + longjmp(jmpbuffer, 1); +} + + +/* + * Called before any actual parsing is done + */ +void +scanner_init(const char *str) +{ + int slen = strlen(str); + + /* + * Might be left over after ereport() + */ + if (YY_CURRENT_BUFFER) + base_yy_delete_buffer(YY_CURRENT_BUFFER); + + /* + * Make a scan buffer with special termination needed by flex. + */ + scanbuf = palloc(slen + 2); + memcpy(scanbuf, str, slen); + scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; + scanbufhandle = base_yy_scan_buffer(scanbuf,slen + 2); + + /* initialize literal buffer to a reasonable but expansible size */ + literalalloc = 1024; + literalbuf = (char *) palloc(literalalloc); + startlit(); + + BEGIN(INITIAL); +} + + +/* + * Called after parsing is done to clean up after scanner_init() + */ +void +scanner_finish(void) +{ + base_yy_delete_buffer(scanbufhandle); + pfree(scanbuf); +} + + +static void +addlit(char *ytext, int yleng) +{ + /* enlarge buffer if needed */ + if ((literallen+yleng) >= literalalloc) + { + do { + literalalloc *= 2; + } while ((literallen+yleng) >= literalalloc); + literalbuf = (char *) repalloc(literalbuf, literalalloc); + } + /* append new data, add trailing null */ + memcpy(literalbuf+literallen, ytext, yleng); + literallen += yleng; + literalbuf[literallen] = '\0'; +} + + +static void +addlitchar(unsigned char ychar) +{ + /* enlarge buffer if needed */ + if ((literallen+1) >= literalalloc) + { + literalalloc *= 2; + literalbuf = (char *) repalloc(literalbuf, literalalloc); + } + /* append new data, add trailing null */ + literalbuf[literallen] = ychar; + literallen += 1; + literalbuf[literallen] = '\0'; +} + + +/* + * One might be tempted to write pstrdup(literalbuf) instead of this, + * but for long literals this is much faster because the length is + * already known. + */ +static char * +litbufdup(void) +{ + char *new; + + new = palloc(literallen + 1); + memcpy(new, literalbuf, literallen+1); + return new; +} + + +static unsigned char +unescape_single_char(unsigned char c) +{ + /* Normally we wouldn't expect to see \n where n has its high bit set + * but we set the flag to check the string if we do get it, so + * that this doesn't become a way of getting around the coding validity + * checks. + */ + if (IS_HIGHBIT_SET(c)) + saw_high_bit = true; + + switch (c) + { + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + default: + return c; + } +} + +static void +check_string_escape_warning(unsigned char ychar) +{ +#if 0 + if (ychar == '\'') + { + if (warn_on_first_escape && escape_string_warning) + ereport(WARNING, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("nonstandard use of \\' in a string literal"), + errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."), + lexer_errposition())); + warn_on_first_escape = false; /* warn only once per string */ + } + else if (ychar == '\\') + { + if (warn_on_first_escape && escape_string_warning) + ereport(WARNING, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("nonstandard use of \\\\ in a string literal"), + errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."), + lexer_errposition())); + warn_on_first_escape = false; /* warn only once per string */ + } + else + check_escape_warning(); +#endif +} + +static void +check_escape_warning(void) +{ +#if 0 + if (warn_on_first_escape && escape_string_warning) + ereport(WARNING, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("nonstandard use of escape in a string literal"), + errhint("Use the escape string syntax for escapes, e.g., E'\\r\\n'."), + lexer_errposition())); + warn_on_first_escape = false; /* warn only once per string */ +#endif +} + +/* + * downcase_truncate_identifier() --- do appropriate downcasing and + * truncation of an unquoted identifier. Optionally warn of truncation. + * + * Returns a palloc'd string containing the adjusted identifier. + * + * Note: in some usages the passed string is not null-terminated. + * + * Note: the API of this function is designed to allow for downcasing + * transformations that increase the string length, but we don't yet + * support that. If you want to implement it, you'll need to fix + * SplitIdentifierString() in utils/adt/varlena.c. + */ +char * +downcase_truncate_identifier(const char *ident, int len, int warn) +{ + char *result; + int i; + + result = palloc(len + 1); + + /* + * SQL99 specifies Unicode-aware case normalization, which we don't yet + * have the infrastructure for. Instead we use tolower() to provide a + * locale-aware translation. However, there are some locales where this + * is not right either (eg, Turkish may do strange things with 'i' and + * 'I'). Our current compromise is to use tolower() for characters with + * the high bit set, and use an ASCII-only downcasing for 7-bit + * characters. + */ + for (i = 0; i < len; i++) + { + unsigned char ch = (unsigned char) ident[i]; + + if (ch >= 'A' && ch <= 'Z') + ch += 'a' - 'A'; + else if (ch >= 0x80 && isupper(ch)) + ch = tolower(ch); + result[i] = (char) ch; + } + result[i] = '\0'; + + if (i >= NAMEDATALEN) + truncate_identifier(result, i, warn); + + return result; +} + +/* + * truncate_identifier() --- truncate an identifier to NAMEDATALEN-1 bytes. + * + * The given string is modified in-place, if necessary. A warning is + * issued if requested. + * + * We require the caller to pass in the string length since this saves a + * strlen() call in some common usages. + */ +void +truncate_identifier(char *ident, int len, int warn) +{ + if (len >= NAMEDATALEN) + { + len = strlen(ident); /*pg_mbcliplen(ident, len, NAMEDATALEN - 1);*/ +#if 0 + if (warn) + ereport(NOTICE, + (errcode(ERRCODE_NAME_TOO_LONG), + errmsg("identifier \"%s\" will be truncated to \"%.*s\"", + ident, len, ident))); +#endif + ident[len] = '\0'; + } +} + diff --git a/parser/scan.l b/parser/scan.l new file mode 100644 index 0000000..8121623 --- /dev/null +++ b/parser/scan.l @@ -0,0 +1,1058 @@ +%{ +/*------------------------------------------------------------------------- + * + * scan.l + * lexical scanner for PostgreSQL + * + * NOTE NOTE NOTE: + * + * The rules in this file must be kept in sync with psql's lexer!!! + * + * The rules are designed so that the scanner never has to backtrack, + * in the sense that there is always a rule that can match the input + * consumed so far (the rule action may internally throw back some input + * with yyless(), however). As explained in the flex manual, this makes + * for a useful speed increase --- about a third faster than a plain -CF + * lexer, in simple testing. The extra complexity is mostly in the rules + * for handling float numbers and continued string literals. If you change + * the lexical rules, verify that you haven't broken the no-backtrack + * property by running flex with the "-b" option and checking that the + * resulting "lex.backup" file says that no backing up is needed. + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.141 2007/09/12 20:49:27 adunstan Exp $ + * + *------------------------------------------------------------------------- + */ +#include "pool_parser.h" + +#include +#include +#include +#include +#include + +#ifndef ereport +#define ereport(a,b) yyerror("") +#endif +#define IS_HIGHBIT_SET(c) 0 + +#include "gramparse.h" +#include "keywords.h" +/* Not needed now that this file is compiled as part of gram.y */ +/* #include "parser/parse.h" */ +#include "gram.h" +#include "scansup.h" + +#include "pool_memory.h" + + +/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ +/* +#undef fprintf +#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) +*/ + +static int xcdepth = 0; /* depth of nesting in slash-star comments */ +static char *dolqstart; /* current $foo$ quote start string */ + +/* + * GUC variables. This is a DIRECT violation of the warning given at the + * head of gram.y, ie flex/bison code must not depend on any GUC variables; + * as such, changing their values can induce very unintuitive behavior. + * But we shall have to live with it as a short-term thing until the switch + * to SQL-standard string syntax is complete. + */ +typedef enum +{ + BACKSLASH_QUOTE_OFF, + BACKSLASH_QUOTE_ON, + BACKSLASH_QUOTE_SAFE_ENCODING +} BackslashQuoteType; + +BackslashQuoteType backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING; +int escape_string_warning = true; +int standard_conforming_strings = false; + +static bool warn_on_first_escape; +static bool saw_high_bit = false; + +/* + * literalbuf is used to accumulate literal values when multiple rules + * are needed to parse a single literal. Call startlit to reset buffer + * to empty, addlit to add text. Note that the buffer is palloc'd and + * starts life afresh on every parse cycle. + */ +static char *literalbuf; /* expandable buffer */ +static int literallen; /* actual current length */ +static int literalalloc; /* current allocated buffer size */ + +#define startlit() (literalbuf[0] = '\0', literallen = 0) +static void addlit(char *ytext, int yleng); +static void addlitchar(unsigned char ychar); +static char *litbufdup(void); + +#if 0 +static int lexer_errposition(void); +#endif +static void check_escape_warning(void); +static void check_string_escape_warning(unsigned char ychar); + +extern char *yytext; + +/* + * Each call to yylex must set yylloc to the location of the found token + * (expressed as a byte offset from the start of the input text). + * When we parse a token that requires multiple lexer rules to process, + * this should be done in the first such rule, else yylloc will point + * into the middle of the token. + */ +#define SET_YYLLOC() (yylloc = yytext - scanbuf) + +/* Handles to the buffer that the lexer uses internally */ +static YY_BUFFER_STATE scanbufhandle; +static char *scanbuf; + +static unsigned char unescape_single_char(unsigned char c); +void yyerror(const char *s); + +%} + +%option 8bit +%option never-interactive +%option nodefault +%option nounput +%option noyywrap +%option prefix="base_yy" + +/* + * OK, here is a short description of lex/flex rules behavior. + * The longest pattern which matches an input string is always chosen. + * For equal-length patterns, the first occurring in the rules list is chosen. + * INITIAL is the starting state, to which all non-conditional rules apply. + * Exclusive states change parsing rules while the state is active. When in + * an exclusive state, only those rules defined for that state apply. + * + * We use exclusive states for quoted strings, extended comments, + * and to eliminate parsing troubles for numeric strings. + * Exclusive states: + * bit string literal + * extended C-style comments + * delimited identifiers (double-quoted identifiers) + * hexadecimal numeric string + * standard quoted strings + * extended quoted strings (support backslash escape sequences) + * $foo$ quoted strings + */ + +%x xb +%x xc +%x xd +%x xh +%x xe +%x xq +%x xdolq + +/* + * In order to make the world safe for Windows and Mac clients as well as + * Unix ones, we accept either \n or \r as a newline. A DOS-style \r\n + * sequence will be seen as two successive newlines, but that doesn't cause + * any problems. Comments that start with -- and extend to the next + * newline are treated as equivalent to a single whitespace character. + * + * NOTE a fine point: if there is no newline following --, we will absorb + * everything to the end of the input as a comment. This is correct. Older + * versions of Postgres failed to recognize -- as a comment if the input + * did not end with a newline. + * + * XXX perhaps \f (formfeed) should be treated as a newline as well? + * + * XXX if you change the set of whitespace characters, fix scanner_isspace() + * to agree, and see also the plpgsql lexer. + */ + +space [ \t\n\r\f] +horiz_space [ \t\f] +newline [\n\r] +non_newline [^\n\r] + +comment ("--"{non_newline}*) + +whitespace ({space}+|{comment}) + +/* + * SQL requires at least one newline in the whitespace separating + * string literals that are to be concatenated. Silly, but who are we + * to argue? Note that {whitespace_with_newline} should not have * after + * it, whereas {whitespace} should generally have a * after it... + */ + +special_whitespace ({space}+|{comment}{newline}) +horiz_whitespace ({horiz_space}|{comment}) +whitespace_with_newline ({horiz_whitespace}*{newline}{special_whitespace}*) + +/* + * To ensure that {quotecontinue} can be scanned without having to back up + * if the full pattern isn't matched, we include trailing whitespace in + * {quotestop}. This matches all cases where {quotecontinue} fails to match, + * except for {quote} followed by whitespace and just one "-" (not two, + * which would start a {comment}). To cover that we have {quotefail}. + * The actions for {quotestop} and {quotefail} must throw back characters + * beyond the quote proper. + */ +quote ' +quotestop {quote}{whitespace}* +quotecontinue {quote}{whitespace_with_newline}{quote} +quotefail {quote}{whitespace}*"-" + +/* Bit string + * It is tempting to scan the string for only those characters + * which are allowed. However, this leads to silently swallowed + * characters if illegal characters are included in the string. + * For example, if xbinside is [01] then B'ABCD' is interpreted + * as a zero-length string, and the ABCD' is lost! + * Better to pass the string forward and let the input routines + * validate the contents. + */ +xbstart [bB]{quote} +xbinside [^']* + +/* Hexadecimal number */ +xhstart [xX]{quote} +xhinside [^']* + +/* National character */ +xnstart [nN]{quote} + +/* Quoted string that allows backslash escapes */ +xestart [eE]{quote} +xeinside [^\\']+ +xeescape [\\][^0-7] +xeoctesc [\\][0-7]{1,3} +xehexesc [\\]x[0-9A-Fa-f]{1,2} + +/* Extended quote + * xqdouble implements embedded quote, '''' + */ +xqstart {quote} +xqdouble {quote}{quote} +xqinside [^']+ + +/* $foo$ style quotes ("dollar quoting") + * The quoted string starts with $foo$ where "foo" is an optional string + * in the form of an identifier, except that it may not contain "$", + * and extends to the first occurrence of an identical string. + * There is *no* processing of the quoted text. + * + * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim} + * fails to match its trailing "$". + */ +dolq_start [A-Za-z\200-\377_] +dolq_cont [A-Za-z\200-\377_0-9] +dolqdelim \$({dolq_start}{dolq_cont}*)?\$ +dolqfailed \${dolq_start}{dolq_cont}* +dolqinside [^$]+ + +/* Double quote + * Allows embedded spaces and other special characters into identifiers. + */ +dquote \" +xdstart {dquote} +xdstop {dquote} +xddouble {dquote}{dquote} +xdinside [^"]+ + +/* C-style comments + * + * The "extended comment" syntax closely resembles allowable operator syntax. + * The tricky part here is to get lex to recognize a string starting with + * slash-star as a comment, when interpreting it as an operator would produce + * a longer match --- remember lex will prefer a longer match! Also, if we + * have something like plus-slash-star, lex will think this is a 3-character + * operator whereas we want to see it as a + operator and a comment start. + * The solution is two-fold: + * 1. append {op_chars}* to xcstart so that it matches as much text as + * {operator} would. Then the tie-breaker (first matching rule of same + * length) ensures xcstart wins. We put back the extra stuff with yyless() + * in case it contains a star-slash that should terminate the comment. + * 2. In the operator rule, check for slash-star within the operator, and + * if found throw it back with yyless(). This handles the plus-slash-star + * problem. + * Dash-dash comments have similar interactions with the operator rule. + */ +xcstart \/\*{op_chars}* +xcstop \*+\/ +xcinside [^*/]+ + +digit [0-9] +ident_start [A-Za-z\200-\377_] +ident_cont [A-Za-z\200-\377_0-9\$] + +identifier {ident_start}{ident_cont}* + +typecast "::" + +/* + * "self" is the set of chars that should be returned as single-character + * tokens. "op_chars" is the set of chars that can make up "Op" tokens, + * which can be one or more characters long (but if a single-char token + * appears in the "self" set, it is not to be returned as an Op). Note + * that the sets overlap, but each has some chars that are not in the other. + * + * If you change either set, adjust the character lists appearing in the + * rule for "operator"! + */ +self [,()\[\].;\:\+\-\*\/\%\^\<\>\=] +op_chars [\~\!\@\#\^\&\|\`\?\+\-\*\/\%\<\>\=] +operator {op_chars}+ + +/* we no longer allow unary minus in numbers. + * instead we pass it separately to parser. there it gets + * coerced via doNegate() -- Leon aug 20 1999 + * + * {realfail1} and {realfail2} are added to prevent the need for scanner + * backup when the {real} rule fails to match completely. + */ + +integer {digit}+ +decimal (({digit}*\.{digit}+)|({digit}+\.{digit}*)) +real ({integer}|{decimal})[Ee][-+]?{digit}+ +realfail1 ({integer}|{decimal})[Ee] +realfail2 ({integer}|{decimal})[Ee][-+] + +param \${integer} + +other . + +/* + * Dollar quoted strings are totally opaque, and no escaping is done on them. + * Other quoted strings must allow some special characters such as single-quote + * and newline. + * Embedded single-quotes are implemented both in the SQL standard + * style of two adjacent single quotes "''" and in the Postgres/Java style + * of escaped-quote "\'". + * Other embedded escaped characters are matched explicitly and the leading + * backslash is dropped from the string. + * Note that xcstart must appear before operator, as explained above! + * Also whitespace (comment) must appear before operator. + */ + +%% + +{whitespace} { + /* ignore */ + } + +{xcstart} { + /* Set location in case of syntax error in comment */ + SET_YYLLOC(); + xcdepth = 0; + BEGIN(xc); + /* Put back any characters past slash-star; see above */ + yyless(2); + } + +{xcstart} { + xcdepth++; + /* Put back any characters past slash-star; see above */ + yyless(2); + } + +{xcstop} { + if (xcdepth <= 0) + BEGIN(INITIAL); + else + xcdepth--; + } + +{xcinside} { + /* ignore */ + } + +{op_chars} { + /* ignore */ + } + +\*+ { + /* ignore */ + } + +<> { yyerror("unterminated /* comment"); } + +{xbstart} { + /* Binary bit type. + * At some point we should simply pass the string + * forward to the parser and label it there. + * In the meantime, place a leading "b" on the string + * to mark it for the input routine as a binary string. + */ + SET_YYLLOC(); + BEGIN(xb); + startlit(); + addlitchar('b'); + } +{quotestop} | +{quotefail} { + yyless(1); + BEGIN(INITIAL); + yylval.str = litbufdup(); + return BCONST; + } +{xhinside} | +{xbinside} { + addlit(yytext, yyleng); + } +{quotecontinue} | +{quotecontinue} { + /* ignore */ + } +<> { yyerror("unterminated bit string literal"); } + +{xhstart} { + /* Hexadecimal bit type. + * At some point we should simply pass the string + * forward to the parser and label it there. + * In the meantime, place a leading "x" on the string + * to mark it for the input routine as a hex string. + */ + SET_YYLLOC(); + BEGIN(xh); + startlit(); + addlitchar('x'); + } +{quotestop} | +{quotefail} { + yyless(1); + BEGIN(INITIAL); + yylval.str = litbufdup(); + return XCONST; + } +<> { yyerror("unterminated hexadecimal string literal"); } + +{xnstart} { + /* National character. + * We will pass this along as a normal character string, + * but preceded with an internally-generated "NCHAR". + */ + const ScanKeyword *keyword; + + SET_YYLLOC(); + yyless(1); /* eat only 'n' this time */ + /* nchar had better be a keyword! */ + keyword = ScanKeywordLookup("nchar"); + yylval.keyword = keyword->name; + return keyword->value; + } + +{xqstart} { + warn_on_first_escape = true; + saw_high_bit = false; + SET_YYLLOC(); + if (standard_conforming_strings) + BEGIN(xq); + else + BEGIN(xe); + startlit(); + } +{xestart} { + warn_on_first_escape = false; + saw_high_bit = false; + SET_YYLLOC(); + BEGIN(xe); + startlit(); + } +{quotestop} | +{quotefail} { + yyless(1); + BEGIN(INITIAL); + /* check that the data remains valid if it might have been + * made invalid by unescaping any chars. + */ + if (saw_high_bit); +/* pg_verifymbstr(literalbuf, literallen, false);*/ + yylval.str = litbufdup(); + return SCONST; + } +{xqdouble} { + addlitchar('\''); + } +{xqinside} { + addlit(yytext, yyleng); + } +{xeinside} { + addlit(yytext, yyleng); + } +{xeescape} { + if (yytext[1] == '\'') + { +#if 0 + if (backslash_quote == BACKSLASH_QUOTE_OFF || + (backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING && + PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding()))) + ereport(ERROR, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("unsafe use of \\' in a string literal"), + errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."), + lexer_errposition())); +#endif + } + check_string_escape_warning(yytext[1]); + addlitchar(unescape_single_char(yytext[1])); + } +{xeoctesc} { + unsigned char c = strtoul(yytext+1, NULL, 8); + + check_escape_warning(); + addlitchar(c); + if (IS_HIGHBIT_SET(c)) + saw_high_bit = true; + } +{xehexesc} { + unsigned char c = strtoul(yytext+2, NULL, 16); + + check_escape_warning(); + addlitchar(c); + if (IS_HIGHBIT_SET(c)) + saw_high_bit = true; + } +{quotecontinue} { + /* ignore */ + } +. { + /* This is only needed for \ just before EOF */ + addlitchar(yytext[0]); + } +<> { yyerror("unterminated quoted string"); } + +{dolqdelim} { + SET_YYLLOC(); + dolqstart = pstrdup(yytext); + BEGIN(xdolq); + startlit(); + } +{dolqfailed} { + /* throw back all but the initial "$" */ + yyless(1); + /* and treat it as {other} */ + return yytext[0]; + } +{dolqdelim} { + if (strcmp(yytext, dolqstart) == 0) + { + pfree(dolqstart); + BEGIN(INITIAL); + yylval.str = litbufdup(); + return SCONST; + } + else + { + /* + * When we fail to match $...$ to dolqstart, transfer + * the $... part to the output, but put back the final + * $ for rescanning. Consider $delim$...$junk$delim$ + */ + addlit(yytext, yyleng-1); + yyless(yyleng-1); + } + } +{dolqinside} { + addlit(yytext, yyleng); + } +{dolqfailed} { + addlit(yytext, yyleng); + } +. { + /* This is only needed for $ inside the quoted text */ + addlitchar(yytext[0]); + } +<> { yyerror("unterminated dollar-quoted string"); } + +{xdstart} { + SET_YYLLOC(); + BEGIN(xd); + startlit(); + } +{xdstop} { + char *ident; + + BEGIN(INITIAL); + if (literallen == 0) + yyerror("zero-length delimited identifier"); + ident = litbufdup(); + if (literallen >= NAMEDATALEN) + truncate_identifier(ident, literallen, true); + yylval.str = ident; + return IDENT; + } +{xddouble} { + addlitchar('"'); + } +{xdinside} { + addlit(yytext, yyleng); + } +<> { yyerror("unterminated quoted identifier"); } + +{typecast} { + SET_YYLLOC(); + return TYPECAST; + } + +{self} { + SET_YYLLOC(); + return yytext[0]; + } + +{operator} { + /* + * Check for embedded slash-star or dash-dash; those + * are comment starts, so operator must stop there. + * Note that slash-star or dash-dash at the first + * character will match a prior rule, not this one. + */ + int nchars = yyleng; + char *slashstar = strstr(yytext, "/*"); + char *dashdash = strstr(yytext, "--"); + + if (slashstar && dashdash) + { + /* if both appear, take the first one */ + if (slashstar > dashdash) + slashstar = dashdash; + } + else if (!slashstar) + slashstar = dashdash; + if (slashstar) + nchars = slashstar - yytext; + + /* + * For SQL compatibility, '+' and '-' cannot be the + * last char of a multi-char operator unless the operator + * contains chars that are not in SQL operators. + * The idea is to lex '=-' as two operators, but not + * to forbid operator names like '?-' that could not be + * sequences of SQL operators. + */ + while (nchars > 1 && + (yytext[nchars-1] == '+' || + yytext[nchars-1] == '-')) + { + int ic; + + for (ic = nchars-2; ic >= 0; ic--) + { + if (strchr("~!@#^&|`?%", yytext[ic])) + break; + } + if (ic >= 0) + break; /* found a char that makes it OK */ + nchars--; /* else remove the +/-, and check again */ + } + + SET_YYLLOC(); + + if (nchars < yyleng) + { + /* Strip the unwanted chars from the token */ + yyless(nchars); + /* + * If what we have left is only one char, and it's + * one of the characters matching "self", then + * return it as a character token the same way + * that the "self" rule would have. + */ + if (nchars == 1 && + strchr(",()[].;:+-*/%^<>=", yytext[0])) + return yytext[0]; + } + + /* + * Complain if operator is too long. Unlike the case + * for identifiers, we make this an error not a notice- + * and-truncate, because the odds are we are looking at + * a syntactic mistake anyway. + */ + if (nchars >= NAMEDATALEN) + yyerror("operator too long"); + + /* Convert "!=" operator to "<>" for compatibility */ + if (strcmp(yytext, "!=") == 0) + yylval.str = pstrdup("<>"); + else + yylval.str = pstrdup(yytext); + return Op; + } + +{param} { + SET_YYLLOC(); + yylval.ival = atol(yytext + 1); + return PARAM; + } + +{integer} { + long val; + char* endptr; + + SET_YYLLOC(); + errno = 0; + val = strtol(yytext, &endptr, 10); + if (*endptr != '\0' || errno == ERANGE +#ifdef HAVE_LONG_INT_64 + /* if long > 32 bits, check for overflow of int4 */ + || val != (long) ((int32) val) +#endif + ) + { + /* integer too large, treat it as a float */ + yylval.str = pstrdup(yytext); + return FCONST; + } + yylval.ival = val; + return ICONST; + } +{decimal} { + SET_YYLLOC(); + yylval.str = pstrdup(yytext); + return FCONST; + } +{real} { + SET_YYLLOC(); + yylval.str = pstrdup(yytext); + return FCONST; + } +{realfail1} { + /* + * throw back the [Ee], and treat as {decimal}. Note + * that it is possible the input is actually {integer}, + * but since this case will almost certainly lead to a + * syntax error anyway, we don't bother to distinguish. + */ + yyless(yyleng-1); + SET_YYLLOC(); + yylval.str = pstrdup(yytext); + return FCONST; + } +{realfail2} { + /* throw back the [Ee][+-], and proceed as above */ + yyless(yyleng-2); + SET_YYLLOC(); + yylval.str = pstrdup(yytext); + return FCONST; + } + + +{identifier} { + const ScanKeyword *keyword; + char *ident; + + SET_YYLLOC(); + + /* Is it a keyword? */ + keyword = ScanKeywordLookup(yytext); + if (keyword != NULL) + { + yylval.keyword = keyword->name; + return keyword->value; + } + + /* + * No. Convert the identifier to lower case, and truncate + * if necessary. + */ + ident = downcase_truncate_identifier(yytext, yyleng, true); + yylval.str = ident; + return IDENT; + } + +{other} { + SET_YYLLOC(); + return yytext[0]; + } + +<> { + SET_YYLLOC(); + yyterminate(); + } + +%% + +/* + * lexer_errposition + * Report a lexical-analysis-time cursor position, if possible. + * + * This is expected to be used within an ereport() call. The return value + * is a dummy (always 0, in fact). + * + * Note that this can only be used for messages from the lexer itself, + * since it depends on scanbuf to still be valid. + */ +#if 0 +static int +lexer_errposition(void) +{ + int pos; + + /* Convert byte offset to character number */ + pos = pg_mbstrlen_with_len(scanbuf, yylloc) + 1; + /* And pass it to the ereport mechanism */ + return errposition(pos); +} +#endif + +/* + * yyerror + * Report a lexer or grammar error. + * + * The message's cursor position identifies the most recently lexed token. + * This is OK for syntax error messages from the Bison parser, because Bison + * parsers report error as soon as the first unparsable token is reached. + * Beware of using yyerror for other purposes, as the cursor position might + * be misleading! + */ +void +yyerror(const char *message) +{ + longjmp(jmpbuffer, 1); +} + + +/* + * Called before any actual parsing is done + */ +void +scanner_init(const char *str) +{ + int slen = strlen(str); + + /* + * Might be left over after ereport() + */ + if (YY_CURRENT_BUFFER) + yy_delete_buffer(YY_CURRENT_BUFFER); + + /* + * Make a scan buffer with special termination needed by flex. + */ + scanbuf = palloc(slen + 2); + memcpy(scanbuf, str, slen); + scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR; + scanbufhandle = yy_scan_buffer(scanbuf, slen + 2); + + /* initialize literal buffer to a reasonable but expansible size */ + literalalloc = 1024; + literalbuf = (char *) palloc(literalalloc); + startlit(); + + BEGIN(INITIAL); +} + + +/* + * Called after parsing is done to clean up after scanner_init() + */ +void +scanner_finish(void) +{ + yy_delete_buffer(scanbufhandle); + pfree(scanbuf); +} + + +static void +addlit(char *ytext, int yleng) +{ + /* enlarge buffer if needed */ + if ((literallen+yleng) >= literalalloc) + { + do { + literalalloc *= 2; + } while ((literallen+yleng) >= literalalloc); + literalbuf = (char *) repalloc(literalbuf, literalalloc); + } + /* append new data, add trailing null */ + memcpy(literalbuf+literallen, ytext, yleng); + literallen += yleng; + literalbuf[literallen] = '\0'; +} + + +static void +addlitchar(unsigned char ychar) +{ + /* enlarge buffer if needed */ + if ((literallen+1) >= literalalloc) + { + literalalloc *= 2; + literalbuf = (char *) repalloc(literalbuf, literalalloc); + } + /* append new data, add trailing null */ + literalbuf[literallen] = ychar; + literallen += 1; + literalbuf[literallen] = '\0'; +} + + +/* + * One might be tempted to write pstrdup(literalbuf) instead of this, + * but for long literals this is much faster because the length is + * already known. + */ +static char * +litbufdup(void) +{ + char *new; + + new = palloc(literallen + 1); + memcpy(new, literalbuf, literallen+1); + return new; +} + + +static unsigned char +unescape_single_char(unsigned char c) +{ + /* Normally we wouldn't expect to see \n where n has its high bit set + * but we set the flag to check the string if we do get it, so + * that this doesn't become a way of getting around the coding validity + * checks. + */ + if (IS_HIGHBIT_SET(c)) + saw_high_bit = true; + + switch (c) + { + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + default: + return c; + } +} + +static void +check_string_escape_warning(unsigned char ychar) +{ +#if 0 + if (ychar == '\'') + { + if (warn_on_first_escape && escape_string_warning) + ereport(WARNING, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("nonstandard use of \\' in a string literal"), + errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."), + lexer_errposition())); + warn_on_first_escape = false; /* warn only once per string */ + } + else if (ychar == '\\') + { + if (warn_on_first_escape && escape_string_warning) + ereport(WARNING, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("nonstandard use of \\\\ in a string literal"), + errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."), + lexer_errposition())); + warn_on_first_escape = false; /* warn only once per string */ + } + else + check_escape_warning(); +#endif +} + +static void +check_escape_warning(void) +{ +#if 0 + if (warn_on_first_escape && escape_string_warning) + ereport(WARNING, + (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER), + errmsg("nonstandard use of escape in a string literal"), + errhint("Use the escape string syntax for escapes, e.g., E'\\r\\n'."), + lexer_errposition())); + warn_on_first_escape = false; /* warn only once per string */ +#endif +} + +/* + * downcase_truncate_identifier() --- do appropriate downcasing and + * truncation of an unquoted identifier. Optionally warn of truncation. + * + * Returns a palloc'd string containing the adjusted identifier. + * + * Note: in some usages the passed string is not null-terminated. + * + * Note: the API of this function is designed to allow for downcasing + * transformations that increase the string length, but we don't yet + * support that. If you want to implement it, you'll need to fix + * SplitIdentifierString() in utils/adt/varlena.c. + */ +char * +downcase_truncate_identifier(const char *ident, int len, int warn) +{ + char *result; + int i; + + result = palloc(len + 1); + + /* + * SQL99 specifies Unicode-aware case normalization, which we don't yet + * have the infrastructure for. Instead we use tolower() to provide a + * locale-aware translation. However, there are some locales where this + * is not right either (eg, Turkish may do strange things with 'i' and + * 'I'). Our current compromise is to use tolower() for characters with + * the high bit set, and use an ASCII-only downcasing for 7-bit + * characters. + */ + for (i = 0; i < len; i++) + { + unsigned char ch = (unsigned char) ident[i]; + + if (ch >= 'A' && ch <= 'Z') + ch += 'a' - 'A'; + else if (ch >= 0x80 && isupper(ch)) + ch = tolower(ch); + result[i] = (char) ch; + } + result[i] = '\0'; + + if (i >= NAMEDATALEN) + truncate_identifier(result, i, warn); + + return result; +} + +/* + * truncate_identifier() --- truncate an identifier to NAMEDATALEN-1 bytes. + * + * The given string is modified in-place, if necessary. A warning is + * issued if requested. + * + * We require the caller to pass in the string length since this saves a + * strlen() call in some common usages. + */ +void +truncate_identifier(char *ident, int len, int warn) +{ + if (len >= NAMEDATALEN) + { + len = strlen(ident); /*pg_mbcliplen(ident, len, NAMEDATALEN - 1);*/ +#if 0 + if (warn) + ereport(NOTICE, + (errcode(ERRCODE_NAME_TOO_LONG), + errmsg("identifier \"%s\" will be truncated to \"%.*s\"", + ident, len, ident))); +#endif + ident[len] = '\0'; + } +} diff --git a/parser/scansup.h b/parser/scansup.h new file mode 100644 index 0000000..1cdf750 --- /dev/null +++ b/parser/scansup.h @@ -0,0 +1,26 @@ +/*------------------------------------------------------------------------- + * + * scansup.h + * scanner support routines. used by both the bootstrap lexer + * as well as the normal lexer + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/parser/scansup.h,v 1.18 2004/12/31 22:03:38 pgsql Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef SCANSUP_H +#define SCANSUP_H + +extern char *scanstr(const char *s); + +extern char *downcase_truncate_identifier(const char *ident, int len, + int warn); + +extern void truncate_identifier(char *ident, int len, int warn); + +#endif /* SCANSUP_H */ diff --git a/parser/value.c b/parser/value.c new file mode 100644 index 0000000..94a2693 --- /dev/null +++ b/parser/value.c @@ -0,0 +1,78 @@ +/*------------------------------------------------------------------------- + * + * value.c + * implementation of Value nodes + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Copyright (c) 2003-2005, PostgreSQL Global Development Group + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/backend/nodes/value.c,v 1.2 2005/01/01 20:44:15 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +/*#include "postgres.h"*/ + +#include +#include "pool_memory.h" +#include "parsenodes.h" + +/* + * makeInteger + */ +Value * +makeInteger(long i) +{ + Value *v = makeNode(Value); + + v->type = T_Integer; + v->val.ival = i; + return v; +} + +/* + * makeFloat + * + * Caller is responsible for passing a palloc'd string. + */ +Value * +makeFloat(char *numericStr) +{ + Value *v = makeNode(Value); + + v->type = T_Float; + v->val.str = numericStr; + return v; +} + +/* + * makeString + * + * Caller is responsible for passing a palloc'd string. + */ +Value * +makeString(char *str) +{ + Value *v = makeNode(Value); + + v->type = T_String; + v->val.str = str; + return v; +} + +/* + * makeBitString + * + * Caller is responsible for passing a palloc'd string. + */ +Value * +makeBitString(char *str) +{ + Value *v = makeNode(Value); + + v->type = T_BitString; + v->val.str = str; + return v; +} diff --git a/parser/value.h b/parser/value.h new file mode 100644 index 0000000..c7e5aef --- /dev/null +++ b/parser/value.h @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------- + * + * value.h + * interface for Value nodes + * + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Copyright (c) 2003-2007, PostgreSQL Global Development Group + * + * $PostgreSQL: pgsql/src/include/nodes/value.h,v 1.6 2007/01/05 22:19:56 momjian Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef VALUE_H +#define VALUE_H + +#include "nodes.h" + +/*---------------------- + * Value node + * + * The same Value struct is used for five node types: T_Integer, + * T_Float, T_String, T_BitString, T_Null. + * + * Integral values are actually represented by a machine integer, + * but both floats and strings are represented as strings. + * Using T_Float as the node type simply indicates that + * the contents of the string look like a valid numeric literal. + * + * (Before Postgres 7.0, we used a double to represent T_Float, + * but that creates loss-of-precision problems when the value is + * ultimately destined to be converted to NUMERIC. Since Value nodes + * are only used in the parsing process, not for runtime data, it's + * better to use the more general representation.) + * + * Note that an integer-looking string will get lexed as T_Float if + * the value is too large to fit in a 'long'. + * + * Nulls, of course, don't need the value part at all. + *---------------------- + */ +typedef struct Value +{ + NodeTag type; /* tag appropriately (eg. T_String) */ + union ValUnion + { + long ival; /* machine integer */ + char *str; /* string */ + } val; +} Value; + +#define intVal(v) (((Value *)(v))->val.ival) +#define floatVal(v) atof(((Value *)(v))->val.str) +#define strVal(v) (((Value *)(v))->val.str) + +extern Value *makeInteger(long i); +extern Value *makeFloat(char *numericStr); +extern Value *makeString(char *str); +extern Value *makeBitString(char *str); + +#endif /* VALUE_H */ diff --git a/pcp.conf.sample b/pcp.conf.sample new file mode 100644 index 0000000..7e3f620 --- /dev/null +++ b/pcp.conf.sample @@ -0,0 +1,28 @@ +# PCP Client Authentication Configuration File +# ============================================ +# +# This file contains user ID and his password for pgpool +# communication manager authentication. +# +# Note that users defined here do not need to be PostgreSQL +# users. These users are authorized ONLY for pgpool +# communication manager. +# +# File Format +# =========== +# +# List one UserID and password on a single line. They must +# be concatenated together using ':' (colon) between them. +# No spaces or tabs are allowed anywhere in the line. +# +# Example: +# postgres:e8a48653851e28c69d0506508fb27fc5 +# +# Be aware that there will be no spaces or tabs at the +# beginning of the line! although the above example looks +# like so. +# +# Lines beginning with '#' (pound) are comments and will +# be ignored. Again, no spaces or tabs allowed before '#'. + +# USERID:MD5PASSWD diff --git a/pcp/Makefile.am b/pcp/Makefile.am new file mode 100644 index 0000000..bf2ca58 --- /dev/null +++ b/pcp/Makefile.am @@ -0,0 +1,33 @@ +AM_CPPFLAGS = -D_GNU_SOURCE -I .. -I @PGSQL_INCLUDE_DIR@ + +lib_LTLIBRARIES = libpcp.la +libpcp_la_SOURCES = pcp.h ../pool_type.h md5.h pcp.c pcp_stream.h pcp_stream.c pcp_error.c md5.c +libpcp_la_LIBS = +include_HEADERS = pcp.h ../pool_type.h + +md5.c: ../md5.c + rm -f $@ && ln -s $< . +md5.h: ../md5.h + rm -f $@ && ln -s $< . + +bin_PROGRAMS = pcp_stop_pgpool pcp_node_count pcp_node_info pcp_proc_count pcp_proc_info \ + pcp_systemdb_info pcp_detach_node pcp_attach_node pcp_recovery_node +pcp_stop_pgpool_SOURCES = pcp_stop_pgpool.c pcp.h +pcp_stop_pgpool_LDADD = libpcp.la +pcp_stop_pgpool_LDFLAGS = +pcp_node_count_SOURCES = pcp_node_count.c pcp.h +pcp_node_count_LDADD = libpcp.la +pcp_node_info_SOURCES = pcp_node_info.c pcp.h +pcp_node_info_LDADD = libpcp.la +pcp_proc_count_SOURCES = pcp_proc_count.c pcp.h +pcp_proc_count_LDADD = libpcp.la +pcp_proc_info_SOURCES = pcp_proc_info.c pcp.h +pcp_proc_info_LDADD = libpcp.la +pcp_systemdb_info_SOURCES = pcp_systemdb_info.c pcp.h +pcp_systemdb_info_LDADD = libpcp.la +pcp_detach_node_SOURCES = pcp_detach_node.c pcp.h +pcp_detach_node_LDADD = libpcp.la +pcp_attach_node_SOURCES = pcp_attach_node.c pcp.h +pcp_attach_node_LDADD = libpcp.la +pcp_recovery_node_SOURCES = pcp_recovery_node.c pcp.h +pcp_recovery_node_LDADD = libpcp.la diff --git a/pcp/Makefile.in b/pcp/Makefile.in new file mode 100644 index 0000000..e5d7693 --- /dev/null +++ b/pcp/Makefile.in @@ -0,0 +1,623 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = pcp_stop_pgpool$(EXEEXT) pcp_node_count$(EXEEXT) \ + pcp_node_info$(EXEEXT) pcp_proc_count$(EXEEXT) \ + pcp_proc_info$(EXEEXT) pcp_systemdb_info$(EXEEXT) \ + pcp_detach_node$(EXEEXT) pcp_attach_node$(EXEEXT) \ + pcp_recovery_node$(EXEEXT) +subdir = pcp +DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/ac_func_accept_argtypes.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ + "$(DESTDIR)$(includedir)" +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(lib_LTLIBRARIES) +libpcp_la_LIBADD = +am_libpcp_la_OBJECTS = pcp.lo pcp_stream.lo pcp_error.lo md5.lo +libpcp_la_OBJECTS = $(am_libpcp_la_OBJECTS) +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_pcp_attach_node_OBJECTS = pcp_attach_node.$(OBJEXT) +pcp_attach_node_OBJECTS = $(am_pcp_attach_node_OBJECTS) +pcp_attach_node_DEPENDENCIES = libpcp.la +am_pcp_detach_node_OBJECTS = pcp_detach_node.$(OBJEXT) +pcp_detach_node_OBJECTS = $(am_pcp_detach_node_OBJECTS) +pcp_detach_node_DEPENDENCIES = libpcp.la +am_pcp_node_count_OBJECTS = pcp_node_count.$(OBJEXT) +pcp_node_count_OBJECTS = $(am_pcp_node_count_OBJECTS) +pcp_node_count_DEPENDENCIES = libpcp.la +am_pcp_node_info_OBJECTS = pcp_node_info.$(OBJEXT) +pcp_node_info_OBJECTS = $(am_pcp_node_info_OBJECTS) +pcp_node_info_DEPENDENCIES = libpcp.la +am_pcp_proc_count_OBJECTS = pcp_proc_count.$(OBJEXT) +pcp_proc_count_OBJECTS = $(am_pcp_proc_count_OBJECTS) +pcp_proc_count_DEPENDENCIES = libpcp.la +am_pcp_proc_info_OBJECTS = pcp_proc_info.$(OBJEXT) +pcp_proc_info_OBJECTS = $(am_pcp_proc_info_OBJECTS) +pcp_proc_info_DEPENDENCIES = libpcp.la +am_pcp_recovery_node_OBJECTS = pcp_recovery_node.$(OBJEXT) +pcp_recovery_node_OBJECTS = $(am_pcp_recovery_node_OBJECTS) +pcp_recovery_node_DEPENDENCIES = libpcp.la +am_pcp_stop_pgpool_OBJECTS = pcp_stop_pgpool.$(OBJEXT) +pcp_stop_pgpool_OBJECTS = $(am_pcp_stop_pgpool_OBJECTS) +pcp_stop_pgpool_DEPENDENCIES = libpcp.la +am_pcp_systemdb_info_OBJECTS = pcp_systemdb_info.$(OBJEXT) +pcp_systemdb_info_OBJECTS = $(am_pcp_systemdb_info_OBJECTS) +pcp_systemdb_info_DEPENDENCIES = libpcp.la +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libpcp_la_SOURCES) $(pcp_attach_node_SOURCES) \ + $(pcp_detach_node_SOURCES) $(pcp_node_count_SOURCES) \ + $(pcp_node_info_SOURCES) $(pcp_proc_count_SOURCES) \ + $(pcp_proc_info_SOURCES) $(pcp_recovery_node_SOURCES) \ + $(pcp_stop_pgpool_SOURCES) $(pcp_systemdb_info_SOURCES) +DIST_SOURCES = $(libpcp_la_SOURCES) $(pcp_attach_node_SOURCES) \ + $(pcp_detach_node_SOURCES) $(pcp_node_count_SOURCES) \ + $(pcp_node_info_SOURCES) $(pcp_proc_count_SOURCES) \ + $(pcp_proc_info_SOURCES) $(pcp_recovery_node_SOURCES) \ + $(pcp_stop_pgpool_SOURCES) $(pcp_systemdb_info_SOURCES) +includeHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(include_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PGCONFIG = @PGCONFIG@ +PGSQL_INCLUDE_DIR = @PGSQL_INCLUDE_DIR@ +PGSQL_LIB_DIR = @PGSQL_LIB_DIR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +YACC = @YACC@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +enable_rpath_FALSE = @enable_rpath_FALSE@ +enable_rpath_TRUE = @enable_rpath_TRUE@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +AM_CPPFLAGS = -D_GNU_SOURCE -I .. -I @PGSQL_INCLUDE_DIR@ +lib_LTLIBRARIES = libpcp.la +libpcp_la_SOURCES = pcp.h ../pool_type.h md5.h pcp.c pcp_stream.h pcp_stream.c pcp_error.c md5.c +libpcp_la_LIBS = +include_HEADERS = pcp.h ../pool_type.h +pcp_stop_pgpool_SOURCES = pcp_stop_pgpool.c pcp.h +pcp_stop_pgpool_LDADD = libpcp.la +pcp_stop_pgpool_LDFLAGS = +pcp_node_count_SOURCES = pcp_node_count.c pcp.h +pcp_node_count_LDADD = libpcp.la +pcp_node_info_SOURCES = pcp_node_info.c pcp.h +pcp_node_info_LDADD = libpcp.la +pcp_proc_count_SOURCES = pcp_proc_count.c pcp.h +pcp_proc_count_LDADD = libpcp.la +pcp_proc_info_SOURCES = pcp_proc_info.c pcp.h +pcp_proc_info_LDADD = libpcp.la +pcp_systemdb_info_SOURCES = pcp_systemdb_info.c pcp.h +pcp_systemdb_info_LDADD = libpcp.la +pcp_detach_node_SOURCES = pcp_detach_node.c pcp.h +pcp_detach_node_LDADD = libpcp.la +pcp_attach_node_SOURCES = pcp_attach_node.c pcp.h +pcp_attach_node_LDADD = libpcp.la +pcp_recovery_node_SOURCES = pcp_recovery_node.c pcp.h +pcp_recovery_node_LDADD = libpcp.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu pcp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu pcp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libpcp.la: $(libpcp_la_OBJECTS) $(libpcp_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libpcp_la_LDFLAGS) $(libpcp_la_OBJECTS) $(libpcp_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +pcp_attach_node$(EXEEXT): $(pcp_attach_node_OBJECTS) $(pcp_attach_node_DEPENDENCIES) + @rm -f pcp_attach_node$(EXEEXT) + $(LINK) $(pcp_attach_node_LDFLAGS) $(pcp_attach_node_OBJECTS) $(pcp_attach_node_LDADD) $(LIBS) +pcp_detach_node$(EXEEXT): $(pcp_detach_node_OBJECTS) $(pcp_detach_node_DEPENDENCIES) + @rm -f pcp_detach_node$(EXEEXT) + $(LINK) $(pcp_detach_node_LDFLAGS) $(pcp_detach_node_OBJECTS) $(pcp_detach_node_LDADD) $(LIBS) +pcp_node_count$(EXEEXT): $(pcp_node_count_OBJECTS) $(pcp_node_count_DEPENDENCIES) + @rm -f pcp_node_count$(EXEEXT) + $(LINK) $(pcp_node_count_LDFLAGS) $(pcp_node_count_OBJECTS) $(pcp_node_count_LDADD) $(LIBS) +pcp_node_info$(EXEEXT): $(pcp_node_info_OBJECTS) $(pcp_node_info_DEPENDENCIES) + @rm -f pcp_node_info$(EXEEXT) + $(LINK) $(pcp_node_info_LDFLAGS) $(pcp_node_info_OBJECTS) $(pcp_node_info_LDADD) $(LIBS) +pcp_proc_count$(EXEEXT): $(pcp_proc_count_OBJECTS) $(pcp_proc_count_DEPENDENCIES) + @rm -f pcp_proc_count$(EXEEXT) + $(LINK) $(pcp_proc_count_LDFLAGS) $(pcp_proc_count_OBJECTS) $(pcp_proc_count_LDADD) $(LIBS) +pcp_proc_info$(EXEEXT): $(pcp_proc_info_OBJECTS) $(pcp_proc_info_DEPENDENCIES) + @rm -f pcp_proc_info$(EXEEXT) + $(LINK) $(pcp_proc_info_LDFLAGS) $(pcp_proc_info_OBJECTS) $(pcp_proc_info_LDADD) $(LIBS) +pcp_recovery_node$(EXEEXT): $(pcp_recovery_node_OBJECTS) $(pcp_recovery_node_DEPENDENCIES) + @rm -f pcp_recovery_node$(EXEEXT) + $(LINK) $(pcp_recovery_node_LDFLAGS) $(pcp_recovery_node_OBJECTS) $(pcp_recovery_node_LDADD) $(LIBS) +pcp_stop_pgpool$(EXEEXT): $(pcp_stop_pgpool_OBJECTS) $(pcp_stop_pgpool_DEPENDENCIES) + @rm -f pcp_stop_pgpool$(EXEEXT) + $(LINK) $(pcp_stop_pgpool_LDFLAGS) $(pcp_stop_pgpool_OBJECTS) $(pcp_stop_pgpool_LDADD) $(LIBS) +pcp_systemdb_info$(EXEEXT): $(pcp_systemdb_info_OBJECTS) $(pcp_systemdb_info_DEPENDENCIES) + @rm -f pcp_systemdb_info$(EXEEXT) + $(LINK) $(pcp_systemdb_info_LDFLAGS) $(pcp_systemdb_info_OBJECTS) $(pcp_systemdb_info_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_attach_node.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_detach_node.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_node_count.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_node_info.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_proc_count.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_proc_info.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_recovery_node.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_stop_pgpool.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_stream.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_systemdb_info.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)" + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ + $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ + rm -f "$(DESTDIR)$(includedir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ + uninstall-info-am uninstall-libLTLIBRARIES + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libLTLIBRARIES clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-includeHEADERS install-info install-info-am \ + install-libLTLIBRARIES install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-includeHEADERS uninstall-info-am \ + uninstall-libLTLIBRARIES + + +md5.c: ../md5.c + rm -f $@ && ln -s $< . +md5.h: ../md5.h + rm -f $@ && ln -s $< . +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/pcp/md5.c b/pcp/md5.c new file mode 100644 index 0000000..0ce9efe --- /dev/null +++ b/pcp/md5.c @@ -0,0 +1,405 @@ +/* + * md5.c + * + * Implements the MD5 Message-Digest Algorithm as specified in + * RFC 1321. This implementation is a simple one, in that it + * needs every input byte to be buffered before doing any + * calculations. I do not expect this file to be used for + * general purpose MD5'ing of large amounts of data, only for + * generating hashed passwords from limited input. + * + * Sverre H. Huseby + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * This file is imported from PostgreSQL 8.1.3., and modified by + * Taiki Yamaguchi + * + * IDENTIFICATION + * $Header: /cvsroot/pgpool/pgpool-II/pcp/md5.c,v 1.1.1.1.6.1 2009/08/22 04:19:50 t-ishii Exp $ + */ + +#include +#include +#include +#include + +#include "md5.h" + +typedef unsigned char uint8; /* == 8 bits */ +typedef unsigned int uint32; /* == 32 bits */ + +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + +#define FF(a, b, c, d, x, s, ac) { \ +(a) += F((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define GG(a, b, c, d, x, s, ac) { \ +(a) += G((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define HH(a, b, c, d, x, s, ac) { \ +(a) += H((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define II(a, b, c, d, x, s, ac) { \ +(a) += I((b), (c), (d)) + (x) + (uint32)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +const uint32 T[64] = +{ + 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, + + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, + + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, + + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 +}; + + +/* + * PRIVATE FUNCTIONS + */ + + +/* + * The returned array is allocated using malloc. the caller should free it + * when it is no longer needed. + */ +static uint8 * +createPaddedCopyWithLength(uint8 *b, uint32 *l) +{ + /* + * uint8 *b - message to be digested + * uint32 *l - length of b + */ + uint8 *ret; + uint32 q; + uint32 len, + newLen448; + uint32 len_high, + len_low; /* 64-bit value split into 32-bit sections */ + + len = ((b == NULL) ? 0 : *l); + newLen448 = len + 64 - (len % 64) - 8; + if (newLen448 <= len) + newLen448 += 64; + + *l = newLen448 + 8; + if ((ret = (uint8 *) malloc(sizeof(uint8) * *l)) == NULL) + return NULL; + + if (b != NULL) + memcpy(ret, b, sizeof(uint8) * len); + + /* pad */ + ret[len] = 0x80; + for (q = len + 1; q < newLen448; q++) + ret[q] = 0x00; + + /* append length as a 64 bit bitcount */ + len_low = len; + /* split into two 32-bit values */ + /* we only look at the bottom 32-bits */ + len_high = len >> 29; + len_low <<= 3; + q = newLen448; + ret[q++] = (len_low & 0xff); + len_low >>= 8; + ret[q++] = (len_low & 0xff); + len_low >>= 8; + ret[q++] = (len_low & 0xff); + len_low >>= 8; + ret[q++] = (len_low & 0xff); + ret[q++] = (len_high & 0xff); + len_high >>= 8; + ret[q++] = (len_high & 0xff); + len_high >>= 8; + ret[q++] = (len_high & 0xff); + len_high >>= 8; + ret[q] = (len_high & 0xff); + + return ret; +} + +static void +doTheRounds(uint32 X[16], uint32 state[4]) +{ + uint32 a, + b, + c, + d; + + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + + /* round 1 */ + FF(a, b, c, d, X[ 0], S11, T[ 0]); + FF(d, a, b, c, X[ 1], S12, T[ 1]); + FF(c, d, a, b, X[ 2], S13, T[ 2]); + FF(b, c, d, a, X[ 3], S14, T[ 3]); + FF(a, b, c, d, X[ 4], S11, T[ 4]); + FF(d, a, b, c, X[ 5], S12, T[ 5]); + FF(c, d, a, b, X[ 6], S13, T[ 6]); + FF(b, c, d, a, X[ 7], S14, T[ 7]); + FF(a, b, c, d, X[ 8], S11, T[ 8]); + FF(d, a, b, c, X[ 9], S12, T[ 9]); + FF(c, d, a, b, X[10], S13, T[10]); + FF(b, c, d, a, X[11], S14, T[11]); + FF(a, b, c, d, X[12], S11, T[12]); + FF(d, a, b, c, X[13], S12, T[13]); + FF(c, d, a, b, X[14], S13, T[14]); + FF(b, c, d, a, X[15], S14, T[15]); + + GG(a, b, c, d, X[ 1], S21, T[16]); + GG(d, a, b, c, X[ 6], S22, T[17]); + GG(c, d, a, b, X[11], S23, T[18]); + GG(b, c, d, a, X[ 0], S24, T[19]); + GG(a, b, c, d, X[ 5], S21, T[20]); + GG(d, a, b, c, X[10], S22, T[21]); + GG(c, d, a, b, X[15], S23, T[22]); + GG(b, c, d, a, X[ 4], S24, T[23]); + GG(a, b, c, d, X[ 9], S21, T[24]); + GG(d, a, b, c, X[14], S22, T[25]); + GG(c, d, a, b, X[ 3], S23, T[26]); + GG(b, c, d, a, X[ 8], S24, T[27]); + GG(a, b, c, d, X[13], S21, T[28]); + GG(d, a, b, c, X[ 2], S22, T[29]); + GG(c, d, a, b, X[ 7], S23, T[30]); + GG(b, c, d, a, X[12], S24, T[31]); + + HH(a, b, c, d, X[ 5], S31, T[32]); + HH(d, a, b, c, X[ 8], S32, T[33]); + HH(c, d, a, b, X[11], S33, T[34]); + HH(b, c, d, a, X[14], S34, T[35]); + HH(a, b, c, d, X[ 1], S31, T[36]); + HH(d, a, b, c, X[ 4], S32, T[37]); + HH(c, d, a, b, X[ 7], S33, T[38]); + HH(b, c, d, a, X[10], S34, T[39]); + HH(a, b, c, d, X[13], S31, T[40]); + HH(d, a, b, c, X[ 0], S32, T[41]); + HH(c, d, a, b, X[ 3], S33, T[42]); + HH(b, c, d, a, X[ 6], S34, T[43]); + HH(a, b, c, d, X[ 9], S31, T[44]); + HH(d, a, b, c, X[12], S32, T[45]); + HH(c, d, a, b, X[15], S33, T[46]); + HH(b, c, d, a, X[ 2], S34, T[47]); + + II(a, b, c, d, X[ 0], S41, T[48]); + II(d, a, b, c, X[ 7], S42, T[49]); + II(c, d, a, b, X[14], S43, T[50]); + II(b, c, d, a, X[ 5], S44, T[51]); + II(a, b, c, d, X[12], S41, T[52]); + II(d, a, b, c, X[ 3], S42, T[53]); + II(c, d, a, b, X[10], S43, T[54]); + II(b, c, d, a, X[ 1], S44, T[55]); + II(a, b, c, d, X[ 8], S41, T[56]); + II(d, a, b, c, X[15], S42, T[57]); + II(c, d, a, b, X[ 6], S43, T[58]); + II(b, c, d, a, X[13], S44, T[59]); + II(a, b, c, d, X[ 4], S41, T[60]); + II(d, a, b, c, X[11], S42, T[61]); + II(c, d, a, b, X[ 2], S43, T[62]); + II(b, c, d, a, X[ 9], S44, T[63]); + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; +} + +static int +calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16]) +{ + /* + * uint8 *b - message to be digested + * uint32 len - length of b + * uint8 sum[16] - md5 digest calculated from b + */ + + register uint32 i, + j, + k, + newI; + uint32 l; + uint8 *input; + register uint32 *wbp; + uint32 workBuff[16], + state[4]; + + l = len; + + state[0] = 0x67452301; + state[1] = 0xEFCDAB89; + state[2] = 0x98BADCFE; + state[3] = 0x10325476; + + if ((input = createPaddedCopyWithLength(b, &l)) == NULL) + return 0; + + for (i = 0;;) + { + if ((newI = i + 16 * 4) > l) + break; + k = i + 3; + for (j = 0; j < 16; j++) + { + wbp = (workBuff + j); + *wbp = input[k--]; + *wbp <<= 8; + *wbp |= input[k--]; + *wbp <<= 8; + *wbp |= input[k--]; + *wbp <<= 8; + *wbp |= input[k]; + k += 7; + } + doTheRounds(workBuff, state); + i = newI; + } + free(input); + + j = 0; + for (i = 0; i < 4; i++) + { + k = state[i]; + sum[j++] = (k & 0xff); + k >>= 8; + sum[j++] = (k & 0xff); + k >>= 8; + sum[j++] = (k & 0xff); + k >>= 8; + sum[j++] = (k & 0xff); + } + return 1; +} + +static void +bytesToHex(uint8 b[16], char *s) +{ + static const char *hex = "0123456789abcdef"; + int q, + w; + + for (q = 0, w = 0; q < 16; q++) + { + s[w++] = hex[(b[q] >> 4) & 0x0F]; + s[w++] = hex[b[q] & 0x0F]; + } + s[w] = '\0'; +} + +/* + * PUBLIC FUNCTIONS + */ + +/* + * pool_md5_hash + * + * Calculates the MD5 sum of the bytes in a buffer. + * + * SYNOPSIS int pool_md5_hash(const void *buff, size_t len, char *hexsum) + * + * INPUT buff the buffer containing the bytes that you want + * the MD5 sum of. + * len number of bytes in the buffer. + * + * OUTPUT hexsum the MD5 sum as a '\0'-terminated string of + * hexadecimal digits. an MD5 sum is 16 bytes long. + * each byte is represented by two heaxadecimal + * characters. you thus need to provide an array + * of 33 characters, including the trailing '\0'. + * + * RETURNS false on failure (out of memory for internal buffers) or + * true on success. + * + * STANDARDS MD5 is described in RFC 1321. + * + * AUTHOR Sverre H. Huseby + * MODIFIED by Taiki Yamaguchi + * + */ +int +pool_md5_hash(const void *buff, size_t len, char *hexsum) +{ + uint8 sum[16]; + + if (!calculateDigestFromBuffer((uint8 *) buff, len, sum)) + return 0; /* failed */ + + bytesToHex(sum, hexsum); + return 1; /* success */ +} + +/* + * Computes MD5 checksum of "passwd" (a null-terminated string) followed + * by "salt" (which need not be null-terminated). + * + * Output format is a 32-hex-digit MD5 checksum. + * Hence, the output buffer "buf" must be at least 33 bytes long. + * + * Returns 1 if okay, 0 on error (out of memory). + */ +int +pool_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, + char *buf) +{ + size_t passwd_len = strlen(passwd); + char *crypt_buf = malloc(passwd_len + salt_len); + int ret; + + if (!crypt_buf) + return 0; /* failed */ + + /* + * Place salt at the end because it may be known by users trying to crack + * the MD5 output. + */ + strcpy(crypt_buf, passwd); + memcpy(crypt_buf + passwd_len, salt, salt_len); + + ret = pool_md5_hash(crypt_buf, passwd_len + salt_len, buf); + + free(crypt_buf); + + return ret; +} diff --git a/pcp/md5.h b/pcp/md5.h new file mode 100644 index 0000000..81e91fb --- /dev/null +++ b/pcp/md5.h @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + * + * md5.h + * Interface to md5.c + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $Header: /cvsroot/pgpool/pgpool-II/pcp/md5.h,v 1.1.1.1 2006/09/08 03:36:48 t-ishii Exp $ + * + *------------------------------------------------------------------------- + */ + +/* + * This file is imported from PostgreSQL 8.1.3. + * Modified by Taiki Yamaguchi + */ + +#ifndef MD5_H +#define MD5_H + +#define MD5_PASSWD_LEN 32 + +extern int pool_md5_hash(const void *buff, size_t len, char *hexsum); +extern int pool_md5_encrypt(const char *passwd, const char *salt, size_t salt_len, char *buf); + +#endif diff --git a/pcp/pcp.c b/pcp/pcp.c new file mode 100644 index 0000000..241ed4c --- /dev/null +++ b/pcp/pcp.c @@ -0,0 +1,1299 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp.c,v 1.8 2008/12/31 10:25:40 t-ishii Exp $ + * + * Handles PCP connection, and protocol communication with pgpool-II + * These are client APIs. Server program should use APIs in pcp_stream.c + * + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcp.h" +#include "pcp_stream.h" +#include "md5.h" + +struct timeval pcp_timeout; + +static PCP_CONNECTION *pc; +#ifdef DEBUG +static int debug = 1; +#else +static int debug = 0; +#endif +static int pcp_authorize(char *username, char *password); + +/* -------------------------------- + * pcp_connect - open connection to pgpool using given arguments + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_connect(char *hostname, int port, char *username, char *password) +{ + struct sockaddr_in addr; + struct sockaddr_un unix_addr; + struct hostent *hp; + int fd; + int on = 1; + int len; + + if (pc != NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname); + return 0; + } + + if (hostname == NULL || *hostname == '\0' || *hostname == '/') + { + char *path; + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + + if (fd < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not create socket\n"); + errorcode = SOCKERR; + return -1; + } + + memset(&unix_addr, 0, sizeof(unix_addr)); + unix_addr.sun_family = AF_UNIX; + + if (hostname == NULL || *hostname == '\0') + { + path = UNIX_DOMAIN_PATH; + } + else + { + path = hostname; + } + + snprintf(unix_addr.sun_path, sizeof(unix_addr.sun_path), "%s/.s.PGSQL.%d", + path, port); + + if (connect(fd, (struct sockaddr *) &unix_addr, sizeof(unix_addr)) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path); + close(fd); + errorcode = CONNERR; + return -1; + } + } + else + { + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not create socket\n"); + errorcode = SOCKERR; + return -1; + } + + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + (char *) &on, sizeof(on)) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not set socket option\n"); + close(fd); + errorcode = SOCKERR; + return -1; + } + + memset((char *) &addr, 0, sizeof(addr)); + ((struct sockaddr *) &addr)->sa_family = AF_INET; + hp = gethostbyname(hostname); + if ((hp == NULL) || (hp->h_addrtype != AF_INET)) + { + if (debug) fprintf(stderr, "DEBUG: could not retrieve hostname\n"); + close(fd); + errorcode = HOSTERR; + return -1; + } + memmove((char *) &(addr.sin_addr), + (char *) hp->h_addr, + hp->h_length); + addr.sin_port = htons(port); + + len = sizeof(struct sockaddr_in); + if (connect(fd, (struct sockaddr *) &addr, len) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname); + close(fd); + errorcode = CONNERR; + return -1; + } + } + + pc = pcp_open(fd); + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: could not allocate buffer space\n"); + close(fd); + return -1; + } + + if (pcp_authorize(username, password) < 0) + { + pcp_close(pc); + return -1; + } + + return 0; +} + +/* -------------------------------- + * pcp_authorize - authenticate with pgpool using username and password + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +static int +pcp_authorize(char *username, char *password) +{ + char tos; + char *buf = NULL; + int wsize; + int rsize; + char salt[4]; + char encrypt_buf[(MD5_PASSWD_LEN+1)*2]; + char md5[MD5_PASSWD_LEN+1]; + + /* request salt */ + pcp_write(pc, "M", 1); + wsize = htonl(sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + + if (pcp_read(pc, &tos, 1)) + return -1; + if (pcp_read(pc, &rsize, sizeof(int))) + return -1; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return -1; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + return -1; + memcpy(salt, buf, 4); + free(buf); + + /* encrypt password */ + pool_md5_hash(password, strlen(password), md5); + md5[MD5_PASSWD_LEN] = '\0'; + + pool_md5_encrypt(md5, username, strlen(username), + encrypt_buf + MD5_PASSWD_LEN + 1); + encrypt_buf[(MD5_PASSWD_LEN+1)*2-1] = '\0'; + + pool_md5_encrypt(encrypt_buf+MD5_PASSWD_LEN+1, salt, 4, + encrypt_buf); + encrypt_buf[MD5_PASSWD_LEN] = '\0'; + + pcp_write(pc, "R", 1); + wsize = htonl((strlen(username)+1 + strlen(encrypt_buf)+1) + sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, username, strlen(username)+1); + pcp_write(pc, encrypt_buf, strlen(encrypt_buf)+1); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return -1; + if (pcp_read(pc, &rsize, sizeof(int))) + return -1; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return -1; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + return -1; + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + errorcode = BACKENDERR; + } + else if (tos == 'r') + { + if (strcmp(buf, "AuthenticationOK") == 0) + { + free(buf); + return 0; + } + + if (debug) fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf); + errorcode = AUTHERR; + } + free(buf); + + return -1; +} + +/* -------------------------------- + * pcp_disconnect - close connection to pgpool + * -------------------------------- + */ +void +pcp_disconnect(void) +{ + int wsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + return; + } + + pcp_write(pc, "X", 1); + wsize = htonl(sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + if (pcp_flush(pc) < 0) + { + /* backend had closed connection already */ + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int)); + + pcp_close(pc); + pc = NULL; +} + +/* -------------------------------- + * pcp_terminate_pgpool - send terminate packet + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_terminate_pgpool(char mode) +{ + int wsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return -1; + } + + pcp_write(pc, "T", 1); + wsize = htonl(sizeof(int) + sizeof(char)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, &mode, sizeof(char)); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize)); + + return 0; +} + +/* -------------------------------- + * pcp_node_count - get number of nodes currently connected to pgpool + * + * return array of node IDs on success, -1 otherwise + * -------------------------------- + */ +int +pcp_node_count(void) +{ + char tos; + char *buf = NULL; + int wsize; + int rsize; + char *index = NULL; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return -1; + } + + pcp_write(pc, "L", 1); + wsize = htonl(sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return -1; + if (pcp_read(pc, &rsize, sizeof(int))) + return -1; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return -1; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return -1; + } + + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + errorcode = BACKENDERR; + } + else if (tos == 'l') + { + if (strcmp(buf, "CommandComplete") == 0) + { + index = (char *) memchr(buf, '\0', rsize) + 1; + if (index != NULL) + { + int ret = atoi(index); + free(buf); + return ret; + } + } + } + + free(buf); + + return -1; +} + +/* -------------------------------- + * pcp_node_info - get information of node pointed by given argument + * + * return structure of node information on success, -1 otherwise + * -------------------------------- + */ +BackendInfo * +pcp_node_info(int nid) +{ + int wsize; + char node_id[16]; + char tos; + char *buf = NULL; + int rsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return NULL; + } + + snprintf(node_id, sizeof(node_id), "%d", nid); + + pcp_write(pc, "I", 1); + wsize = htonl(strlen(node_id)+1 + sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, node_id, strlen(node_id)+1); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return NULL; + if (pcp_read(pc, &rsize, sizeof(int))) + return NULL; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return NULL; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return NULL; + } + + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + errorcode = BACKENDERR; + free(buf); + return NULL; + } + else if (tos == 'i') + { + if (strcmp(buf, "CommandComplete") == 0) + { + char *index = NULL; + BackendInfo* backend_info = NULL; + + backend_info = (BackendInfo *)malloc(sizeof(BackendInfo)); + if (backend_info == NULL) + { + errorcode = NOMEMERR; + free(buf); + return NULL; + } + // FIXME +// rsize -= strlen("CommandComplete") + 1; + + index = (char *) memchr(buf, '\0', rsize) + 1; + if (index != NULL) + strcpy(backend_info->backend_hostname, index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + backend_info->backend_port = atoi(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + backend_info->backend_status = atoi(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + backend_info->backend_weight = atof(index); + + free(buf); + return backend_info; + } + } + + free(buf); + return NULL; +} + +/* -------------------------------- + * pcp_node_count - get number of nodes currently connected to pgpool + * + * return array of pids on success, NULL otherwise + * -------------------------------- + */ +int * +pcp_process_count(int *pnum) +{ + char tos; + char *buf = NULL; + int wsize; + int rsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return NULL; + } + + pcp_write(pc, "N", 1); + wsize = htonl(sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return NULL; + if (pcp_read(pc, &rsize, sizeof(int))) + return NULL; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return NULL; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + free(buf); + errorcode = BACKENDERR; + return NULL; + } + else if (tos == 'n') + { + if (strcmp(buf, "CommandComplete") == 0) + { + int process_count; + int *process_list = NULL; + char *index = NULL; + int i; + + index = (char *) memchr(buf, '\0', rsize) + 1; + process_count = atoi(index); + + process_list = (int *)malloc(sizeof(int) * process_count); + if (process_list == NULL) + { + free(buf); + errorcode = NOMEMERR; + return NULL; + } + + for (i = 0; i < process_count; i++) + { + index = (char *) memchr(index, '\0', rsize) + 1; + process_list[i] = atoi(index); + } + + *pnum = process_count; + free(buf); + return process_list; + } + } + + free(buf); + return NULL; +} + +/* -------------------------------- + * pcp_process_info - get information of node pointed by given argument + * + * return structure of process information on success, -1 otherwise + * -------------------------------- + */ +ProcessInfo * +pcp_process_info(int pid, int *array_size) +{ + int wsize; + char process_id[16]; + char tos; + char *buf = NULL; + int rsize; + + ProcessInfo *process_info = NULL; + int ci_size = 0; + int offset = 0; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return NULL; + } + + snprintf(process_id, sizeof(process_id), "%d", pid); + + pcp_write(pc, "P", 1); + wsize = htonl(strlen(process_id)+1 + sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, process_id, strlen(process_id)+1); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize)); + + while (1) + { + if (pcp_read(pc, &tos, 1)) + return NULL; + if (pcp_read(pc, &rsize, sizeof(int))) + return NULL; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return NULL; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + free(buf); + errorcode = BACKENDERR; + return NULL; + } + else if (tos == 'p') + { + char *index; + + if (strcmp(buf, "ArraySize") == 0) + { + index = (char *) memchr(buf, '\0', rsize) + 1; + if (index != NULL) + ci_size = atoi(index); + + *array_size = ci_size; + + process_info = (ProcessInfo *)malloc(sizeof(ProcessInfo)); + if (process_info == NULL) + { + free(buf); + errorcode = NOMEMERR; + return NULL; + } + process_info->connection_info = NULL; + process_info->connection_info = (ConnectionInfo *)malloc(sizeof(ConnectionInfo)*ci_size); + if (process_info->connection_info == NULL) + { + free(buf); + errorcode = NOMEMERR; + return NULL; + } + + continue; + } + else if (strcmp(buf, "ProcessInfo") == 0) + { + index = (char *) memchr(buf, '\0', rsize) + 1; + if (index != NULL) + strcpy(process_info->connection_info[offset].database, index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + strcpy(process_info->connection_info[offset].user, index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + process_info->start_time = atol(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + process_info->connection_info[offset].create_time = atol(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + process_info->connection_info[offset].major = atoi(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + process_info->connection_info[offset].minor = atoi(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + process_info->connection_info[offset].counter = atoi(index); + + offset++; + } + else if (strcmp(buf, "CommandComplete") == 0) + { + free(buf); + return process_info; + } + else + { + // never reached + } + } + } + + free(buf); + return NULL; +} + +/* -------------------------------- + * pcp_systemdb_info - get information of system DB + * + * return structure of system DB information on success, -1 otherwise + * -------------------------------- + */ +SystemDBInfo * +pcp_systemdb_info(void) +{ + char tos; + char *buf = NULL; + int wsize; + int rsize; + SystemDBInfo *systemdb_info = NULL; + int offset = 0; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return NULL; + } + + pcp_write(pc, "S", 1); + wsize = htonl(sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize)); + + while (1) { + if (pcp_read(pc, &tos, 1)) + return NULL; + if (pcp_read(pc, &rsize, sizeof(int))) + return NULL; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return NULL; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return NULL; + } + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + free(buf); + errorcode = BACKENDERR; + return NULL; + } + else if (tos == 's') + { + char *index; + + if (strcmp(buf, "SystemDBInfo") == 0) + { + systemdb_info = (SystemDBInfo *)malloc(sizeof(SystemDBInfo)); + if (systemdb_info == NULL) + { + free(buf); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(buf, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->hostname = strdup(index); + if (systemdb_info->hostname == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->port = atoi(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->user = strdup(index); + if (systemdb_info->user == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->password = strdup(index); + if (systemdb_info->password == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->schema_name = strdup(index); + if (systemdb_info->schema_name == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->database_name = strdup(index); + if (systemdb_info->database_name == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->dist_def_num = atoi(index); + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + systemdb_info->system_db_status = atoi(index); + + if (systemdb_info->dist_def_num > 0) + { + systemdb_info->dist_def_slot = NULL; + systemdb_info->dist_def_slot = (DistDefInfo *)malloc(sizeof(DistDefInfo) * systemdb_info->dist_def_num); + if (systemdb_info->dist_def_slot == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + } + } + else if (strcmp(buf, "DistDefInfo") == 0) + { + DistDefInfo *dist_def_info = NULL; + int i; + + dist_def_info = (DistDefInfo *)malloc(sizeof(DistDefInfo)); + if (dist_def_info == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(buf, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->dbname = strdup(index); + if (dist_def_info->dbname == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->schema_name = strdup(index); + if (dist_def_info->schema_name == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->table_name = strdup(index); + if (dist_def_info->table_name == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->dist_key_col_name = strdup(index); + if (dist_def_info->dist_key_col_name == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->col_num = atoi(index); + + dist_def_info->col_list = NULL; + dist_def_info->col_list = (char **)malloc(sizeof(char *) * dist_def_info->col_num); + if (dist_def_info->col_list == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + for (i = 0; i < dist_def_info->col_num; i++) + { + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->col_list[i] = strdup(index); + if (dist_def_info->col_list[i] == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + } + + dist_def_info->type_list = NULL; + dist_def_info->type_list = (char **)malloc(sizeof(char *) * dist_def_info->col_num); + if (dist_def_info->type_list == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + for (i = 0; i < dist_def_info->col_num; i++) + { + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->type_list[i] = strdup(index); + if (dist_def_info->type_list[i] == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + } + + index = (char *) memchr(index, '\0', rsize) + 1; + if (index != NULL) + dist_def_info->dist_def_func = strdup(index); + if (dist_def_info->dist_def_func == NULL) + { + free(buf); + free_systemdb_info(systemdb_info); + errorcode = NOMEMERR; + return NULL; + } + + memcpy(&systemdb_info->dist_def_slot[offset++], dist_def_info, sizeof(DistDefInfo)); + } + else if (strcmp(buf, "CommandComplete") == 0) + { + free(buf); + return systemdb_info; + } + else + { + // never reached + } + } + } + + free(buf); + return NULL; +} + +void +free_systemdb_info(SystemDBInfo * si) +{ + int i, j; + + free(si->hostname); + free(si->user); + free(si->password); + free(si->schema_name); + free(si->database_name); + + if (si->dist_def_slot != NULL) + { + for (i = 0; i < si->dist_def_num; i++) + { + DistDefInfo *di = &si->dist_def_slot[i]; + free(di->dbname); + free(di->schema_name); + free(di->table_name); + free(di->dist_def_func); + for (j = 0; j < di->col_num; j++) + { + free(di->col_list[j]); + free(di->type_list[j]); + } + } + } + + free(si); +} + +/* -------------------------------- + * pcp_detach_node - dettach a node given by the argument from pgpool's control + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_detach_node(int nid) +{ + int wsize; + char node_id[16]; + char tos; + char *buf = NULL; + int rsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return -1; + } + + snprintf(node_id, sizeof(node_id), "%d", nid); + + pcp_write(pc, "D", 1); + wsize = htonl(strlen(node_id)+1 + sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, node_id, strlen(node_id)+1); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return -1; + if (pcp_read(pc, &rsize, sizeof(int))) + return -1; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return -1; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + errorcode = BACKENDERR; + } + else if (tos == 'd') + { + /* strcmp() for success message, or fail */ + if(strcmp(buf, "CommandComplete") == 0) + { + free(buf); + return 0; + } + } + + free(buf); + return -1; +} + + +/* -------------------------------- + * pcp_attach_node - attach a node given by the argument from pgpool's control + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_attach_node(int nid) +{ + int wsize; + char node_id[16]; + char tos; + char *buf = NULL; + int rsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return -1; + } + + snprintf(node_id, sizeof(node_id), "%d", nid); + + pcp_write(pc, "C", 1); + wsize = htonl(strlen(node_id)+1 + sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, node_id, strlen(node_id)+1); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return -1; + if (pcp_read(pc, &rsize, sizeof(int))) + return -1; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return -1; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + errorcode = BACKENDERR; + } + else if (tos == 'c') + { + /* strcmp() for success message, or fail */ + if(strcmp(buf, "CommandComplete") == 0) + { + free(buf); + return 0; + } + } + + free(buf); + return -1; +} + +void +pcp_set_timeout(long sec) +{ + /* disable timeout (wait forever!) (2008/02/08 yamaguti) */ + sec = 0; + pcp_timeout.tv_sec = sec; +} + + +int +pcp_recovery_node(int nid) +{ + int wsize; + char node_id[16]; + char tos; + char *buf = NULL; + int rsize; + + if (pc == NULL) + { + if (debug) fprintf(stderr, "DEBUG: connection does not exist\n"); + errorcode = NOCONNERR; + return -1; + } + + snprintf(node_id, sizeof(node_id), "%d", nid); + + pcp_write(pc, "O", 1); + wsize = htonl(strlen(node_id)+1 + sizeof(int)); + pcp_write(pc, &wsize, sizeof(int)); + pcp_write(pc, node_id, strlen(node_id)+1); + if (pcp_flush(pc) < 0) + { + if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n"); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize)); + + if (pcp_read(pc, &tos, 1)) + return -1; + if (pcp_read(pc, &rsize, sizeof(int))) + return -1; + rsize = ntohl(rsize); + buf = (char *)malloc(rsize); + if (buf == NULL) + { + errorcode = NOMEMERR; + return -1; + } + if (pcp_read(pc, buf, rsize - sizeof(int))) + { + free(buf); + return -1; + } + if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf); + + if (tos == 'e') + { + if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf); + errorcode = BACKENDERR; + } + else if (tos == 'c') + { + /* strcmp() for success message, or fail */ + if(strcmp(buf, "CommandComplete") == 0) + { + free(buf); + return 0; + } + } + + free(buf); + return -1; +} + +void +pcp_enable_debug(void) +{ + debug = 1; +} + +void +pcp_disable_debug(void) +{ + debug = 0; +} diff --git a/pcp/pcp.h b/pcp/pcp.h new file mode 100644 index 0000000..ffa5109 --- /dev/null +++ b/pcp/pcp.h @@ -0,0 +1,75 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp.h,v 1.4 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * + * pcp.h - master header file. + */ + +#ifndef PCP_H +#define PCP_H + +#include "pool_type.h" + +#define MAX_USER_PASSWD_LEN 128 + +typedef enum { + UNKNOWNERR = 1, /* shouldn't happen */ + EOFERR, /* EOF read by read() */ + NOMEMERR, /* could not allocate memory */ + READERR, /* read() error */ + WRITEERR, /* flush() error */ + TIMEOUTERR, /* select() timeout */ + INVALERR, /* invalid command-line argument(s) number, length, range, etc. */ + CONNERR, /* thrown by connect() */ + NOCONNERR, /* not connected to server */ + SOCKERR, /* thrown by socket() or setsockopt() */ + HOSTERR, /* thrown by gethostbyname() */ + BACKENDERR, /* server dependent error */ + AUTHERR /* authorization faiure */ +} ErrorCode; + +/* -------------------------------- + * pcp.c + * -------------------------------- + */ +extern struct timeval pcp_timeout; +extern int pcp_connect(char *hostname, int port, char *username, char *password); +extern void pcp_disconnect(void); +extern int pcp_terminate_pgpool(char mode); +extern int pcp_node_count(void); +extern BackendInfo *pcp_node_info(int nid); +extern int *pcp_process_count(int *process_count); +extern ProcessInfo *pcp_process_info(int pid, int *array_size); +extern SystemDBInfo *pcp_systemdb_info(void); +extern void free_systemdb_info(SystemDBInfo * si); +extern int pcp_detach_node(int nid); +extern int pcp_attach_node(int nid); +extern void pcp_set_timeout(long sec); +extern int pcp_recovery_node(int nid); +extern void pcp_enable_debug(void); +extern void pcp_disable_debug(void); + +/* ------------------------------ + * pcp_error.c + * ------------------------------ + */ +extern ErrorCode errorcode; +extern void pcp_errorstr(ErrorCode e); + +#endif /* PCP_H */ diff --git a/pcp/pcp_attach_node.c b/pcp/pcp_attach_node.c new file mode 100644 index 0000000..07c2669 --- /dev/null +++ b/pcp/pcp_attach_node.c @@ -0,0 +1,160 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_attach_node.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "attach node" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int nodeID; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 6) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + nodeID = atoi(argv[5]); + if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (pcp_attach_node(nodeID)) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_attach_node - attach a node from pgpool-II\n\n"); + fprintf(stderr, "Usage: pcp_attach_node [-d] timeout hostname port# username password nodeID\n"); + fprintf(stderr, "Usage: pcp_attach_node -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " nodeID - ID of a node to be attached\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_detach_node.c b/pcp/pcp_detach_node.c new file mode 100644 index 0000000..bf1cb75 --- /dev/null +++ b/pcp/pcp_detach_node.c @@ -0,0 +1,160 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_detach_node.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "detach node" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int nodeID; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 6) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + nodeID = atoi(argv[5]); + if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (pcp_detach_node(nodeID)) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_detach_node - detach a node from pgpool-II\n\n"); + fprintf(stderr, "Usage: pcp_detach_node [-d] timeout hostname port# username password nodeID\n"); + fprintf(stderr, "Usage: pcp_detach_node -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " nodeID - ID of a node to be detached\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_error.c b/pcp/pcp_error.c new file mode 100644 index 0000000..3a9eefb --- /dev/null +++ b/pcp/pcp_error.c @@ -0,0 +1,87 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_error.c,v 1.2 2008/01/29 01:56:38 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Handles errors occured in PCP modules. + */ + +#include + +#include "pcp.h" + +ErrorCode errorcode; + +void +pcp_errorstr(ErrorCode e) +{ + switch (e) + { + case EOFERR: + fprintf(stdout, "EOFError\n"); + break; + + case NOMEMERR: + fprintf(stdout, "NoMemoryError\n"); + break; + + case READERR: + fprintf(stdout, "ReadError\n"); + break; + + case WRITEERR: + fprintf(stdout, "WriteError\n"); + break; + + case TIMEOUTERR: + fprintf(stdout, "TimeoutError\n"); + break; + + case INVALERR: + fprintf(stdout, "InvalidArgumentError\n"); + break; + + case CONNERR: + fprintf(stdout, "ConnectionError\n"); + break; + + case NOCONNERR: + fprintf(stdout, "NoConnectionError\n"); + break; + + case SOCKERR: + fprintf(stdout, "SocketError\n"); + break; + + case HOSTERR: + fprintf(stdout, "HostError\n"); + break; + + case BACKENDERR: + fprintf(stdout, "BackendError\n"); + break; + + case AUTHERR: + fprintf(stdout, "AuthorizationError\n"); + break; + + case UNKNOWNERR: + default: + fprintf(stdout, "UnknownError\n"); + break; + } +} diff --git a/pcp/pcp_node_count.c b/pcp/pcp_node_count.c new file mode 100644 index 0000000..eb500c3 --- /dev/null +++ b/pcp/pcp_node_count.c @@ -0,0 +1,148 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_count.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "node count" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int node_count; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 5) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if ((node_count = pcp_node_count()) < 0) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } else { + printf("%d\n", node_count); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_node_count - display the total number of nodes under pgpool-II's control\n\n"); + fprintf(stderr, "Usage: pcp_node_count [-d] timeout hostname port# username password\n"); + fprintf(stderr, "Usage: pcp_node_count -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_node_info.c b/pcp/pcp_node_info.c new file mode 100644 index 0000000..9d73dd9 --- /dev/null +++ b/pcp/pcp_node_info.c @@ -0,0 +1,169 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_info.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "node info" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int nodeID; + BackendInfo *backend_info; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 6) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + nodeID = atoi(argv[5]); + if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if ((backend_info = pcp_node_info(nodeID)) == NULL) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } else { + printf("%s %d %d %f\n", + backend_info->backend_hostname, + backend_info->backend_port, + backend_info->backend_status, + backend_info->backend_weight); + + free(backend_info); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_node_info - display a pgpool-II node's information\n\n"); + fprintf(stderr, "Usage: pcp_node_info [-d] timeout hostname port# username password nodeID\n"); + fprintf(stderr, "Usage: pcp_node_info -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " nodeID - ID of a node to get information for\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_proc_count.c b/pcp/pcp_proc_count.c new file mode 100644 index 0000000..c1c2168 --- /dev/null +++ b/pcp/pcp_proc_count.c @@ -0,0 +1,154 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_count.c,v 1.4 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "process count" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int process_count; + int *process_list = NULL; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 5) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if ((process_list = pcp_process_count(&process_count)) == NULL) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } else { + int i; + + for (i = 0; i < process_count; i++) + printf("%d ", process_list[i]); + printf("\n"); + + free(process_list); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_proc_count - display the list of pgpool-II child process PIDs\n\n"); + fprintf(stderr, "Usage: pcp_proc_count timeout hostname port# username password\n"); + fprintf(stderr, "Usage: pcp_node_info -h\n\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_proc_info.c b/pcp/pcp_proc_info.c new file mode 100644 index 0000000..e18ce45 --- /dev/null +++ b/pcp/pcp_proc_info.c @@ -0,0 +1,179 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_info.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "process info" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int processID; + ProcessInfo *process_info; + int array_size; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 6) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + processID = atoi(argv[5]); + if (processID < 0) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if ((process_info = pcp_process_info(processID, &array_size)) == NULL) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } else { + int i; + for (i = 0; i < array_size; i++) + { + if (process_info->connection_info[i].database[0] == '\0') + continue; + + printf("%s %s %ld %ld %d %d %d\n", + process_info->connection_info[i].database, + process_info->connection_info[i].user, + process_info->start_time, + process_info->connection_info[i].create_time, + process_info->connection_info[i].major, + process_info->connection_info[i].minor, + process_info->connection_info[i].counter); + } + free(process_info); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_proc_info - display a pgpool-II child process' information\n\n"); + fprintf(stderr, "Usage: pcp_proc_info [-d] timeout hostname port# username password PID\n"); + fprintf(stderr, "Usage: pcp_proc_info -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " PID - PID of a child process to get information for\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_recovery_node.c b/pcp/pcp_recovery_node.c new file mode 100644 index 0000000..50641aa --- /dev/null +++ b/pcp/pcp_recovery_node.c @@ -0,0 +1,160 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_recovery_node.c,v 1.4 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "attach node" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + int nodeID; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 6) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + nodeID = atoi(argv[5]); + if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (pcp_recovery_node(nodeID)) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_recovery_node - recovery a node\n\n"); + fprintf(stderr, "Usage: pcp_recovery_node [-d] timeout hostname port# username password nodeID\n"); + fprintf(stderr, "Usage: pcp_recovery_node -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " nodeID - ID of a node to recover\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_stop_pgpool.c b/pcp/pcp_stop_pgpool.c new file mode 100644 index 0000000..a77434d --- /dev/null +++ b/pcp/pcp_stop_pgpool.c @@ -0,0 +1,169 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_stop_pgpool.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "stop pgpool" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + char mode; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 6) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + if (strlen(argv[5]) != 1) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + mode = argv[5][0]; + if (mode != 's' && mode != 'f' && mode != 'i') + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + pcp_set_timeout(timeout); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (pcp_terminate_pgpool(mode)) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } else { + // display something on success? + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_stop_pgpool - terminate pgpool-II\n\n"); + fprintf(stderr, "Usage: pcp_stop_pgpool [-d] timeout hostname port# username password mode\n"); + fprintf(stderr, "Usage: pcp_stop_pgpool -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " mode - shutdown mode\n"); + fprintf(stderr, " s - smart shutdown f - fast shutdown i - immediate shutdown\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp/pcp_stream.c b/pcp/pcp_stream.c new file mode 100644 index 0000000..e6457d4 --- /dev/null +++ b/pcp/pcp_stream.c @@ -0,0 +1,385 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_stream.c,v 1.4 2008/01/29 01:56:38 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * PCP buffer management module. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcp.h" +#include "pcp_stream.h" + +static int consume_pending_data(PCP_CONNECTION *pc, void *data, int len); +static int save_pending_data(PCP_CONNECTION *pc, void *data, int len); +static int pcp_check_fd(PCP_CONNECTION *pc, int notimeout); + +/* -------------------------------- + * pcp_open - allocate read & write buffers for PCP_CONNECION + * + * return newly allocated PCP_CONNECTION on success, NULL if malloc() fails + * -------------------------------- + */ +PCP_CONNECTION * +pcp_open(int fd) +{ + PCP_CONNECTION *pc; + + pc = (PCP_CONNECTION *)malloc(sizeof(PCP_CONNECTION)); + if (pc == NULL) + { + errorcode = NOMEMERR; + return NULL; + } + memset(pc, 0, sizeof(*pc)); + + /* initialize write buffer */ + pc->wbuf = malloc(WRITEBUFSZ); + if (pc->wbuf == NULL) + return NULL; + pc->wbufsz = WRITEBUFSZ; + pc->wbufpo = 0; + + /* initialize pending data buffer */ + pc->hp = malloc(READBUFSZ); + if (pc->hp == NULL) + { + errorcode = NOMEMERR; + return NULL; + } + pc->bufsz = READBUFSZ; + pc->po = 0; + pc->len = 0; + + pc->fd = fd; + + return pc; +} + +/* -------------------------------- + * pcp_close - deallocate read & write buffers for PCP_CONNECION + * -------------------------------- + */ +void +pcp_close(PCP_CONNECTION *pc) +{ + close(pc->fd); + free(pc->wbuf); + free(pc->hp); + free(pc); +} + +/* -------------------------------- + * pcp_read - read 'len' bytes from 'pc' + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_read(PCP_CONNECTION *pc, void *buf, int len) +{ + static char readbuf[READBUFSZ]; + + int consume_size; + int readlen; + int notimeout = 0; + + consume_size = consume_pending_data(pc, buf, len); + len -= consume_size; + buf += consume_size; + + while (len > 0) + { + if (pcp_check_fd(pc, notimeout)) + { + errorcode = TIMEOUTERR; + return -1; + } + + readlen = read(pc->fd, readbuf, READBUFSZ); + if (readlen == -1) + { + if (errno == EAGAIN || errno == EINTR) + continue; + + errorcode = READERR; + return -1; + } + else if (readlen == 0) + { + errorcode = EOFERR; + return -1; + } + + if (len < readlen) + { + /* overrun. we need to save remaining data to pending buffer */ + if (save_pending_data(pc, readbuf+len, readlen-len)) + { + errorcode = NOMEMERR; + return -1; + } + memmove(buf, readbuf, len); + break; + } + + memmove(buf, readbuf, readlen); + buf += readlen; + len -= readlen; + } + + return 0; +} + +/* -------------------------------- + * pcp_write - write 'len' bytes to 'pc' buffer + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_write(PCP_CONNECTION *pc, void *buf, int len) +{ + int reqlen; + + if (len < 0) + { + errorcode = INVALERR; + return -1; + } + + /* check buffer size */ + reqlen = pc->wbufpo + len; + + if (reqlen > pc->wbufsz) + { + char *p; + + reqlen = (reqlen/WRITEBUFSZ+1)*WRITEBUFSZ; + p = realloc(pc->wbuf, reqlen); + if (p == NULL) + { + errorcode = NOMEMERR; + return -1; + } + + pc->wbuf = p; + pc->wbufsz = reqlen; + } + + memcpy(pc->wbuf+pc->wbufpo, buf, len); + pc->wbufpo += len; + + return 0; +} + +/* -------------------------------- + * pcp_flush - send pending data in buffer to 'pc' + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pcp_flush(PCP_CONNECTION *pc) +{ + int sts; + int wlen; + int offset; + wlen = pc->wbufpo; + + if (wlen == 0) + { + return 0; + } + + offset = 0; + + for (;;) + { + errno = 0; + + sts = write(pc->fd, pc->wbuf + offset, wlen); + + if (sts > 0) + { + wlen -= sts; + + if (wlen == 0) + { + /* write completed */ + break; + } + + else if (wlen < 0) + { + errorcode = WRITEERR; + return -1; + } + + else + { + /* need to write remaining data */ + offset += sts; + continue; + } + } + else if (errno == EAGAIN || errno == EINTR) + { + continue; + } + else + { + errorcode = WRITEERR; + return -1; + } + } + + pc->wbufpo = 0; + + return 0; +} + +/* -------------------------------- + * consume_pending_data - read pending data from 'pc' buffer + * + * return the size of data read in + * -------------------------------- + */ +static int +consume_pending_data(PCP_CONNECTION *pc, void *data, int len) +{ + int consume_size; + + if (pc->len <= 0) + return 0; + + consume_size = Min(len, pc->len); + memmove(data, pc->hp + pc->po, consume_size); + pc->len -= consume_size; + + if (pc->len <= 0) + pc->po = 0; + else + pc->po += consume_size; + + return consume_size; +} + +/* -------------------------------- + * save_pending_data - save excessively read data into 'pc' buffer + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +static int +save_pending_data(PCP_CONNECTION *pc, void *data, int len) +{ + int reqlen; + size_t realloc_size; + char *p; + + /* to be safe */ + if (pc->len == 0) + pc->po = 0; + + reqlen = pc->po + pc->len + len; + + /* pending buffer is enough? */ + if (reqlen > pc->bufsz) + { + /* too small, enlarge it */ + realloc_size = (reqlen/READBUFSZ+1)*READBUFSZ; + p = realloc(pc->hp, realloc_size); + if (p == NULL) + { + errorcode = NOMEMERR; + return -1; + } + pc->bufsz = realloc_size; + pc->hp = p; + } + + memmove(pc->hp + pc->po + pc->len, data, len); + pc->len += len; + + return 0; +} + +/* -------------------------------- + * pcp_check_fd - watch for fd which is ready to be read + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +static int +pcp_check_fd(PCP_CONNECTION *pc, int notimeout) +{ + fd_set readmask; + fd_set exceptmask; + int fd; + int fds; + struct timeval timeout; + struct timeval *tp; + + fd = pc->fd; + + for (;;) + { + FD_ZERO(&readmask); + FD_ZERO(&exceptmask); + FD_SET(fd, &readmask); + FD_SET(fd, &exceptmask); + + if (notimeout || (pcp_timeout.tv_sec + pcp_timeout.tv_usec == 0)) + tp = NULL; + else + { + /***** haven't got timeout option yet. hard-code it *****/ + timeout.tv_sec = pcp_timeout.tv_sec; + timeout.tv_usec = pcp_timeout.tv_usec; + tp = &timeout; + } + + fds = select(fd+1, &readmask, NULL, &exceptmask, tp); + + if (fds == -1) + { + if (errno == EAGAIN || errno == EINTR) + continue; + + break; + } + + if (FD_ISSET(fd, &exceptmask)) + break; + + if (fds == 0) + break; + + return 0; + } + + return -1; +} diff --git a/pcp/pcp_stream.h b/pcp/pcp_stream.h new file mode 100644 index 0000000..a8c5d36 --- /dev/null +++ b/pcp/pcp_stream.h @@ -0,0 +1,52 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_stream.h,v 1.2 2008/01/29 01:56:38 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pcp_stream.h - master header file. + */ + +#ifndef PCP_STREAM_H +#define PCP_STREAM_H + +#include "pool.h" + +#define READBUFSZ 1024 +#define WRITEBUFSZ 8192 + +typedef struct { + int fd; /* fd for connection */ + + char *wbuf; /* write buffer for the connection */ + int wbufsz; /* write buffer size */ + int wbufpo; /* buffer offset */ + + char *hp; /* pending data buffer head address */ + int po; /* pending data offset */ + int bufsz; /* pending data buffer size */ + int len; /* pending data length */ +} PCP_CONNECTION; + +extern PCP_CONNECTION *pcp_open(int fd); +extern void pcp_close(PCP_CONNECTION *pc); +extern int pcp_read(PCP_CONNECTION *pc, void *buf, int len); +extern int pcp_write(PCP_CONNECTION *pc, void *buf, int len); +extern int pcp_flush(PCP_CONNECTION *pc); + +#define UNIX_DOMAIN_PATH "/tmp" + +#endif /* PCP_STREAM_H */ diff --git a/pcp/pcp_systemdb_info.c b/pcp/pcp_systemdb_info.c new file mode 100644 index 0000000..4fd5bbd --- /dev/null +++ b/pcp/pcp_systemdb_info.c @@ -0,0 +1,182 @@ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp/pcp_systemdb_info.c,v 1.3 2008/12/31 10:25:40 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * Client program to send "systemDB info" command. + */ + +#include +#include +#include +#include + +#include "pcp.h" + +static void usage(void); +static void myexit(ErrorCode e); + +int +main(int argc, char **argv) +{ + long timeout; + char host[MAX_DB_HOST_NAMELEN]; + int port; + char user[MAX_USER_PASSWD_LEN]; + char pass[MAX_USER_PASSWD_LEN]; + SystemDBInfo *systemdb_info; + int i, j; + int ch; + + while ((ch = getopt(argc, argv, "hd")) != -1) { + switch (ch) { + case 'd': + pcp_enable_debug(); + break; + + case 'h': + case '?': + default: + usage(); + exit(0); + } + } + argc -= optind; + argv += optind; + + if (argc != 5) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + timeout = atol(argv[0]); + if (timeout < 0) { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(host, argv[1]); + + port = atoi(argv[2]); + if (port <= 1024 || port > 65535) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(user, argv[3]); + + if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) + { + errorcode = INVALERR; + pcp_errorstr(errorcode); + myexit(errorcode); + } + strcpy(pass, argv[4]); + + if (pcp_connect(host, port, user, pass)) + { + pcp_errorstr(errorcode); + myexit(errorcode); + } + + if ((systemdb_info = pcp_systemdb_info()) == NULL) + { + pcp_errorstr(errorcode); + pcp_disconnect(); + myexit(errorcode); + } else { + printf("%s %d %s %s %s %s %d %d\n", + systemdb_info->hostname, + systemdb_info->port, + systemdb_info->user, + systemdb_info->password[0] == '\0' ? "''" : systemdb_info->password, + systemdb_info->schema_name, + systemdb_info->database_name, + systemdb_info->dist_def_num, + systemdb_info->system_db_status); + + for (i = 0; i < systemdb_info->dist_def_num; i++) + { + DistDefInfo *ddi = &systemdb_info->dist_def_slot[i]; + + printf("%s %s %s %s %d ", + ddi->dbname, + ddi->schema_name, + ddi->table_name, + ddi->dist_key_col_name, + ddi->col_num); + + for (j = 0; j < ddi->col_num; j++) + printf("%s ", ddi->col_list[j]); + + for (j = 0; j < ddi->col_num; j++) + printf("%s ", ddi->type_list[j]); + + printf("%s\n", ddi->dist_def_func); + } + + free_systemdb_info(systemdb_info); + } + + pcp_disconnect(); + + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, "pcp_systemdb_info - display the pgpool-II systemDB information\n\n"); + fprintf(stderr, "Usage: pcp_systemdb_info [-d] timeout hostname port# username password\n"); + fprintf(stderr, "Usage: pcp_systemdb_info -h\n\n"); + fprintf(stderr, " -d - enable debug message (optional)\n"); + fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n"); + fprintf(stderr, " hostname - pgpool-II hostname\n"); + fprintf(stderr, " port# - pgpool-II port number\n"); + fprintf(stderr, " username - username for PCP authentication\n"); + fprintf(stderr, " password - password for PCP authentication\n"); + fprintf(stderr, " -h - print this help\n"); +} + +static void +myexit(ErrorCode e) +{ + if (e == INVALERR) + { + usage(); + exit(e); + } + + exit(e); +} diff --git a/pcp_child.c b/pcp_child.c new file mode 100644 index 0000000..97d5265 --- /dev/null +++ b/pcp_child.c @@ -0,0 +1,1074 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pcp_child.c,v 1.11.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pcp_child.c: PCP child process main + * + */ +#include "config.h" + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_NETINET_TCP_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_FCNTL_H +#include +#endif + +#include "pool.h" +#include "pcp/pcp_stream.h" +#include "pcp/pcp.h" +#include "md5.h" + +#define MAX_FILE_LINE_LEN 512 +#define MAX_USER_PASSWD_LEN 128 + +extern void pcp_set_timeout(long sec); +static int exit_request; /* non 0 means SIGTERM(smart shutdown) or SIGINT(fast shutdown) has arrived */ + +static RETSIGTYPE die(int sig); +static PCP_CONNECTION *pcp_do_accept(int unix_fd, int inet_fd); +static void unset_nonblock(int fd); +static int user_authenticate(char *buf, char *passwd_file, char *salt, int salt_len); +static void pool_random_salt(char *md5Salt); +static RETSIGTYPE wakeup_handler(int sig); +static RETSIGTYPE reload_config_handler(int sig); + +extern int myargc; +extern char **myargv; + +static volatile sig_atomic_t pcp_got_sighup = 0; +volatile sig_atomic_t pcp_wakeup_request = 0; + +void +pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file) +{ + PCP_CONNECTION *frontend = NULL; + int authenticated = 0; + struct timeval uptime; + char salt[4]; + int random_salt = 0; + int i; + char tos; + int rsize; + char *buf = NULL; + + pool_debug("I am PCP %d", getpid()); + + /* Identify myself via ps */ + init_ps_display("", "", "", ""); + + gettimeofday(&uptime, NULL); + srandom((unsigned int) (getpid() ^ uptime.tv_usec)); + + /* set pcp_read() timeout */ + pcp_set_timeout(pool_config->pcp_timeout); + + /* set up signal handlers */ + signal(SIGTERM, die); + signal(SIGINT, die); + signal(SIGHUP, reload_config_handler); + signal(SIGQUIT, die); + signal(SIGCHLD, SIG_DFL); + signal(SIGUSR1, SIG_DFL); + signal(SIGUSR2, wakeup_handler); + signal(SIGPIPE, SIG_IGN); + signal(SIGALRM, SIG_IGN); + + for(;;) + { + errno = 0; + + if (frontend == NULL) + { + frontend = pcp_do_accept(unix_fd, inet_fd); + if (frontend == NULL) + continue; + + unset_nonblock(frontend->fd); + } + + /* read a PCP packet */ + if (pcp_read(frontend, &tos, 1)) + { + if (errorcode == TIMEOUTERR) + { + pool_debug("pcp_child: pcp_read() has timed out"); + authenticated = 0; + pcp_close(frontend); frontend = NULL; + free(buf); buf = NULL; + continue; + } + pool_error("pcp_child: pcp_read() failed. reason: %s", strerror(errno)); + exit(1); + } + if (pcp_read(frontend, &rsize, sizeof(int))) + { + if (errorcode == TIMEOUTERR) + { + pool_debug("pcp_child: pcp_read() has timed out"); + authenticated = 0; + pcp_close(frontend); frontend = NULL; + free(buf); buf = NULL; + continue; + } + pool_error("pcp_child: pcp_read() failed. reason: %s", strerror(errno)); + exit(1); + } + + rsize = ntohl(rsize); + if ((rsize - sizeof(int)) > 0) + { + buf = (char *)malloc(rsize - sizeof(int)); + if (buf == NULL) + { + pool_error("pcp_child: malloc() failed. reason: %s", strerror(errno)); + exit(1); + } + if (pcp_read(frontend, buf, rsize - sizeof(int))) + { + if (errorcode == TIMEOUTERR) + { + pool_debug("pcp_child: pcp_read() has timed out"); + authenticated = 0; + pcp_close(frontend); frontend = NULL; + free(buf); buf = NULL; + continue; + } + pool_error("pcp_child: pcp_read() failed. reason: %s", strerror(errno)); + exit(1); + } + } + + /* is this connection authenticated? if not disconnect immediately*/ + if ((! authenticated) && (tos != 'R' && tos != 'M')) + { + pool_debug("pcp_child: connection not authorized"); + free(buf); + buf = NULL; + pcp_close(frontend); + frontend = NULL; + pool_signal(SIGALRM, SIG_IGN); + continue; + } + + /* process a request */ + pool_debug("pcp_child: received PCP packet type of service '%c'", tos); + + set_ps_display("PCP: processing a request", false); + + switch (tos) + { + case 'R': /* authentication */ + { + int wsize; + + if (random_salt) + { + authenticated = user_authenticate(buf, pcp_conf_file, salt, 4); + } + if (!random_salt || !authenticated) + { + char code[] = "AuthenticationFailed"; + char mesg[] = "username and/or password do not match"; + pcp_write(frontend, "r", 1); + wsize = htonl(sizeof(code) + sizeof(mesg) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + pcp_write(frontend, mesg, sizeof(mesg)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_error("pcp_child: authentication failed"); + pcp_close(frontend); + frontend = NULL; + random_salt = 0; + } + else + { + char code[] = "AuthenticationOK"; + pcp_write(frontend, "r", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + random_salt = 0; + + pool_debug("pcp_child: authentication OK"); + } + break; + } + + case 'M': /* md5 salt */ + { + int wsize; + + pool_random_salt(salt); + random_salt = 1; + + pcp_write(frontend, "m", 1); + wsize = htonl(sizeof(int) + 4); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, salt, 4); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: salt sent to the client"); + break; + } + + case 'L': /* node count */ + { + int wsize; + int node_count = pool_get_node_count(); + + char code[] = "CommandComplete"; + char mesg[16]; + + snprintf(mesg, sizeof(mesg), "%d", node_count); + + pcp_write(frontend, "l", 1); + wsize = htonl(sizeof(code) + + strlen(mesg)+1 + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + pcp_write(frontend, mesg, strlen(mesg)+1); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: %d node(s) found", node_count); + break; + } + case 'I': /* node info */ + { + int node_id; + int wsize; + + BackendInfo *bi = NULL; + + node_id = atoi(buf); + bi = pool_get_node_info(node_id); + + if (bi == NULL) { + char code[] = "Invalid Node ID"; + + pcp_write(frontend, "e", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: invalid node ID"); + } + else + { + char code[] = "CommandComplete"; + char port_str[6]; + char status[2]; + char weight_str[20]; + + snprintf(port_str, sizeof(port_str), "%d", bi->backend_port); + snprintf(status, sizeof(status), "%d", bi->backend_status); + snprintf(weight_str, sizeof(weight_str), "%f", bi->backend_weight); + + pcp_write(frontend, "i", 1); + wsize = htonl(sizeof(code) + + strlen(bi->backend_hostname)+1 + + strlen(port_str)+1 + + strlen(status)+1 + + strlen(weight_str)+1 + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + pcp_write(frontend, bi->backend_hostname, strlen(bi->backend_hostname)+1); + pcp_write(frontend, port_str, strlen(port_str)+1); + pcp_write(frontend, status, strlen(status)+1); + pcp_write(frontend, weight_str, strlen(weight_str)+1); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: retrieved node information from shared memory"); + } + break; + } + + case 'N': /* process count */ + { + int wsize; + int process_count; + char process_count_str[16]; + int *process_list = NULL; + char code[] = "CommandComplete"; + char *mesg = NULL; + int i; + int total_port_len = 0; + + process_list = pool_get_process_list(&process_count); + + mesg = (char *)malloc(6*process_count); /* port# is at most 5 characters long (MAX:65535) */ + if (mesg == NULL) + { + pool_error("pcp_child: malloc() failed. reason: %s", strerror(errno)); + exit(1); + } + + snprintf(process_count_str, sizeof(process_count_str), "%d", process_count); + + for (i = 0; i < process_count; i++) + { + char port[6]; + snprintf(port, sizeof(port), "%d", process_list[i]); + snprintf(mesg+total_port_len, strlen(port)+1, "%s", port); + total_port_len += strlen(port)+1; + } + + pcp_write(frontend, "n", 1); + wsize = htonl(sizeof(code) + + strlen(process_count_str)+1 + + total_port_len + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + pcp_write(frontend, process_count_str, strlen(process_count_str)+1); + pcp_write(frontend, mesg, total_port_len); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + free(process_list); + free(mesg); + + pool_debug("pcp_child: %d process(es) found", process_count); + break; + } + + case 'P': /* process info */ + { + int proc_id; + int wsize; + + ProcessInfo *pi = NULL; + + proc_id = atoi(buf); + pi = pool_get_process_info(proc_id); + + if (pi == NULL) + { + char code[] = "InvalidProcessID"; + + pcp_write(frontend, "e", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: invalid process ID"); + } + else + { + /* First, send array size of connection_info */ + char arr_code[] = "ArraySize"; + char con_info_size[16]; + /* Finally, indicate that all data is sent */ + char fin_code[] = "CommandComplete"; + + snprintf(con_info_size, sizeof(con_info_size), "%d", pool_config->max_pool); + + pcp_write(frontend, "p", 1); + wsize = htonl(sizeof(arr_code) + + strlen(con_info_size)+1 + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, arr_code, sizeof(arr_code)); + pcp_write(frontend, con_info_size, strlen(con_info_size)+1); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + /* Second, send process information for all connection_info */ + + for (i = 0; i < pool_config->max_pool; i++) + { + char code[] = "ProcessInfo"; + char proc_start_time[20]; + char proc_create_time[20]; + char majorversion[5]; + char minorversion[5]; + char pool_counter[16]; + + snprintf(proc_start_time, sizeof(proc_start_time), "%ld", pi->start_time); + snprintf(proc_create_time, sizeof(proc_create_time), "%ld", pi->connection_info[i].create_time); + snprintf(majorversion, sizeof(majorversion), "%d", pi->connection_info[i].major); + snprintf(minorversion, sizeof(minorversion), "%d", pi->connection_info[i].minor); + snprintf(pool_counter, sizeof(pool_counter), "%d", pi->connection_info[i].counter); + + pcp_write(frontend, "p", 1); + wsize = htonl(sizeof(code) + + strlen(pi->connection_info[i].database)+1 + + strlen(pi->connection_info[i].user)+1 + + strlen(proc_start_time)+1 + + strlen(proc_create_time)+1 + + strlen(majorversion)+1 + + strlen(minorversion)+1 + + strlen(pool_counter)+1 + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + pcp_write(frontend, pi->connection_info[i].database, strlen(pi->connection_info[i].database)+1); + pcp_write(frontend, pi->connection_info[i].user, strlen(pi->connection_info[i].user)+1); + pcp_write(frontend, proc_start_time, strlen(proc_start_time)+1); + pcp_write(frontend, proc_create_time, strlen(proc_create_time)+1); + pcp_write(frontend, majorversion, strlen(majorversion)+1); + pcp_write(frontend, minorversion, strlen(minorversion)+1); + pcp_write(frontend, pool_counter, strlen(pool_counter)+1); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + } + + pcp_write(frontend, "p", 1); + wsize = htonl(sizeof(fin_code) + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, fin_code, sizeof(fin_code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: retrieved process information from shared memory"); + } + break; + } + + case 'S': /* SystemDB info */ + { + int wsize; + + SystemDBInfo *si = NULL; + si = pool_get_system_db_info(); + + /* since PCP clients can only see SystemDBInfo, set system_db_status from the shared memory */ + si->system_db_status = SYSDB_STATUS; + + if (si == NULL) + { + char code[] = "SystemDBNotDefined"; + + pcp_write(frontend, "e", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + } + else + { + /* first, send systemDB information */ + char code[] = "SystemDBInfo"; + char port[6]; + char status[2]; + char dist_def_num[16]; + /* finally, indicate that all data is sent */ + char fin_code[] = "CommandComplete"; + + snprintf(port, sizeof(port), "%d", si->port); + snprintf(status, sizeof(status), "%d", si->system_db_status); + snprintf(dist_def_num, sizeof(dist_def_num), "%d", si->dist_def_num); + + pcp_write(frontend, "s", 1); + wsize = htonl(sizeof(code) + + strlen(si->hostname)+1 + + strlen(port)+1 + + strlen(si->user)+1 + + strlen(si->password)+1 + + strlen(si->schema_name)+1 + + strlen(si->database_name)+1 + + strlen(dist_def_num)+1 + + strlen(status)+1 + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + pcp_write(frontend, si->hostname, strlen(si->hostname)+1); + pcp_write(frontend, port, strlen(port)+1); + pcp_write(frontend, si->user, strlen(si->user)+1); + pcp_write(frontend, si->password, strlen(si->password)+1); + pcp_write(frontend, si->schema_name, strlen(si->schema_name)+1); + pcp_write(frontend, si->database_name, strlen(si->database_name)+1); + pcp_write(frontend, dist_def_num, strlen(dist_def_num)+1); + pcp_write(frontend, status, strlen(status)+1); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + /* second, send DistDefInfo if any */ + if (si->dist_def_num > 0) + { + char dist_code[] = "DistDefInfo"; + char col_num[16]; + int col_list_total_len; + int type_list_total_len; + char *col_list = NULL; + char *type_list = NULL; + int col_list_offset; + int type_list_offset; + DistDefInfo *ddi; + int i, j; + + for (i = 0; i < si->dist_def_num; i++) + { + ddi = &si->dist_def_slot[i]; + snprintf(col_num, sizeof(col_num), "%d", ddi->col_num); + + col_list_total_len = type_list_total_len = 0; + for (j = 0; j < ddi->col_num; j++) + { + col_list_total_len += strlen(ddi->col_list[j]) + 1; + type_list_total_len += strlen(ddi->type_list[j]) + 1; + } + + col_list = (char *)malloc(col_list_total_len); + type_list = (char *)malloc(type_list_total_len); + if (col_list == NULL || type_list == NULL) + { + pool_error("pcp_child: malloc() failed. reason: %s", strerror(errno)); + exit(1); + } + + col_list_offset = type_list_offset = 0; + for (j = 0; j < ddi->col_num; j++) + { + snprintf(col_list + col_list_offset, strlen(ddi->col_list[j])+1, + "%s", ddi->col_list[j]); + snprintf(type_list + type_list_offset, strlen(ddi->type_list[j])+1, + "%s", ddi->type_list[j]); + col_list_offset += strlen(ddi->col_list[j]) + 1; + type_list_offset += strlen(ddi->type_list[j]) + 1; + } + + pcp_write(frontend, "s", 1); + wsize = htonl(sizeof(dist_code) + + strlen(ddi->dbname)+1 + + strlen(ddi->schema_name)+1 + + strlen(ddi->table_name)+1 + + strlen(ddi->dist_key_col_name)+1 + + strlen(col_num)+1 + + col_list_total_len + + type_list_total_len + + strlen(ddi->dist_def_func)+1 + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, dist_code, sizeof(dist_code)); + pcp_write(frontend, ddi->dbname, strlen(ddi->dbname)+1); + pcp_write(frontend, ddi->schema_name, strlen(ddi->schema_name)+1); + pcp_write(frontend, ddi->table_name, strlen(ddi->table_name)+1); + pcp_write(frontend, ddi->dist_key_col_name, strlen(ddi->dist_key_col_name)+1); + pcp_write(frontend, col_num, strlen(col_num)+1); + pcp_write(frontend, col_list, col_list_total_len); + pcp_write(frontend, type_list, type_list_total_len); + pcp_write(frontend, ddi->dist_def_func, strlen(ddi->dist_def_func)+1); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + free(col_list); + free(type_list); + } + } + + pcp_write(frontend, "s", 1); + wsize = htonl(sizeof(fin_code) + + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, fin_code, sizeof(fin_code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + + pool_debug("pcp_child: retrieved SystemDB information from shared memory"); + } + break; + } + + case 'D': /* detach node */ + { + int node_id; + int wsize; + char code[] = "CommandComplete"; + + node_id = atoi(buf); + pool_debug("pcp_child: detaching Node ID %d", node_id); + notice_backend_error(node_id); + + pcp_write(frontend, "d", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + break; + } + + case 'C': /* attach node */ + { + int node_id; + int wsize; + char code[] = "CommandComplete"; + + node_id = atoi(buf); + pool_debug("pcp_child: attaching Node ID %d", node_id); + send_failback_request(node_id); + + pcp_write(frontend, "c", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + break; + } + + case 'T': + { + char mode = buf[0]; + pid_t ppid = getppid(); + + if (mode == 's') + { + pool_debug("pcp_child: sending SIGTERM to the parent process(%d)", ppid); + kill(ppid, SIGTERM); + } + else if (mode == 'f') + { + pool_debug("pcp_child: sending SIGINT to the parent process(%d)", ppid); + kill(ppid, SIGINT); + } + else if (mode == 'i') + { + pool_debug("pcp_child: sending SIGQUIT to the parent process(%d)", ppid); + kill(ppid, SIGQUIT); + } + else + { + pool_debug("pcp_child: invalid shutdown mode %c", mode); + } + + break; + } + + case 'O': /* recovery request */ + { + int node_id; + int wsize; + char code[] = "CommandComplete"; + int r; + + if (!REPLICATION) + { + int len = strlen("recovery request is accepted only in replication mode. ") + 1; + pcp_write(frontend, "e", 1); + wsize = htonl(sizeof(int) + len); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, "recovery request is accepted only in replication mode. ", len); + } + else + { + pool_debug("pcp_child: start online recovery"); + node_id = atoi(buf); + + r = start_recovery(node_id); + finish_recovery(); + + if (r == 0) /* success */ + { + pcp_write(frontend, "c", 1); + wsize = htonl(sizeof(code) + sizeof(int)); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, code, sizeof(code)); + } + else + { + int len = strlen("recovery failed") + 1; + pcp_write(frontend, "e", 1); + wsize = htonl(sizeof(int) + len); + pcp_write(frontend, &wsize, sizeof(int)); + pcp_write(frontend, "recovery failed", len); + } + } + if (pcp_flush(frontend) < 0) + { + pool_error("pcp_child: pcp_flush() failed. reason: %s", strerror(errno)); + exit(1); + } + } + break; + + case 'F': + pool_debug("pcp_child: stop online recovery"); + break; + + case 'X': /* disconnect */ + pool_debug("pcp_child: client disconnecting. close connection"); + authenticated = 0; + pcp_close(frontend); + frontend = NULL; + break; + + default: + pool_error("pcp_child: unknown packet type %c received", tos); + exit(1); + } + + free(buf); + buf = NULL; + + /* seems ok. cancel idle check timer */ + pool_signal(SIGALRM, SIG_IGN); + } + + exit(0); +} + +static RETSIGTYPE +die(int sig) +{ + exit_request = 1; + + pool_debug("PCP child receives shutdown request signal %d", sig); + + switch (sig) + { + case SIGTERM: /* smart shutdown */ + case SIGINT: /* fast shutdown */ + case SIGQUIT: /* immediate shutdown */ + exit(0); + break; + default: + break; + } + + /* send_frontend_exits(); */ + + exit(0); +} + +static RETSIGTYPE +wakeup_handler(int sig) +{ + pcp_wakeup_request = 1; +} + +static PCP_CONNECTION * +pcp_do_accept(int unix_fd, int inet_fd) +{ + PCP_CONNECTION *pc = NULL; + + fd_set readmask; + int fds; + + struct sockaddr addr; + socklen_t addrlen; + int fd = 0; + int afd; + int inet = 0; + + set_ps_display("PCP: wait for connection request", false); + + FD_ZERO(&readmask); + FD_SET(unix_fd, &readmask); + if (inet_fd) + FD_SET(inet_fd, &readmask); + + fds = select(Max(unix_fd, inet_fd)+1, &readmask, NULL, NULL, NULL); + + if (fds == -1) + { + if (errno == EAGAIN || errno == EINTR) + return NULL; + + pool_error("pcp_child: select() failed. reason: %s", strerror(errno)); + return NULL; + } + + if (FD_ISSET(unix_fd, &readmask)) + { + fd = unix_fd; + } + + if (FD_ISSET(inet_fd, &readmask)) + { + fd = inet_fd; + inet++; + } + + addrlen = sizeof(addr); + + afd = accept(fd, &addr, &addrlen); + if (afd < 0) + { + /* + * "Resource temporarily unavailable" (EAGAIN or EWOULDBLOCK) + * can be silently ignored. + */ + if (errno != EAGAIN && errno != EWOULDBLOCK) + pool_error("pcp_child: accept() failed. reason: %s", strerror(errno)); + return NULL; + } + + if (pcp_got_sighup) + { + pool_get_config(get_config_file_name(), RELOAD_CONFIG); + pcp_got_sighup = 0; + } + + pool_debug("I am PCP %d accept fd %d", getpid(), afd); + + if (inet) + { + int on = 1; + + if (setsockopt(afd, IPPROTO_TCP, TCP_NODELAY, + (char *) &on, + sizeof(on)) < 0) + { + pool_error("pcp_child: setsockopt() failed: %s", strerror(errno)); + close(afd); + return NULL; + } + if (setsockopt(afd, SOL_SOCKET, SO_KEEPALIVE, + (char *) &on, + sizeof(on)) < 0) + { + pool_error("pcp_child: setsockopt() failed: %s", strerror(errno)); + close(afd); + return NULL; + } + } + + if ((pc = pcp_open(afd)) == NULL) + { + close(afd); + return NULL; + } + return pc; +} + +/* + * unset non-block flag + */ +static void +unset_nonblock(int fd) +{ + int var; + + /* set fd to non-blocking */ + var = fcntl(fd, F_GETFL, 0); + if (var == -1) + { + pool_error("pcp_child: fcntl failed. %s", strerror(errno)); + exit(1); + } + if (fcntl(fd, F_SETFL, var & ~O_NONBLOCK) == -1) + { + pool_error("pcp_child: fcntl failed. %s", strerror(errno)); + exit(1); + } +} + +/* + * see if received username and password matches with one in the file + */ +static int +user_authenticate(char *buf, char *passwd_file, char *salt, int salt_len) +{ + FILE *fp = NULL; + char packet_username[MAX_USER_PASSWD_LEN+1]; + char packet_password[MAX_USER_PASSWD_LEN+1]; + char encrypt_buf[(MD5_PASSWD_LEN+1)*2]; + char file_username[MAX_USER_PASSWD_LEN+1]; + char file_password[MD5_PASSWD_LEN+1]; + char *index = NULL; + static char line[MAX_FILE_LINE_LEN+1]; + int i, len; + + /* strcpy() should be OK, but use strncpy() to be extra careful */ + strncpy(packet_username, buf, MAX_USER_PASSWD_LEN); + index = (char *) memchr(buf, '\0', MAX_USER_PASSWD_LEN) + 1; + if (index == NULL) + { + pool_debug("pcp_child: error while reading authentication packet"); + return 0; + } + strncpy(packet_password, index, MAX_USER_PASSWD_LEN); + + fp = fopen(passwd_file, "r"); + if (fp == NULL) + { + pool_error("pcp_child: could not open %s. reason: %s", passwd_file, strerror(errno)); + return 0; + } + + /* for now, I don't care if duplicate username exists in the config file */ + while ((fgets(line, MAX_FILE_LINE_LEN, fp)) != NULL) + { + i = 0; + len = 0; + + if (line[0] == '\n') + continue; + if (line[0] == '#') + continue; + + while (line[i] != ':') + { + len++; + if (++i > MAX_USER_PASSWD_LEN) + { + pool_error("pcp_child: user name in %s exceeds %d", passwd_file, MAX_USER_PASSWD_LEN); + fclose(fp); + return 0; + } + } + memcpy(file_username, line, len); + file_username[len] = '\0'; + + if (strcmp(packet_username, file_username) != 0) + continue; + + i++; + len = 0; + while (line[i] != '\n' && line[i] != '\0') + { + len++; + if (++i > MAX_USER_PASSWD_LEN) + { + pool_error("pcp_child: password in %s exceeds %d", passwd_file, MAX_USER_PASSWD_LEN); + fclose(fp); + return 0; + } + } + + memcpy(file_password, line+strlen(file_username)+1, len); + file_password[len] = '\0'; + + pool_md5_encrypt(file_password, file_username, strlen(file_username), + encrypt_buf + MD5_PASSWD_LEN + 1); + encrypt_buf[(MD5_PASSWD_LEN+1)*2-1] = '\0'; + + pool_md5_encrypt(encrypt_buf+MD5_PASSWD_LEN+1, salt, salt_len, + encrypt_buf); + encrypt_buf[MD5_PASSWD_LEN] = '\0'; + + if (strcmp(encrypt_buf, packet_password) == 0) + { + fclose(fp); + return 1; + } + } + + fclose(fp); + return 0; +} + +/* + * pool_random_salt + */ +static void pool_random_salt(char *md5Salt) +{ + long rand = random(); + + md5Salt[0] = (rand % 255) + 1; + rand = random(); + md5Salt[1] = (rand % 255) + 1; + rand = random(); + md5Salt[2] = (rand % 255) + 1; + rand = random(); + md5Salt[3] = (rand % 255) + 1; +} + +/* SIGHUP handler */ +static RETSIGTYPE reload_config_handler(int sig) +{ + pcp_got_sighup = 1; +} diff --git a/pg_md5.c b/pg_md5.c new file mode 100644 index 0000000..893c84b --- /dev/null +++ b/pg_md5.c @@ -0,0 +1,145 @@ +#include +#include +#include +#include +#include +#include + +#include "md5.h" + + +/* Maximum number of characters allowed for input. */ +#define MAX_INPUT_SIZE 32 + +void print_usage(const char prog[], int exit_code); +void set_tio_attr(int enable); + +int +main(int argc, char *argv[]) +{ + +#define PRINT_USAGE(exit_code) print_usage(argv[0], exit_code) +#define COMPARE_ARG(arg) (!strcmp(argv[1], arg)) + + if (argc != 2) + PRINT_USAGE(EXIT_FAILURE); + else if (COMPARE_ARG("--help") || COMPARE_ARG("-h")) + PRINT_USAGE(EXIT_SUCCESS); + + /* Prompt for password. */ + else if (COMPARE_ARG("--prompt") || COMPARE_ARG("-p")) + { + char md5[MD5_PASSWD_LEN+1]; + char buf[MAX_INPUT_SIZE+1]; + int len; + + set_tio_attr(1); + printf("password: "); + if (!fgets(buf, (MAX_INPUT_SIZE+1), stdin)) + { + int eno = errno; + + fprintf(stderr, "Couldn't read input from stdin. (fgets(): %s)", + strerror(eno)); + + exit(EXIT_FAILURE); + } + set_tio_attr(0); + + /* Remove LF at the end of line, if there is any. */ + len = strlen(buf); + if (len > 0 && buf[len-1] == '\n') + { + buf[len-1] = '\0'; + len--; + } + + pool_md5_hash(buf, len, md5); + printf("\n%s\n", md5); + } + + /* Read password from argv[1]. */ + else + { + char md5[MD5_PASSWD_LEN+1]; + int len = strlen(argv[1]); + + if (len > MAX_INPUT_SIZE) + { + fprintf(stderr, "Error: Input exceeds maximum password length!\n\n"); + PRINT_USAGE(EXIT_FAILURE); + } + + pool_md5_hash(argv[1], len, md5); + printf("%s\n", md5); + } + + return EXIT_SUCCESS; +} + + +void +print_usage(const char prog[], int exit_code) +{ + fprintf(((exit_code == EXIT_SUCCESS) ? stdout : stderr), + "Usage:\n\ +\n\ + %s [OPTIONS]\n\ + %s \n\ +\n\ + --prompt, -p Prompt password using standard input.\n\ + --help, -h This help menu.\n\ +\n\ +Warning: At most %d characters are allowed for input.\n\ +Warning: Plain password argument is deprecated for security concerns\n\ + and kept for compatibility. Please prefer using password\n\ + prompt.\n", + prog, prog, MAX_INPUT_SIZE); + + exit(exit_code); +} + + +void +set_tio_attr(int set) +{ + struct termios tio; + static struct termios tio_save; + + + if (!isatty(0)) + { + fprintf(stderr, "stdin is not tty\n"); + exit(EXIT_FAILURE); + } + + if (set) + { + if (tcgetattr(0, &tio) < 0) + { + fprintf(stderr, "set_tio_attr(set): tcgetattr failed\n"); + exit(EXIT_FAILURE); + } + + tio_save = tio; + + tio.c_iflag &= ~(BRKINT|ISTRIP|IXON); + tio.c_lflag &= ~(ICANON|IEXTEN|ECHO|ECHOE|ECHOK|ECHONL); + tio.c_cc[VMIN] = 1; + tio.c_cc[VTIME] = 0; + + if (tcsetattr(0, TCSANOW, &tio) < 0) + { + fprintf(stderr, "(set_tio_attr(set): tcsetattr failed\n"); + exit(EXIT_FAILURE); + } + } + else + { + if (tcsetattr(0, TCSANOW, &tio_save) < 0) + { + fprintf(stderr, "set_tio_attr(reset): tcsetattr failed\n"); + exit(EXIT_FAILURE); + } + } +} diff --git a/pgpool.8.in b/pgpool.8.in new file mode 100644 index 0000000..f125b0c --- /dev/null +++ b/pgpool.8.in @@ -0,0 +1,98 @@ +.\" Copyright 2004-2009 by PgPool Global Development Group +.\" This man page is subject to the same license as the rest of pgpool. +.\" +.TH PGPOOL 8 "08 Mar 2009" +.\" Please adjust this date whenever revising the manpage. +.hy 0 +.ad l +.nf +.SH NAME +pgpool \- PostgreSQL connection pool daemon +.SH SYNOPSIS +\fBpgpool\fR [ \fB\-c\fR] [ \fB\-f config_file\fR ] [ \fB\-F pcp_config_file\fR ] [ \fB\-a hba_file\fR ] [ \fB\-n\fR ] [ \fB\-d\fR ] +.LP +\fBpgpool\fR [ \fB\-f config_file\fR ] [ \fB\-F pcp_config_file\fR ] [ \fB\-a hba_file\fR ] [ \fB\-m\fR \fI{s[mart]|f[ast]|i[mmediate]}\fR ] \fBstop\fR +.LP +\fBpgpool\fR [ \fB\-f config_file\fR ] [ \fB\-F pcp_config_file\fR ] [ \fB\-a hba_file\fR ] \fBreload\fR +.LP +.SH DESCRIPTION +\fBpgpool\fR is a connection pool server for PostgreSQL. +\fBpgpool\fR runs between PostgreSQL's client and server. +Any PostgreSQL client can connect to \fBpgpool\fR as if it's a real PostgreSQL server. +\fBpgpool\fR caches the connection to the PostgreSQL server to reduce the overhead +involved in establishing the connection to it. +.P +\fBpgpool\fR can also be +used with two PostgreSQL servers for fail over purposes. If the first +server goes down, \fBpgpool\fR will automatically switch to the secondary server. +.P +\fBpgpool\fR is typically started and stopped via system initialization scripts. +. +.P +.SH INVOCATION +.TP +\fBpgpool\fP [ \fIoptions...\fP ] +Starts as a daemon in the background (unless \fB\-n\fR is given). +.TP +\fBpgpool\fP [ \fIoptions...\fP ] \fBstop\fP +Shutdown. +.TP +\fBpgpool\fP [ \fIoptions...\fP ] \fBreload\fP +Reloads the configuration. +.. +.SH OPTIONS +.TP +\fB\-a\fR \fIpath\fR +Sets the path to the \fIpool_hba.conf\fR configuration file (default: \fI@sysconfdir@/pgpool_hba.conf\fR). +.TP +\fB\-c\fR +Clears the query cache. +.TP +\fB\-d\fR +Print lots of debug messages. +.TP +\fB\-f\fR \fIpath\fR +Sets the path to the \fIpgpool.conf\fR configuration file (default: \fI@sysconfdir@/pgpool.conf\fR). +.TP +\fB\-F\fR \fIpath\fR +Sets the path to the \fIpcp.conf\fR configuration file (default: \fI@sysconfdir@/pcp.conf\fR). +.TP +\fB\-h\fR +Print a help message and exit. +.TP +\fB\-m\fR \fImode\fR +Shutdown mode: +.B smart, fast, +or +.BR immediate . +.TP +\fB\-n\fR +Foreground mode. +Error messages go to stdout or stderr, which +could be piped out to log processors such as +.BR logger (1) +or +.BR rotatelogs (8). +To daemonize, explicitly invoke +.B pgpool +in background. +.TP +.B \-v +Print version and exit. +. +.SH FILES +.TP +\fI@sysconfdir@/pgpool.conf\fR +Default configuration file +.TP +\fI@sysconfdir@/pool_hba.conf\fR +Host Based Access configuration file +.TP +\fI@sysconfdir@/pcp.conf\fR +PCP commands configuration file +.SH SEE ALSO +.BR logger (1), +.BR postmaster (1), +.BR rotatelogs (8) +.PP +Additional information can be found in the \fBpgpool\fR \fIREADME\fR file. diff --git a/pgpool.conf.sample b/pgpool.conf.sample new file mode 100644 index 0000000..4345136 --- /dev/null +++ b/pgpool.conf.sample @@ -0,0 +1,208 @@ +# +# pgpool-II configuration file sample +# $Header: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample,v 1.26 2009/02/15 05:26:28 t-ishii Exp $ + +# Host name or IP address to listen on: '*' for all, '' for no TCP/IP +# connections +listen_addresses = 'localhost' + +# Port number for pgpool +port = 9999 + +# Port number for pgpool communication manager +pcp_port = 9898 + +# Unix domain socket path. (The Debian package defaults to +# /var/run/postgresql.) +socket_dir = '/tmp' + +# Unix domain socket path for pgpool communication manager. +# (Debian package defaults to /var/run/postgresql) +pcp_socket_dir = '/tmp' + +# Unix domain socket path for the backend. Debian package defaults to /var/run/postgresql! +backend_socket_dir = '/tmp' + +# pgpool communication manager timeout. 0 means no timeout, but strongly not recommended! +pcp_timeout = 10 + +# number of pre-forked child process +num_init_children = 32 + +# Number of connection pools allowed for a child process +max_pool = 4 + +# If idle for this many seconds, child exits. 0 means no timeout. +child_life_time = 300 + +# If idle for this many seconds, connection to PostgreSQL closes. +# 0 means no timeout. +connection_life_time = 0 + +# If child_max_connections connections were received, child exits. +# 0 means no exit. +child_max_connections = 0 + +# If client_idle_limit is n (n > 0), the client is forced to be +# disconnected whenever after n seconds idle (even inside an explicit +# transactions!) +# 0 means no disconnect. +client_idle_limit = 0 + +# Maximum time in seconds to complete client authentication. +# 0 means no timeout. +authentication_timeout = 60 + +# Logging directory +logdir = '/tmp' + +# pid file name +pid_file_name = '/var/run/pgpool/pgpool.pid' + +# Replication mode +replication_mode = false + +# Load balancing mode, i.e., all SELECTs are load balanced. +# This is ignored if replication_mode is false. +load_balance_mode = false + +# if there's a data mismatch between master and secondary +# start degeneration to stop replication mode +replication_stop_on_mismatch = false + +# If true, replicate SELECT statement when load balancing is disabled. +# If false, it is only sent to the master node. +replicate_select = false + +# Semicolon separated list of queries to be issued at the end of a session +reset_query_list = 'ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT' +# for 8.3 or newer PostgreSQL versions DISCARD ALL can be used as +# follows. However beware that DISCARD ALL holds exclusive lock on +# pg_listener so it will be a serious performance problem if there are +# lots of concurrent sessions. +# reset_query_list = 'ABORT; DISCARD ALL' + +# If true print timestamp on each log line. +print_timestamp = true + +# If true, operate in master/slave mode. +master_slave_mode = false + +# If true, cache connection pool. +connection_cache = true + +# Health check timeout. 0 means no timeout. +health_check_timeout = 20 + +# Health check period. 0 means no health check. +health_check_period = 0 + +# Health check user +health_check_user = 'nobody' + +# Execute command by failover. +# special values: %d = node id +# %h = host name +# %p = port number +# %D = database cluster path +# %m = new master node id +# %M = old master node id +# %% = '%' character +# +failover_command = '' + +# Execute command by failback. +# special values: %d = node id +# %h = host name +# %p = port number +# %D = database cluster path +# %m = new master node id +# %M = old master node id +# %% = '%' character +# +failback_command = '' + +# If true, automatically locks a table with INSERT statements to keep +# SERIAL data consistency. If the data does not have SERIAL data +# type, no lock will be issued. An /*INSERT LOCK*/ comment has the +# same effect. A /NO INSERT LOCK*/ comment disables the effect. +insert_lock = true + +# If true, ignore leading white spaces of each query while pgpool judges +# whether the query is a SELECT so that it can be load balanced. This +# is useful for certain APIs such as DBI/DBD which is known to adding an +# extra leading white space. +ignore_leading_white_space = true + +# If true, print all statements to the log. Like the log_statement option +# to PostgreSQL, this allows for observing queries without engaging in full +# debugging. +log_statement = false + +# If true, incoming connections will be printed to the log. +log_connections = false + +# If true, hostname will be shown in ps status. Also shown in +# connection log if log_connections = true. +# Be warned that this feature will add overhead to look up hostname. +log_hostname = false + +# if non 0, run in parallel query mode +parallel_mode = false + +# if non 0, use query cache +enable_query_cache = false + +#set pgpool2 hostname +pgpool2_hostname = '' + +# system DB info +system_db_hostname = 'localhost' +system_db_port = 5432 +system_db_dbname = 'pgpool' +system_db_schema = 'pgpool_catalog' +system_db_user = 'pgpool' +system_db_password = '' + +# backend_hostname, backend_port, backend_weight +# here are examples +#backend_hostname0 = 'host1' +#backend_port0 = 5432 +#backend_weight0 = 1 +#backend_data_directory0 = '/data' +#backend_hostname1 = 'host2' +#backend_port1 = 5433 +#backend_weight1 = 1 +#backend_data_directory1 = '/data1' + +# - HBA - + +# If true, use pool_hba.conf for client authentication. In pgpool-II +# 1.1, the default value is false. The default value will be true in +# 1.2. +enable_pool_hba = false + +# - online recovery - +# online recovery user +recovery_user = 'nobody' + +# online recovery password +recovery_password = '' + +# execute a command in first stage. +recovery_1st_stage_command = '' + +# execute a command in second stage. +recovery_2nd_stage_command = '' + +# maximum time in seconds to wait for the recovering node's postmaster +# start-up. 0 means no wait. +# this is also used as a timer waiting for clients disconnected before +# starting 2nd stage +recovery_timeout = 90 + +# If client_idle_limit_in_recovery is n (n > 0), the client is forced +# to be disconnected whenever after n seconds idle (even inside an +# explicit transactions!) 0 means no disconnect. This parameter only +# takes effect in recovery 2nd stage. +client_idle_limit_in_recovery = 0 diff --git a/pgpool.spec b/pgpool.spec new file mode 100644 index 0000000..063db64 --- /dev/null +++ b/pgpool.spec @@ -0,0 +1,194 @@ +Summary: Pgpool is a connection pooling/replication server for PostgreSQL +Name: pgpool-II +Version: 2.2 +Release: 1%{?dist} +License: BSD +Group: Applications/Databases +URL: http://pgpool.projects.PostgreSQL.org +Source0: http://pgfoundry.org/frs/download.php/2108/%{name}-%{version}.tar.gz +Source1: pgpool.init +Source2: pgpool.sysconfig +Patch1: pgpool.conf.sample.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: postgresql-devel pam-devel + +Obsoletes: postgresql-pgpool + +%description +pgpool-II is a inherited project of pgpool (to classify from +pgpool-II, it is sometimes called as pgpool-I). For those of +you not familiar with pgpool-I, it is a multi-functional +middle ware for PostgreSQL that features connection pooling, +replication and load balancing functions. pgpool-I allows a +user to connect at most two PostgreSQL servers for higher +availability or for higher search performance compared to a +single PostgreSQL server. + +pgpool-II, on the other hand, allows multiple PostgreSQL +servers (DB nodes) to be connected, which enables queries +to be executed simultaneously on all servers. In other words, +it enables "parallel query" processing. Also, pgpool-II can +be started as pgpool-I by changing configuration parameters. +pgpool-II that is executed in pgpool-I mode enables multiple +DB nodes to be connected, which was not possible in pgpool-I. + +%package devel +Summary: The development files for pgpool-II +Group: Development/Libraries +Requires: %{name} = %{version} + +%description devel +Development headers and libraries for pgpool-II. + +%prep +%setup -q -n %{name}-%{version} +%patch1 -p0 + +%build +%configure --with-pgsql-includedir=%{_includedir}/pgsql --with-pgsql-lib=%{_libdir}/pgsql --disable-static --with-pam --disable-rpath --sysconfdir=%{_sysconfdir}/%{name}/ + +make %{?_smp_flags} + +%install +rm -rf %{buildroot} +make %{?_smp_flags} DESTDIR=%{buildroot} install +install -d %{buildroot}%{_datadir}/%{name} +install -d %{buildroot}%{_sysconfdir}/%{name} +mv %{buildroot}/%{_sysconfdir}/%{name}/pcp.conf.sample %{buildroot}%{_sysconfdir}/%{name}/pcp.conf +mv %{buildroot}/%{_sysconfdir}/%{name}/pgpool.conf.sample %{buildroot}%{_sysconfdir}/%{name}/pgpool.conf +mv %{buildroot}/%{_sysconfdir}/%{name}/pool_hba.conf.sample %{buildroot}%{_sysconfdir}/%{name}/pool_hba.conf +install -d %{buildroot}%{_initrddir} +install -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/pgpool +install -d %{buildroot}%{_sysconfdir}/sysconfig +install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/pgpool + +# nuke libtool archive and static lib +rm -f %{buildroot}%{_libdir}/libpcp.{a,la} + +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig +chkconfig --add pgpool + +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root,-) +%dir %{_datadir}/%{name} +%doc README README.euc_jp TODO COPYING INSTALL AUTHORS ChangeLog NEWS doc/pgpool-en.html doc/pgpool-ja.html doc/pgpool.css doc/tutorial-en.html doc/tutorial-ja.html +%{_bindir}/pgpool +%{_bindir}/pcp_attach_node +%{_bindir}/pcp_detach_node +%{_bindir}/pcp_node_count +%{_bindir}/pcp_node_info +%{_bindir}/pcp_proc_count +%{_bindir}/pcp_proc_info +%{_bindir}/pcp_stop_pgpool +%{_bindir}/pcp_recovery_node +%{_bindir}/pcp_systemdb_info +%{_bindir}/pg_md5 +%{_mandir}/man8/pgpool* +%{_datadir}/%{name}/system_db.sql +%{_libdir}/libpcp.so.* +%{_datadir}/%{name}/pgpool.pam +%{_initrddir}/pgpool +%attr(764,root,apache) %config(noreplace) %{_sysconfdir}/%{name}/*.conf +%config(noreplace) %{_sysconfdir}/sysconfig/pgpool + +%files devel +%defattr(-,root,root,-) +%{_includedir}/pcp.h +%{_includedir}/pool_type.h +%{_libdir}/libpcp.so + +%changelog +* Sun Mar 1 2009 Devrim Gunduz 2.2-1 +- Update to 2.2 +- Fix URL +- Own /usr/share/pgpool-II directory. +- Fix pid file path in init script, per pgcore #81. +- Fix spec file -- we don't use short_name macro in pgcore spec file. +- Create pgpool pid file directory, per pgcore #81. +- Fix stop/start routines, also improve init script a bit. +- Install conf files to a new directory (/etc/pgpool-II), and get rid + of sample conf files. + +* Fri Aug 8 2008 Devrim Gunduz 2.1-1 +- Update to 2.1 +- Removed temp patch #4. + +* Sun Jan 13 2008 Devrim Gunduz 2.0.1-1 +- Update to 2.0.1 +- Add a temp patch that will disappear in 2.0.2 + +* Fri Oct 5 2007 Devrim Gunduz 1.2.1-1 +- Update to 1.2.1 + +* Wed Aug 29 2007 Devrim Gunduz 1.2-5 +- Chmod sysconfig/pgpool to 644, not 755. Per BZ review. +- Run chkconfig --add pgpool during %%post. + +* Thu Aug 16 2007 Devrim Gunduz 1.2-4 +- Fixed the directory name where sample conf files and sql files + are installed. + +* Sun Aug 5 2007 Devrim Gunduz 1.2-3 +- Added a patch for sample conf file to use Fedora defaults + +* Sun Aug 5 2007 Devrim Gunduz 1.2-2 +- Added an init script for pgpool +- Added /etc/sysconfig/pgpool + +* Wed Aug 1 2007 Devrim Gunduz 1.2-1 +- Update to 1.2 + +* Fri Jun 15 2007 Devrim Gunduz 1.1.1-1 +- Update to 1.1.1 + +* Sat Jun 2 2007 Devrim Gunduz 1.1-1 +- Update to 1.1 +- added --disable-rpath configure parameter. +- Chowned sample conf files, so that they can work with pgpoolAdmin. + +* Thu Apr 22 2007 Devrim Gunduz 1.0.2-4 +- Added postgresql-devel as BR, per bugzilla review. +- Added --disable-static flan, per bugzilla review. +- Removed superfluous manual file installs, per bugzilla review. + +* Thu Apr 22 2007 Devrim Gunduz 1.0.2-3 +- Rebuilt for the correct tarball +- Fixed man8 file ownership, per bugzilla review #229321 + +* Tue Feb 20 2007 Jarod Wilson 1.0.2-2 +- Create proper devel package, drop -libs package +- Nuke rpath +- Don't install libtool archive and static lib +- Clean up %%configure line +- Use proper %%_smp_mflags +- Install config files properly, without .sample on the end +- Preserve timestamps on header files + +* Tue Feb 20 2007 Devrim Gunduz 1.0.2-1 +- Update to 1.0.2-1 + +* Mon Oct 02 2006 Devrim Gunduz 1.0.1-5 +- Rebuilt + +* Mon Oct 02 2006 Devrim Gunduz 1.0.1-4 +- Added -libs and RPM +- Fix .so link problem +- Cosmetic changes to spec file + +* Thu Sep 27 2006 - Devrim GUNDUZ 1.0.1-3 +- Fix spec, per Yoshiyuki Asaba + +* Thu Sep 26 2006 - Devrim GUNDUZ 1.0.1-2 +- Fixed rpmlint errors +- Fixed download url +- Added ldconfig for .so files + +* Thu Sep 21 2006 - David Fetter 1.0.1-1 +- Initial build pgpool-II 1.0.1 for PgPool Global Development Group + diff --git a/pool.h b/pool.h new file mode 100644 index 0000000..674a2b5 --- /dev/null +++ b/pool.h @@ -0,0 +1,597 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool.h,v 1.36.2.5 2009/09/06 03:52:12 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool.h.: master definition header file + * + */ + +#ifndef POOL_H +#define POOL_H + +#include "config.h" +#include "pool_type.h" +#include "pool_signal.h" +#include "libpq-fe.h" +#include +#include +#include +#include + +/* undef this if you have problems with non blocking accept() */ +#define NONE_BLOCK + +#define POOLMAXPATHLEN 8192 + +/* configuration file name */ +#define POOL_CONF_FILE_NAME "pgpool.conf" + +/* PCP user/password file name */ +#define PCP_PASSWD_FILE_NAME "pcp.conf" + +/* HBA configuration file name */ +#define HBA_CONF_FILE_NAME "pool_hba.conf" + +/* pid file directory */ +#define DEFAULT_LOGDIR "/tmp" + +/* Unix domain socket directory */ +#define DEFAULT_SOCKET_DIR "/tmp" + +/* pid file name */ +#define DEFAULT_PID_FILE_NAME "/var/run/pgpool/pgpool.pid" + +typedef enum { + POOL_CONTINUE = 0, + POOL_IDLE, + POOL_END, + POOL_ERROR, + POOL_FATAL, + POOL_DEADLOCK +} POOL_STATUS; + + +typedef enum { + INIT_CONFIG = 1, /* 0x01 */ + RELOAD_CONFIG = 2 /* 0x02 */ +} POOL_CONFIG_CONTEXT; + + +/* protocol major version numbers */ +#define PROTO_MAJOR_V2 2 +#define PROTO_MAJOR_V3 3 + +/* Cancel packet proto major */ +#define PROTO_CANCEL 80877102 + +/* + * In protocol 3.0 and later, the startup packet length is not fixed, but + * we set an arbitrary limit on it anyway. This is just to prevent simple + * denial-of-service attacks via sending enough data to run the server + * out of memory. + */ +#define MAX_STARTUP_PACKET_LENGTH 10000 + + +typedef struct StartupPacket_v2 +{ + int protoVersion; /* Protocol version */ + char database[SM_DATABASE]; /* Database name */ + char user[SM_USER]; /* User name */ + char options[SM_OPTIONS]; /* Optional additional args */ + char unused[SM_UNUSED]; /* Unused */ + char tty[SM_TTY]; /* Tty for debug output */ +} StartupPacket_v2; + +/* startup packet info */ +typedef struct +{ + char *startup_packet; /* raw startup packet without packet length (malloced area) */ + int len; /* raw startup packet length */ + int major; /* protocol major version */ + int minor; /* protocol minor version */ + char *database; /* database name in startup_packet (malloced area) */ + char *user; /* user name in startup_packet (malloced area) */ +} StartupPacket; + +typedef struct CancelPacket +{ + int protoVersion; /* Protocol version */ + int pid; /* bcckend process id */ + int key; /* cancel key */ +} CancelPacket; + +/* + * configuration paramters + */ +typedef struct { + char *listen_addresses; /* hostnames/IP addresses to listen on */ + int port; /* port # to bind */ + int pcp_port; /* PCP port # to bind */ + char *socket_dir; /* pgpool socket directory */ + char *pcp_socket_dir; /* PCP socket directory */ + int pcp_timeout; /* PCP timeout for an idle client */ + int num_init_children; /* # of children initially pre-forked */ + int child_life_time; /* if idle for this seconds, child exits */ + int connection_life_time; /* if idle for this seconds, connection closes */ + int child_max_connections; /* if max_connections received, child exits */ + int client_idle_limit; /* If client_idle_limit is n (n > 0), the client is forced to be + disconnected after n seconds idle */ + int authentication_timeout; /* maximum time in seconds to complete client authentication */ + int max_pool; /* max # of connection pool per child */ + char *logdir; /* logging directory */ + char *pid_file_name; /* pid file name */ + char *backend_socket_dir; /* Unix domain socket directory for the PostgreSQL server */ + int replication_mode; /* replication mode */ + + int log_connections; /* 0:false, 1:true - logs incoming connections */ + int log_hostname; /* 0:false, 1:true - resolve hostname */ + int enable_pool_hba; /* 0:false, 1:true - enables pool_hba.conf file authentication */ + + int load_balance_mode; /* load balance mode */ + + int replication_stop_on_mismatch; /* if there's a data mismatch between master and secondary + * start degenration to stop replication mode + */ + int replicate_select; /* if non 0, replicate SELECT statement when load balancing is disabled. */ + char **reset_query_list; /* comma separated list of quries to be issued at the end of session */ + + int print_timestamp; /* if non 0, print time stamp to each log line */ + int master_slave_mode; /* if non 0, operate in master/slave mode */ + int connection_cache; /* if non 0, cache connection pool */ + int health_check_timeout; /* health check timeout */ + int health_check_period; /* health check period */ + char *health_check_user; /* PostgreSQL user name for health check */ + char *failover_command; /* execute command when failover happens */ + char *failback_command; /* execute command when failback happens */ + char *recovery_user; /* PostgreSQL user name for online recovery */ + char *recovery_password; /* PostgreSQL user password for online recovery */ + char *recovery_1st_stage_command; /* Online recovery command in 1st stage */ + char *recovery_2nd_stage_command; /* Online recovery command in 2nd stage */ + int recovery_timeout; /* maximum time in seconds to wait for remote start-up */ + int client_idle_limit_in_recovery; /* If > 0, the client is forced to be + * disconnected after n seconds idle + * This parameter is only valid while in recovery 2nd statge */ + int insert_lock; /* if non 0, automatically lock table with INSERT to keep SERIAL + data consistency */ + int ignore_leading_white_space; /* ignore leading white spaces of each query */ + int log_statement; /* 0:false, 1: true - logs all SQL statements */ + + int parallel_mode; /* if non 0, run in parallel query mode */ + + int enable_query_cache; /* if non 0, use query cache. 0 by default */ + + char *pgpool2_hostname; /* pgpool2 hostname */ + char *system_db_hostname; /* system DB hostname */ + int system_db_port; /* system DB port number */ + char *system_db_dbname; /* system DB name */ + char *system_db_schema; /* system DB schema name */ + char *system_db_user; /* user name to access system DB */ + char *system_db_password; /* password to access system DB */ + + BackendDesc *backend_desc; /* PostgreSQL Server description. Placed on shared memory */ + + LOAD_BALANCE_STATUS load_balance_status[MAX_NUM_BACKENDS]; /* to remember which DB node is selected for load balancing */ + + /* followings do not exist in the configuration file */ + int current_slot; /* current backend slot # */ + int replication_enabled; /* replication mode enabled */ + int master_slave_enabled; /* master/slave mode enabled */ + int num_reset_queries; /* number of queries in reset_query_list */ +} POOL_CONFIG; + +#define MAX_PASSWORD_SIZE 1024 + +typedef struct { + int num; /* number of entries */ + char **names; /* parameter names */ + char **values; /* values */ +} ParamStatus; + +/* + * stream connection structure + */ +typedef struct { + int fd; /* fd for connection */ + + char *wbuf; /* write buffer for the connection */ + int wbufsz; /* write buffer size */ + int wbufpo; /* buffer offset */ + + char *hp; /* pending data buffer head address */ + int po; /* pending data offset */ + int bufsz; /* pending data buffer size */ + int len; /* pending data length */ + + char *sbuf; /* buffer for pool_read_string */ + int sbufsz; /* its size in bytes */ + + char *buf2; /* buffer for pool_read2 */ + int bufsz2; /* its size in bytes */ + + int isbackend; /* this connection is for backend if non 0 */ + int db_node_id; /* DB node id for this connection */ + + char tstate; /* transaction state (V3 only) */ + + /* + * following are used to remember when re-use the authenticated connection + */ + int auth_kind; /* 3: clear text password, 4: crypt password, 5: md5 password */ + int pwd_size; /* password (sent back from frontend) size in host order */ + char password[MAX_PASSWORD_SIZE]; /* password (sent back from frontend) */ + char salt[4]; /* password salt */ + + /* + * following are used to remember current session paramter status. + * re-used connection will need them (V3 only) + */ + ParamStatus params; + + int no_forward; /* if non 0, do not write to frontend */ + + char kind; /* kind cache */ + + /* + * frontend info needed for hba + */ + int protoVersion; + SockAddr raddr; + UserAuth auth_method; + char *auth_arg; + char *database; + char *username; +} POOL_CONNECTION; + +/* + * connection pool structure + */ +typedef struct { + StartupPacket *sp; /* startup packet info */ + int pid; /* backend pid */ + int key; /* cancel key */ + POOL_CONNECTION *con; + time_t closetime; /* absolute time in second when the connection closed + * if 0, that means the connection is under use. + */ +} POOL_CONNECTION_POOL_SLOT; + +typedef struct { + ConnectionInfo *info; /* connection info on shmem */ + POOL_CONNECTION_POOL_SLOT *slots[MAX_NUM_BACKENDS]; +} POOL_CONNECTION_POOL; + +typedef struct { + SystemDBInfo *info; + PGconn *pgconn; + /* persistent connection to the system DB */ + POOL_CONNECTION_POOL_SLOT *connection; + BACKEND_STATUS *system_db_status; +} POOL_SYSTEMDB_CONNECTION_POOL; + +/* + * for pool_clear_cache() in pool_query_cache.c + * + * used to specify the time which cached data created before it to be deleted. + */ +typedef enum { + second, seconds, + minute, minutes, + hour, hours, + day, days, + week, weeks, + month, months, + year, years, + decade, decades, + century, centuries, + millennium, millenniums +} UNIT; + +typedef struct { + int quantity; + UNIT unit; +} Interval; + +#ifdef NOT_USED +#define NUM_BACKENDS (in_load_balance? (selected_slot+1) : \ + (((!REPLICATION && !PARALLEL_MODE)||master_slave_dml)? Req_info->master_node_id+1: \ + pool_config->backend_desc->num_backends)) +#endif +/* NUM_BACKENDS now always returns actual number of backends if not in_load_balance */ +#define NUM_BACKENDS (in_load_balance ? (selected_slot+1) : pool_config->backend_desc->num_backends) +#define BACKEND_INFO(backend_id) (pool_config->backend_desc->backend_info[(backend_id)]) +#define LOAD_BALANCE_STATUS(backend_id) (pool_config->load_balance_status[(backend_id)]) +/* if RAW_MODE, VALID_BACKEND returns the selected node only */ +#define VALID_BACKEND(backend_id) \ + (RAW_MODE ? (backend_id) == MASTER_NODE_ID : \ + (in_load_balance ? LOAD_BALANCE_STATUS(backend_id) == LOAD_SELECTED : \ + ((BACKEND_INFO(backend_id).backend_status == CON_UP) || \ + (BACKEND_INFO(backend_id).backend_status == CON_CONNECT_WAIT)))) +#define CONNECTION_SLOT(p, slot) ((p)->slots[(slot)]) +#define CONNECTION(p, slot) (CONNECTION_SLOT(p, slot)->con) +#define MASTER_CONNECTION(p) ((p)->slots[MASTER_NODE_ID]) +#define MASTER_NODE_ID (in_load_balance? selected_slot : Req_info->master_node_id) +#define IS_MASTER_NODE_ID(node_id) (MASTER_NODE_ID == (node_id)) +//#define SECONDARY_CONNECTION(p) ((p)->slots[1]) +#define REPLICATION (pool_config->replication_enabled) +#define MASTER_SLAVE (pool_config->master_slave_enabled) +#define DUAL_MODE (REPLICATION || MASTER_SLAVE) +#define PARALLEL_MODE (pool_config->parallel_mode) +#define RAW_MODE (!REPLICATION && !PARALLEL_MODE && !MASTER_SLAVE) +#define MASTER(p) MASTER_CONNECTION(p)->con +//#define SECONDARY(p) SECONDARY_CONNECTION(p)->con +#define MAJOR(p) MASTER_CONNECTION(p)->sp->major +#define TSTATE(p) MASTER(p)->tstate +#define SYSDB_INFO (system_db_info->info) +#define SYSDB_CONNECTION (system_db_info->connection) +#define SYSDB_STATUS (*system_db_info->system_db_status) + +#define Max(x, y) ((x) > (y) ? (x) : (y)) +#define Min(x, y) ((x) < (y) ? (x) : (y)) + +#define LOCK_COMMENT "/*INSERT LOCK*/" +#define LOCK_COMMENT_SZ (sizeof(LOCK_COMMENT)-1) +#define NO_LOCK_COMMENT "/*NO INSERT LOCK*/" +#define NO_LOCK_COMMENT_SZ (sizeof(NO_LOCK_COMMENT)-1) + +#define MAX_NUM_SEMAPHORES 3 +#define CONN_COUNTER_SEM 0 +#define REQUEST_INFO_SEM 1 + +#define MY_PROCESS_INFO (pids[my_proc_id]) + +/* + * number specified when semaphore is locked/unlocked + */ +typedef enum SemNum +{ + SEMNUM_CONFIG, + SEMNUM_NODES, + SEMNUM_PROCESSES +} SemNum; + +/* + * up/down request info area in shared memory + */ +typedef enum { + NODE_UP_REQUEST = 0, + NODE_DOWN_REQUEST, + NODE_RECOVERY_REQUEST, + CLOSE_IDLE_REQUEST +} POOL_REQUEST_KIND; + +typedef struct { + POOL_REQUEST_KIND kind; /* request kind */ + int node_id[MAX_NUM_BACKENDS]; /* request node id */ + int master_node_id; /* the youngest node id which is not in down status */ + int conn_counter; +} POOL_REQUEST_INFO; + +/* description of row. corresponding to RowDescription message */ +typedef struct { + char *attrname; /* attribute name */ + int oid; /* 0 or non 0 if it's a table oblect */ + int attrnumber; /* attribute number starting with 1. 0 if it's not a table */ + int typeoid; /* data type oid */ + int size; /* data length minus means variable data type */ + int mod; /* data type modifier */ +} AttrInfo; + +typedef struct { + int num_attrs; /* number of attributes */ + AttrInfo *attrinfo; +} RowDesc; + +typedef struct { + RowDesc *rowdesc; /* attribute info */ + int numrows; /* number of rows */ + int *nullflags; /* if NULL, -1 or length of the string excluding termination null */ + char **data; /* actual row character data terminated with null */ +} POOL_SELECT_RESULT; + +/* + * global variables + */ +extern pid_t mypid; /* parent pid */ +extern POOL_CONFIG *pool_config; /* configuration values */ +extern POOL_CONNECTION_POOL *pool_connection_pool; /* connection pool */ +extern volatile sig_atomic_t backend_timer_expired; /* flag for connection closed timer is expired */ +extern long int weight_master; /* normalized weight of master (0-RAND_MAX range) */ +extern int my_proc_id; /* process table id (!= UNIX's PID) */ +extern POOL_SYSTEMDB_CONNECTION_POOL *system_db_info; /* systemdb */ +extern ProcessInfo *pids; /* shmem process information table */ +extern ConnectionInfo *con_info; /* shmem connection info table */ +extern int in_load_balance; /* non 0 if in load balance mode */ +extern int selected_slot; /* selected DB node for load balance */ +extern int master_slave_dml; /* non 0 if master/slave mode is specified in config file */ +extern POOL_REQUEST_INFO *Req_info; +extern volatile sig_atomic_t *InRecovery; +extern char remote_ps_data[]; /* used for set_ps_display */ +extern volatile sig_atomic_t got_sighup; + +#define QUERY_STRING_BUFFER_LEN 1024 +extern char query_string_buffer[]; /* last query string sent to simpleQuery() */ + +/* + * public functions + */ +extern char *get_config_file_name(void); +extern char *get_hba_file_name(void); +#ifdef __GNUC__ +extern void pool_error(const char *fmt,...) + __attribute__((format (printf, 1, 2))); +extern void pool_debug(const char *fmt,...) + __attribute__((format (printf, 1, 2))); +extern void pool_log(const char *fmt,...) + __attribute__((format (printf, 1, 2))); +#else +extern void pool_error(const char *fmt,...); +extern void pool_debug(const char *fmt,...); +extern void pool_log(const char *fmt,...); +#endif +extern int pool_init_config(void); +extern int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context); +extern void do_child(int unix_fd, int inet_fd); +extern void pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file); +extern int select_load_balancing_node(void); +extern int pool_init_cp(void); +extern POOL_STATUS pool_process_query(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + int connection_reuse, + int first_ready_for_query_received); + +extern POOL_CONNECTION *pool_open(int fd); +extern void pool_close(POOL_CONNECTION *cp); +extern int pool_read(POOL_CONNECTION *cp, void *buf, int len); +extern char *pool_read2(POOL_CONNECTION *cp, int len); +extern int pool_write(POOL_CONNECTION *cp, void *buf, int len); +extern int pool_flush(POOL_CONNECTION *cp); +extern int pool_flush_it(POOL_CONNECTION *cp); +extern int pool_write_and_flush(POOL_CONNECTION *cp, void *buf, int len); +extern char *pool_read_string(POOL_CONNECTION *cp, int *len, int line); +extern int pool_unread(POOL_CONNECTION *cp, void *data, int len); + +extern int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern int pool_do_reauth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp); + +extern int pool_init_cp(void); +extern POOL_CONNECTION_POOL *pool_create_cp(void); +extern POOL_CONNECTION_POOL *pool_get_cp(char *user, char *database, int protoMajor, int check_socket); +extern void pool_discard_cp(char *user, char *database, int protoMajor); +extern void pool_backend_timer(void); + +extern POOL_STATUS ErrorResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS NoticeResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern void notice_backend_error(int node_id); +extern void degenerate_backend_set(int *node_id_set, int count); +extern void send_failback_request(int node_id); + +extern void pool_connection_pool_timer(POOL_CONNECTION_POOL *backend); +extern RETSIGTYPE pool_backend_timer_handler(int sig); + +extern int connect_inet_domain_socket(int secondary_backend); +extern int connect_unix_domain_socket(int secondary_backend); +extern int connect_inet_domain_socket_by_port(char *host, int port); +extern int connect_unix_domain_socket_by_port(int port, char *socket_dir); + +extern void pool_set_timeout(int timeoutval); +extern int pool_check_fd(POOL_CONNECTION *cp); + +extern void pool_send_frontend_exits(POOL_CONNECTION_POOL *backend); + +extern int pool_read_message_length(POOL_CONNECTION_POOL *cp); +extern int *pool_read_message_length2(POOL_CONNECTION_POOL *cp); +extern signed char pool_read_kind(POOL_CONNECTION_POOL *cp); +extern int pool_read_int(POOL_CONNECTION_POOL *cp); + +extern POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); + +extern int pool_init_params(ParamStatus *params); +extern void pool_discard_params(ParamStatus *params); +extern char *pool_find_name(ParamStatus *params, char *name, int *pos); +extern int pool_get_param(ParamStatus *params, int index, char **name, char **value); +extern int pool_add_param(ParamStatus *params, char *name, char *value); +extern void pool_param_debug_print(ParamStatus *params); + +extern void pool_send_error_message(POOL_CONNECTION *frontend, int protoMajor, + char *code, + char *message, + char *detail, + char *hint, + char *file, + int line); +extern void pool_send_readyforquery(POOL_CONNECTION *frontend); +extern int send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp); +extern void pool_free_startup_packet(StartupPacket *sp); +extern void child_exit(int code); + +extern int health_check(void); +extern int system_db_health_check(void); + +extern void init_prepared_list(void); + +extern void *pool_shared_memory_create(size_t size); +extern void pool_shmem_exit(int code); + +extern int pool_semaphore_create(int numSems); +extern void pool_semaphore_lock(int semNum); +extern void pool_semaphore_unlock(int semNum); + +extern BackendInfo *pool_get_node_info(int node_number); +extern int pool_get_node_count(void); +extern int *pool_get_process_list(int *array_size); +extern ProcessInfo *pool_get_process_info(pid_t pid); +extern SystemDBInfo *pool_get_system_db_info(void); +extern POOL_STATUS OneNode_do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *query, char *database); + +extern POOL_CONNECTION_POOL_SLOT *make_persistent_db_connection( + char *hostname, int port, char *dbname, char *user, char *password); + +extern POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result); + +/* define pool_system.c */ +extern POOL_CONNECTION_POOL_SLOT *pool_system_db_connection(void); +extern DistDefInfo *pool_get_dist_def_info (char * dbname, char * schema_name, char * table_name); +extern RepliDefInfo *pool_get_repli_def_info (char * dbname, char * schema_name, char * table_name); +extern int pool_get_id (DistDefInfo *info, const char * value); +extern int system_db_connect (void); +extern int pool_memset_system_db_info (SystemDBInfo *info); +extern void pool_close_libpq_connection(void); + +/* pool_query_cache.c */ +extern POOL_STATUS pool_query_cache_lookup(POOL_CONNECTION *frontend, char *query, char *database, char tstate); +extern int pool_query_cache_register(char kind, POOL_CONNECTION *frontend, char *database, char *data, int data_len, char *query); +extern int pool_query_cache_table_exists(void); +extern int pool_clear_cache_by_time(Interval *interval, int size); + +/* pool_hba.c */ +extern void load_hba(char *hbapath); +extern void ClientAuthentication(POOL_CONNECTION *frontend); + +/* pool_ip.c */ +extern void pool_getnameinfo_all(SockAddr *saddr, char *remote_host, char *remote_port); + +/* strlcpy.c */ +extern size_t strlcpy(char *dst, const char *src, size_t siz); + +/* ps_status.c */ +extern bool update_process_title; +extern char **save_ps_display_args(int argc, char **argv); +extern void init_ps_display(const char *username, const char *dbname, + const char *host_info, const char *initial_str); +extern void set_ps_display(const char *activity, bool force); +extern const char *get_ps_display(int *displen); + +/* recovery.c */ +extern int start_recovery(int recovery_node); +extern void finish_recovery(void); + +/* child.c */ +extern void pool_set_nonblock(int fd); +extern void pool_unset_nonblock(int fd); +extern void cancel_request(CancelPacket *sp); + +#endif /* POOL_H */ diff --git a/pool_auth.c b/pool_auth.c new file mode 100644 index 0000000..cd5bf42 --- /dev/null +++ b/pool_auth.c @@ -0,0 +1,1133 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_auth.c,v 1.15.2.2 2009/09/23 02:03:12 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_auth.c: authenticaton stuff + * +*/ + +#include "pool.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_PARAM_H +#include +#endif +#include +#include + +#define AUTHFAIL_ERRORCODE "28000" + +static POOL_STATUS pool_send_auth_ok(POOL_CONNECTION *frontend, int pid, int key, int protoMajor); +static int do_clear_text_password(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor); +static int do_crypt(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor); +static int do_md5(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor); + +/* +* do authentication against backend. if success return 0 otherwise non 0. +*/ +int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) +{ + signed char kind; + int pid; + int key; + int protoMajor; + int length; + int authkind; + int i; + StartupPacket *sp; + + protoMajor = MAJOR(cp); + + kind = pool_read_kind(cp); + if (kind < 0) + { + return -1; + } + + /* error response? */ + if (kind == 'E') + { + /* we assume error response at this stage is likely version + * protocol mismatch (v3 frontend vs. v2 backend). So we throw + * a V2 protocol error response in the hope that v3 frontend + * will negotiate again using v2 protocol. + */ + pool_log("pool_do_auth: maybe protocol version mismatch (current version %d)", protoMajor); + ErrorResponse(frontend, cp); + return -1; + } + else if (kind != 'R') + { + pool_error("pool_do_auth: expect \"R\" got %c", kind); + return -1; + } + + /* + * message length (v3 only) + */ + if (protoMajor == PROTO_MAJOR_V3 && pool_read_message_length(cp) < 0) + { + pool_error("Failed to read the authentication packet length. \ +This is likely caused by the inconsistency of auth method among DB nodes. \ +In this case you can check the previous error messages (hint: length field) \ +from pool_read_message_length and recheck the pg_hba.conf settings."); + return -1; + } + + /* + * read authentication request kind. + * + * 0: authentication ok + * 1: kerberos v4 + * 2: kerberos v5 + * 3: clear text password + * 4: crypt password + * 5: md5 password + * 6: scm credential + * + * in replication mode, we only support kind = 0, 3. this is because to "salt" + * cannot be replicated. + * in non replication mode, we support kind = 0, 3, 4, 5 + */ + + authkind = pool_read_int(cp); + if (authkind < 0) + { + pool_error("pool_do_auth: read auth kind failed"); + return -1; + } + + authkind = ntohl(authkind); + + /* trust? */ + if (authkind == 0) + { + int msglen; + + pool_write(frontend, "R", 1); + + if (protoMajor == PROTO_MAJOR_V3) + { + msglen = htonl(8); + pool_write(frontend, &msglen, sizeof(msglen)); + } + + msglen = htonl(0); + if (pool_write_and_flush(frontend, &msglen, sizeof(msglen)) < 0) + { + return -1; + } + MASTER(cp)->auth_kind = 0; + } + + /* clear text password authentication? */ + else if (authkind == 3) + { + for (i=0;i 1) + { + pool_send_error_message(frontend, protoMajor, AUTHFAIL_ERRORCODE, + "MD5 authentication is unsupported in replication, master-slave and parallel modes.", + "", + "check pg_hba.conf", + __FILE__, __LINE__); + return -1; + } + + for (i=0;ipid = cp->info[i].pid = pid; + + /* read key */ + if (pool_read(CONNECTION(cp, i), &key, sizeof(key)) < 0) + { + pool_error("pool_do_auth: failed to read key in slot %d", i); + return -1; + } + CONNECTION_SLOT(cp, i)->key = cp->info[i].key = key; + + } + } + + sp = MASTER_CONNECTION(cp)->sp; + cp->info->major = sp->major; + cp->info->minor = sp->minor; + strncpy(cp->info->database, sp->database, sizeof(cp->info->database) - 1); + strncpy(cp->info->user, sp->user, sizeof(cp->info->user) - 1); + cp->info->counter = 1; + + return pool_send_auth_ok(frontend, pid, key, protoMajor); +} + +/* +* do re-authentication for reused connection. if success return 0 otherwise non 0. +*/ +int pool_do_reauth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp) +{ + int status; + int protoMajor; + + protoMajor = MAJOR(cp); + + switch(MASTER(cp)->auth_kind) + { + case 0: + /* trust */ + status = 0; + break; + + case 3: + /* clear text password */ + status = do_clear_text_password(MASTER(cp), frontend, 1, protoMajor); + break; + + case 4: + /* crypt password */ + status = do_crypt(MASTER(cp), frontend, 1, protoMajor); + break; + + case 5: + /* md5 password */ + status = do_md5(MASTER(cp), frontend, 1, protoMajor); + break; + + default: + pool_error("pool_do_reauth: unknown authentication request code %d", + MASTER(cp)->auth_kind); + return -1; + } + + if (status == 0) + { + int msglen; + + pool_write(frontend, "R", 1); + + if (protoMajor == PROTO_MAJOR_V3) + { + msglen = htonl(8); + pool_write(frontend, &msglen, sizeof(msglen)); + } + + msglen = htonl(0); + if (pool_write_and_flush(frontend, &msglen, sizeof(msglen)) < 0) + { + return -1; + } + } + else + { + pool_debug("pool_do_reauth: authentication failed"); + return -1; + } + + return (pool_send_auth_ok(frontend, MASTER_CONNECTION(cp)->pid, MASTER_CONNECTION(cp)->key, protoMajor) != POOL_CONTINUE); +} + +/* +* send authentication ok to frontend. if success return 0 otherwise non 0. +*/ +static POOL_STATUS pool_send_auth_ok(POOL_CONNECTION *frontend, int pid, int key, int protoMajor) +{ + char kind; + int len; + +#ifdef NOT_USED + if (protoMajor == PROTO_MAJOR_V2) + { + /* return "Authentication OK" to the frontend */ + kind = 'R'; + pool_write(frontend, &kind, 1); + len = htonl(0); + if (pool_write_and_flush(frontend, &len, sizeof(len)) < 0) + { + return -1; + } + } +#endif + + /* send backend key data */ + kind = 'K'; + pool_write(frontend, &kind, 1); + if (protoMajor == PROTO_MAJOR_V3) + { + len = htonl(12); + pool_write(frontend, &len, sizeof(len)); + } + + pool_debug("pool_send_auth_ok: send pid %d to frontend", ntohl(pid)); + + pool_write(frontend, &pid, sizeof(pid)); + if (pool_write_and_flush(frontend, &key, sizeof(key)) < 0) + { + return -1; + } + + return 0; +} + +/* + * perform clear text password authetication + */ +static int do_clear_text_password(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor) +{ + static int size; + static char password[MAX_PASSWORD_SIZE]; + char response; + int kind; + int len; + + /* master? */ + if (IS_MASTER_NODE_ID(backend->db_node_id)) + { + pool_write(frontend, "R", 1); /* authenticaton */ + if (protoMajor == PROTO_MAJOR_V3) + { + len = htonl(8); + pool_write(frontend, &len, sizeof(len)); + } + kind = htonl(3); /* clear text password authentication */ + pool_write_and_flush(frontend, &kind, sizeof(kind)); /* indicating clear text password authentication */ + + /* read password packet */ + if (protoMajor == PROTO_MAJOR_V2) + { + if (pool_read(frontend, &size, sizeof(size))) + { + pool_error("do_clear_text_password: failed to read password packet size"); + return -1; + } + } + else + { + char k; + + if (pool_read(frontend, &k, sizeof(k))) + { + pool_error("do_clear_text_password: failed to read password packet \"p\""); + return -1; + } + if (k != 'p') + { + pool_error("do_clear_text_password: password packet does not start with \"p\""); + return -1; + } + if (pool_read(frontend, &size, sizeof(size))) + { + pool_error("do_clear_text_password: failed to read password packet size"); + return -1; + } + } + + if ((ntohl(size) - 4) > sizeof(password)) + { + pool_error("do_clear_text_password: password is too long (size: %d)", ntohl(size) - 4); + return -1; + } + + if (pool_read(frontend, password, ntohl(size) - 4)) + { + pool_error("do_clear_text_password: failed to read password (size: %d)", ntohl(size) - 4); + return -1; + } + } + + /* connection reusing? */ + if (reauth) + { + if ((ntohl(size) - 4) != backend->pwd_size) + { + pool_debug("do_clear_text_password; password size does not match in re-authetication"); + return -1; + } + + if (memcmp(password, backend->password, backend->pwd_size) != 0) + { + pool_debug("do_clear_text_password; password does not match in re-authetication"); + return -1; + } + + return 0; + } + + /* send password packet to backend */ + if (protoMajor == PROTO_MAJOR_V3) + pool_write(backend, "p", 1); + pool_write(backend, &size, sizeof(size)); + pool_write_and_flush(backend, password, ntohl(size) -4); + if (pool_read(backend, &response, sizeof(response))) + { + pool_error("do_clear_text_password: failed to read authentication response"); + return -1; + } + + if (response != 'R') + { + pool_debug("do_clear_text_password: backend does not return R while processing clear text password authentication"); + return -1; + } + + if (protoMajor == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len))) + { + pool_error("do_clear_text_password: failed to read authentication packet size"); + return -1; + } + + if (ntohl(len) != 8) + { + pool_error("do_clear_text_password: incorrect authentication packet size (%d)", ntohl(len)); + return -1; + } + } + + /* expect to read "Authentication OK" response. kind should be 0... */ + if (pool_read(backend, &kind, sizeof(kind))) + { + pool_debug("do_clear_text_password: failed to read Authentication OK response"); + return -1; + } + + /* if authenticated, save info */ + if (!reauth && kind == 0) + { + if (IS_MASTER_NODE_ID(backend->db_node_id)) + { + int msglen; + + pool_write(frontend, "R", 1); + + if (protoMajor == PROTO_MAJOR_V3) + { + msglen = htonl(8); + pool_write(frontend, &msglen, sizeof(msglen)); + } + + msglen = htonl(0); + if (pool_write_and_flush(frontend, &msglen, sizeof(msglen)) < 0) + { + return -1; + } + } + + backend->auth_kind = 3; + backend->pwd_size = ntohl(size) - 4; + memcpy(backend->password, password, backend->pwd_size); + } + return kind; +} + +/* + * perform crypt authetication + */ +static int do_crypt(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor) +{ + char salt[2]; + static int size; + static char password[MAX_PASSWORD_SIZE]; + char response; + int kind; + int len; + + if (!reauth) + { + /* read salt */ + if (pool_read(backend, salt, sizeof(salt))) + { + pool_error("do_crypt: failed to read salt"); + return -1; + } + } + else + { + memcpy(salt, backend->salt, sizeof(salt)); + } + + /* master? */ + if (IS_MASTER_NODE_ID(backend->db_node_id)) + { + pool_write(frontend, "R", 1); /* authenticaton */ + if (protoMajor == PROTO_MAJOR_V3) + { + len = htonl(10); + pool_write(frontend, &len, sizeof(len)); + } + kind = htonl(4); /* crypt authentication */ + pool_write(frontend, &kind, sizeof(kind)); /* indicating crypt authentication */ + pool_write_and_flush(frontend, salt, sizeof(salt)); /* salt */ + + /* read password packet */ + if (protoMajor == PROTO_MAJOR_V2) + { + if (pool_read(frontend, &size, sizeof(size))) + { + pool_error("do_crypt: failed to read password packet size"); + return -1; + } + } + else + { + char k; + + if (pool_read(frontend, &k, sizeof(k))) + { + pool_error("do_crypt_password: failed to read password packet \"p\""); + return -1; + } + if (k != 'p') + { + pool_error("do_crypt_password: password packet does not start with \"p\""); + return -1; + } + if (pool_read(frontend, &size, sizeof(size))) + { + pool_error("do_crypt_password: failed to read password packet size"); + return -1; + } + } + + if ((ntohl(size) - 4) > sizeof(password)) + { + pool_error("do_crypt: password is too long(size: %d)", ntohl(size) - 4); + return -1; + } + + if (pool_read(frontend, password, ntohl(size) - 4)) + { + pool_error("do_crypt: failed to read password (size: %d)", ntohl(size) - 4); + return -1; + } + } + + /* connection reusing? */ + if (reauth) + { + pool_debug("size: %d saved_size: %d", (ntohl(size) - 4), backend->pwd_size); + if ((ntohl(size) - 4) != backend->pwd_size) + { + pool_debug("do_crypt: password size does not match in re-authentication"); + return -1; + } + + if (memcmp(password, backend->password, backend->pwd_size) != 0) + { + pool_debug("do_crypt: password does not match in re-authentication"); + return -1; + } + + return 0; + } + + /* send password packet to backend */ + if (protoMajor == PROTO_MAJOR_V3) + pool_write(backend, "p", 1); + pool_write(backend, &size, sizeof(size)); + pool_write_and_flush(backend, password, ntohl(size) -4); + if (pool_read(backend, &response, sizeof(response))) + { + pool_error("do_crypt: failed to read authentication response"); + return -1; + } + + if (response != 'R') + { + pool_debug("do_crypt: backend does not return R while processing crypt authentication(%02x) DB node id: %d", response, backend->db_node_id); + return -1; + } + + if (protoMajor == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len))) + { + pool_error("do_clear_text_password: failed to read authentication packet size"); + return -1; + } + + if (ntohl(len) != 8) + { + pool_error("do_clear_text_password: incorrect authentication packet size (%d)", ntohl(len)); + return -1; + } + } + + /* expect to read "Authentication OK" response. kind should be 0... */ + if (pool_read(backend, &kind, sizeof(kind))) + { + pool_debug("do_crypt: failed to read Authentication OK response"); + return -1; + } + + /* if authenticated, save info */ + if (!reauth && kind == 0) + { + int msglen; + + pool_write(frontend, "R", 1); + + if (protoMajor == PROTO_MAJOR_V3) + { + msglen = htonl(8); + pool_write(frontend, &msglen, sizeof(msglen)); + } + + msglen = htonl(0); + if (pool_write_and_flush(frontend, &msglen, sizeof(msglen)) < 0) + { + return -1; + } + + backend->auth_kind = 4; + backend->pwd_size = ntohl(size) - 4; + memcpy(backend->password, password, backend->pwd_size); + memcpy(backend->salt, salt, sizeof(salt)); + } + return kind; +} + +/* + * perform MD5 authetication + */ +static int do_md5(POOL_CONNECTION *backend, POOL_CONNECTION *frontend, int reauth, int protoMajor) +{ + char salt[4]; + static int size; + static char password[MAX_PASSWORD_SIZE]; + char response; + int kind; + int len; + + if (!reauth) + { + /* read salt */ + if (pool_read(backend, salt, sizeof(salt))) + { + pool_error("do_md5: failed to read salt"); + return -1; + } + pool_debug("DB node id: %d salt: %hhx%hhx%hhx%hhx", backend->db_node_id, + salt[0], salt[1], salt[2], salt[3]); + } + else + { + memcpy(salt, backend->salt, sizeof(salt)); + } + + /* master? */ + if (IS_MASTER_NODE_ID(backend->db_node_id)) + { + pool_write(frontend, "R", 1); /* authenticaton */ + if (protoMajor == PROTO_MAJOR_V3) + { + len = htonl(12); + pool_write(frontend, &len, sizeof(len)); + } + kind = htonl(5); + pool_write(frontend, &kind, sizeof(kind)); /* indicating MD5 */ + pool_write_and_flush(frontend, salt, sizeof(salt)); /* salt */ + + /* read password packet */ + if (protoMajor == PROTO_MAJOR_V2) + { + if (pool_read(frontend, &size, sizeof(size))) + { + pool_error("do_md5: failed to read password packet size"); + return -1; + } + } + else + { + char k; + + if (pool_read(frontend, &k, sizeof(k))) + { + pool_error("do_md5_password: failed to read password packet \"p\""); + return -1; + } + if (k != 'p') + { + pool_error("do_md5_password: password packet does not start with \"p\""); + return -1; + } + if (pool_read(frontend, &size, sizeof(size))) + { + pool_error("do_md5_password: failed to read password packet size"); + return -1; + } + } + + if ((ntohl(size) - 4) > sizeof(password)) + { + pool_error("do_md5: password is too long(size: %d)", ntohl(size) - 4); + return -1; + } + + if (pool_read(frontend, password, ntohl(size) - 4)) + { + pool_error("do_md5: failed to read password (size: %d)", ntohl(size) - 4); + return -1; + } + } + + /* connection reusing? */ + if (reauth) + { + if ((ntohl(size) - 4) != backend->pwd_size) + { + pool_debug("do_md5; password size does not match in re-authentication"); + return -1; + } + + if (memcmp(password, backend->password, backend->pwd_size) != 0) + { + pool_debug("do_md5; password does not match in re-authentication"); + return -1; + } + + return 0; + } + + /* send password packet to backend */ + if (protoMajor == PROTO_MAJOR_V3) + pool_write(backend, "p", 1); + pool_write(backend, &size, sizeof(size)); + pool_write_and_flush(backend, password, ntohl(size) -4); + if (pool_read(backend, &response, sizeof(response))) + { + pool_error("do_md5: failed to read authentication response"); + return -1; + } + + if (response != 'R') + { + pool_debug("do_md5: backend does not return R while processing MD5 authentication %c", response); + return -1; + } + + if (protoMajor == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len))) + { + pool_error("do_md5: failed to read authentication packet size"); + return -1; + } + + if (ntohl(len) != 8) + { + pool_error("do_clear_text_password: incorrect authentication packet size (%d)", ntohl(len)); + return -1; + } + } + + /* expect to read "Authentication OK" response. kind should be 0... */ + if (pool_read(backend, &kind, sizeof(kind))) + { + pool_debug("do_md5: failed to read Authentication OK response"); + return -1; + } + + /* if authenticated, save info */ + if (!reauth && kind == 0) + { + int msglen; + + pool_write(frontend, "R", 1); + + if (protoMajor == PROTO_MAJOR_V3) + { + msglen = htonl(8); + pool_write(frontend, &msglen, sizeof(msglen)); + } + + msglen = htonl(0); + if (pool_write_and_flush(frontend, &msglen, sizeof(msglen)) < 0) + { + return -1; + } + + backend->auth_kind = 5; + backend->pwd_size = ntohl(size) - 4; + memcpy(backend->password, password, backend->pwd_size); + memcpy(backend->salt, salt, sizeof(salt)); + } + return kind; +} + +/* + * read message length (V3 only) + */ +int pool_read_message_length(POOL_CONNECTION_POOL *cp) +{ + int status; + int length, length0; + int i; + + /* read message from master node */ + status = pool_read(CONNECTION(cp, MASTER_NODE_ID), &length0, sizeof(length0)); + if (status < 0) + { + pool_error("pool_read_message_length: error while reading message length in slot %d", MASTER_NODE_ID); + return -1; + } + length0 = ntohl(length0); + pool_debug("pool_read_message_length: slot: %d length: %d", MASTER_NODE_ID, length0); + + for (i=0;i +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 11 +#define YY_END_OF_BUFFER 12 +static yyconst short int yy_accept[38] = + { 0, + 0, 0, 12, 10, 2, 1, 10, 10, 10, 8, + 7, 7, 9, 4, 2, 0, 3, 0, 5, 0, + 8, 7, 7, 8, 0, 0, 6, 4, 4, 0, + 5, 0, 0, 8, 7, 6, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 4, 1, 1, 1, 5, 1, + 1, 1, 6, 1, 7, 8, 9, 10, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 9, 1, 1, + 12, 1, 1, 1, 13, 13, 13, 13, 14, 13, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 1, 16, 1, 1, 17, 1, 13, 13, 13, 13, + + 14, 13, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 18, + 15, 15, 1, 1, 1, 1, 1, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15 + } ; + +static yyconst int yy_meta[19] = + { 0, + 1, 1, 2, 1, 1, 1, 3, 3, 3, 4, + 4, 1, 5, 4, 3, 1, 3, 3 + } ; + +static yyconst short int yy_base[45] = + { 0, + 0, 0, 61, 86, 58, 86, 55, 14, 23, 43, + 10, 46, 86, 28, 47, 40, 86, 16, 86, 22, + 28, 0, 0, 0, 40, 0, 24, 45, 0, 24, + 39, 43, 12, 14, 0, 22, 86, 62, 67, 22, + 70, 75, 77, 80 + } ; + +static yyconst short int yy_def[45] = + { 0, + 37, 1, 37, 37, 37, 37, 38, 39, 37, 40, + 9, 9, 37, 41, 37, 38, 37, 39, 37, 42, + 40, 11, 12, 21, 37, 43, 44, 41, 28, 39, + 39, 42, 37, 37, 43, 44, 0, 37, 37, 37, + 37, 37, 37, 37 + } ; + +static yyconst short int yy_nxt[105] = + { 0, + 4, 5, 6, 7, 8, 9, 9, 10, 4, 11, + 12, 13, 14, 14, 14, 4, 14, 14, 19, 23, + 19, 34, 34, 34, 34, 24, 31, 26, 19, 20, + 21, 20, 22, 23, 27, 27, 27, 32, 36, 20, + 36, 25, 17, 19, 29, 33, 33, 31, 15, 34, + 34, 27, 27, 27, 20, 23, 25, 17, 32, 15, + 37, 29, 16, 16, 16, 16, 16, 18, 37, 18, + 18, 18, 28, 28, 28, 30, 37, 30, 30, 30, + 35, 35, 27, 27, 27, 3, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + + 37, 37, 37, 37 + } ; + +static yyconst short int yy_chk[105] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 11, + 18, 33, 33, 34, 34, 40, 20, 11, 30, 8, + 9, 18, 9, 9, 14, 14, 14, 20, 36, 30, + 27, 21, 16, 31, 14, 25, 25, 32, 15, 25, + 25, 28, 28, 28, 31, 12, 10, 7, 32, 5, + 3, 28, 38, 38, 38, 38, 38, 39, 0, 39, + 39, 39, 41, 41, 41, 42, 0, 42, 42, 42, + 43, 43, 44, 44, 44, 37, 37, 37, 37, 37, + 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, + + 37, 37, 37, 37 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "pool_config.l" +#define INITIAL 0 +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_config.c,v 1.27.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_config.l: read configuration file + * + */ +#line 27 "pool_config.l" + +#include "pool.h" + +#include +#include +#include + +#define CHECK_CONTEXT(mask, context) ((mask) & (context)) + +/* to shut off compiler warnings */ +int yylex(void); + +POOL_CONFIG *pool_config; /* configuration values */ +POOL_SYSTEMDB_CONNECTION_POOL *system_db_info; +static unsigned Lineno; +static char *default_reset_query_list[] = {"ABORT", "RESET ALL", "SET SESSION AUTHORIZATION DEFAULT"}; + +typedef enum { + POOL_KEY = 1, + POOL_INTEGER, + POOL_REAL, + POOL_STRING, + POOL_UNQUOTED_STRING, + POOL_EQUALS, + POOL_EOL, + POOL_PARSE_ERROR +} POOL_TOKEN; + +static char *extract_string(char *value, POOL_TOKEN token); +static char **extract_string_tokens(char *str, char *delim, int *n); +static int eval_logical(char *str); +static void clear_host_entry(int slot); + +#define YY_NEVER_INTERACTIVE 1 +#define YY_NO_UNPUT 1 +#line 460 "pool_config.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 84 "pool_config.l" + + +#line 614 "pool_config.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 38 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 86 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 86 "pool_config.l" +Lineno++; return POOL_EOL; + YY_BREAK +case 2: +YY_RULE_SETUP +#line 87 "pool_config.l" +/* eat whitespace */ + YY_BREAK +case 3: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 88 "pool_config.l" +/* eat comment */ + YY_BREAK +case 4: +YY_RULE_SETUP +#line 90 "pool_config.l" +return POOL_KEY; + YY_BREAK +case 5: +YY_RULE_SETUP +#line 91 "pool_config.l" +return POOL_STRING; + YY_BREAK +case 6: +YY_RULE_SETUP +#line 92 "pool_config.l" +return POOL_UNQUOTED_STRING; + YY_BREAK +case 7: +YY_RULE_SETUP +#line 93 "pool_config.l" +return POOL_INTEGER; + YY_BREAK +case 8: +YY_RULE_SETUP +#line 94 "pool_config.l" +return POOL_REAL; + YY_BREAK +case 9: +YY_RULE_SETUP +#line 95 "pool_config.l" +return POOL_EQUALS; + YY_BREAK +case 10: +YY_RULE_SETUP +#line 97 "pool_config.l" +return POOL_PARSE_ERROR; + YY_BREAK +case 11: +YY_RULE_SETUP +#line 99 "pool_config.l" +ECHO; + YY_BREAK +#line 755 "pool_config.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 38 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 38 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 37); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 99 "pool_config.l" + + +int pool_init_config(void) +{ + int res; + static char localhostname[256]; + int i; + + pool_config = malloc(sizeof(POOL_CONFIG)); + if (pool_config == NULL) + { + pool_error("failed to allocate pool_config"); + return(-1); + } + + memset(pool_config, 0, sizeof(POOL_CONFIG)); + + pool_config->backend_desc = pool_shared_memory_create(sizeof(BackendDesc)); + if (pool_config->backend_desc == NULL) + { + pool_error("failed to allocate pool_config->backend_desc"); + return -1; + } + + /* set hardcoded default values */ + pool_config->listen_addresses = "localhost"; + pool_config->port = 9999; + pool_config->pcp_port = 9898; + pool_config->socket_dir = DEFAULT_SOCKET_DIR; + pool_config->pcp_socket_dir = DEFAULT_SOCKET_DIR; + pool_config->backend_socket_dir = DEFAULT_SOCKET_DIR; + pool_config->pcp_timeout = 10; + pool_config->num_init_children = 32; + pool_config->max_pool = 4; + pool_config->child_life_time = 300; + pool_config->client_idle_limit = 0; + pool_config->connection_life_time = 0; + pool_config->child_max_connections = 0; + pool_config->authentication_timeout = 60; + pool_config->logdir = DEFAULT_LOGDIR; + pool_config->pid_file_name = DEFAULT_PID_FILE_NAME; + pool_config->log_statement = 0; + pool_config->log_connections = 0; + pool_config->log_hostname = 0; + pool_config->enable_pool_hba = 0; + + pool_config->replication_mode = 0; + pool_config->load_balance_mode = 0; + pool_config->replication_stop_on_mismatch = 0; + pool_config->replicate_select = 0; + pool_config->reset_query_list = default_reset_query_list; + pool_config->num_reset_queries = sizeof(default_reset_query_list)/sizeof(char *); + pool_config->reset_query_list = default_reset_query_list; + pool_config->print_timestamp = 1; + pool_config->master_slave_mode = 0; + pool_config->connection_cache = 1; + pool_config->health_check_timeout = 20; + pool_config->health_check_period = 0; + pool_config->health_check_user = "nobody"; + pool_config->failover_command = ""; + pool_config->failback_command = ""; + pool_config->insert_lock = 1; + pool_config->ignore_leading_white_space = 1; + pool_config->parallel_mode = 0; + pool_config->enable_query_cache = 0; + pool_config->system_db_hostname = "localhost"; + pool_config->system_db_port = 5432; + pool_config->system_db_dbname = "pgpool"; + pool_config->system_db_schema = "pgpool_catalog"; + pool_config->system_db_user = "pgpool"; + pool_config->system_db_password = ""; + pool_config->backend_desc->num_backends = 0; + pool_config->recovery_user = ""; + pool_config->recovery_password = ""; + pool_config->recovery_1st_stage_command = ""; + pool_config->recovery_2nd_stage_command = ""; + pool_config->recovery_timeout = 90; + pool_config->client_idle_limit_in_recovery = 0; + + res = gethostname(localhostname,sizeof(localhostname)); + if(res !=0 ) + { + pool_debug("faild to get this hostname"); + } + pool_config->pgpool2_hostname = localhostname; + + for (i=0;ilisten_addresses = strdup("*"); + else + pool_config->listen_addresses = strdup(""); + } + else if (!strcmp(key, "listen_addresses") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->listen_addresses = str; + } + + else if (!strcmp(key, "port") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 1024) + { + pool_error("pool_config: %s must be 1024 or higher numeric value", key); + fclose(fd); + return(-1); + } + pool_config->port = v; + } + else if (!strcmp(key, "pcp_port") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 1024) + { + pool_error("pool_config: %s must be 1024 or higher numeric value", key); + fclose(fd); + return(-1); + } + pool_config->pcp_port = v; + } + else if (!strcmp(key, "socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->socket_dir = str; + } + else if (!strcmp(key, "pcp_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->pcp_socket_dir = str; + } + else if (!strcmp(key, "pcp_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->pcp_timeout = v; + } + else if (!strcmp(key, "num_init_children") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 1) + { + pool_error("pool_config: %s must be higher than 1 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->num_init_children = v; + } + else if (!strcmp(key, "child_life_time") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->child_life_time = v; + } + else if (!strcmp(key, "client_idle_limit") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->client_idle_limit = v; + } + else if (!strcmp(key, "connection_life_time") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->connection_life_time = v; + } + else if (!strcmp(key, "child_max_connections") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->child_max_connections = v; + } + else if (!strcmp(key, "authentication_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->authentication_timeout = v; + } + else if (!strcmp(key, "max_pool") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->max_pool = v; + } + else if (!strcmp(key, "logdir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->logdir = str; + } + else if (!strcmp(key, "pid_file_name") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->pid_file_name = str; + } + else if (!strcmp(key, "log_connections") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->log_connections = v; + } + else if (!strcmp(key, "log_hostname") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->log_hostname = v; + } + else if (!strcmp(key, "enable_pool_hba") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->enable_pool_hba = v; + } + else if (!strcmp(key, "backend_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->backend_socket_dir = str; + } + else if (!strcmp(key, "replication_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->replication_mode = pool_config->replication_enabled = v; + + if (pool_config->master_slave_enabled && pool_config->replication_enabled) + { + pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time"); + fclose(fd); + return(-1); + } + + } + else if (!strcmp(key, "load_balance_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->load_balance_mode = v; + } + else if (!strcmp(key, "replication_stop_on_mismatch") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_debug("replication_stop_on_mismatch: %d", v); + pool_config->replication_stop_on_mismatch = v; + } + else if (!strcmp(key, "replicate_select") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_debug("replicate_select: %d", v); + pool_config->replicate_select = v; + } + else if (!strcmp(key, "reset_query_list") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->reset_query_list = extract_string_tokens(str, ";", &pool_config->num_reset_queries); + if (pool_config->reset_query_list == NULL) + { + fclose(fd); + return(-1); + } + } + + else if (!strcmp(key, "print_timestamp") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->print_timestamp = v; + } + + else if (!strcmp(key, "master_slave_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->master_slave_mode = pool_config->master_slave_enabled = v; + + if (pool_config->master_slave_enabled && pool_config->replication_enabled) + { + pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time"); + fclose(fd); + return(-1); + } + } + + else if (!strcmp(key, "connection_cache") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->connection_cache = v; + } + + else if (!strcmp(key, "health_check_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->health_check_timeout = v; + } + + else if (!strcmp(key, "health_check_period") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->health_check_period = v; + } + + else if (!strcmp(key, "health_check_user") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->health_check_user = str; + } + + else if (!strcmp(key, "failover_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->failover_command = str; + } + + else if (!strcmp(key, "failback_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->failback_command = str; + } + + else if (!strcmp(key, "recovery_user") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_user = str; + } + + else if (!strcmp(key, "recovery_password") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_password = str; + } + + else if (!strcmp(key, "recovery_1st_stage_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_1st_stage_command = str; + } + + else if (!strcmp(key, "recovery_2nd_stage_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_2nd_stage_command = str; + } + + else if (!strcmp(key, "recovery_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->recovery_timeout = v; + } + + else if (!strcmp(key, "client_idle_limit_in_recovery") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->client_idle_limit_in_recovery = v; + } + + else if (!strcmp(key, "insert_lock") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->insert_lock = v; + } + + else if (!strcmp(key, "ignore_leading_white_space") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->ignore_leading_white_space = v; + } + + else if (!strcmp(key, "parallel_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->parallel_mode = v; + } + + else if (!strcmp(key, "enable_query_cache") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->enable_query_cache = v; + } + + else if (!strcmp(key, "pgpool2_hostname") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + if(strlen(str)) + pool_config->pgpool2_hostname = str; + } + + else if (!strcmp(key, "system_db_hostname") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_hostname = str; + } + + else if (!strcmp(key, "system_db_port") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->system_db_port = v; + } + + else if (!strcmp(key, "system_db_dbname") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_dbname = str; + } + + else if (!strcmp(key, "system_db_schema") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_schema = str; + } + + else if (!strcmp(key, "system_db_user") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_user = str; + } + + else if (!strcmp(key, "system_db_password") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_password = str; + } + + else if (!strncmp(key, "backend_hostname", 16) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + char *str; + + slot = atoi(key + 16); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: backend number %s for backend_hostname out of range", key); + fclose(fd); + return(-1); + } + + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + if (context == INIT_CONFIG || + (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED)) + strncpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN); + } + + else if (!strncmp(key, "backend_port", 12) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + + slot = atoi(key + 12); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: host number %s for port number out of range", key); + fclose(fd); + return(-1); + } + pool_debug("pool_config: port slot number %d ", slot); + if (context == INIT_CONFIG) + { + BACKEND_INFO(slot).backend_port = atoi(yytext); + BACKEND_INFO(slot).backend_status = CON_CONNECT_WAIT; + } + else if (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED) + { + BACKEND_INFO(slot).backend_port = atoi(yytext); + BACKEND_INFO(slot).backend_status = CON_DOWN; + } + } + + else if (!strncmp(key, "backend_weight", 14) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + double v; + BACKEND_STATUS status; + + slot = atoi(key + 14); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: weight number %s for port number out of range", key); + fclose(fd); + return(-1); + } + + v = atof(yytext); + + if (v < 0.0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + + pool_debug("pool_config: weight slot number %d weight: %f", slot, v); + status = BACKEND_INFO(slot).backend_status; + if (context == INIT_CONFIG || + (context == RELOAD_CONFIG && (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))) + { + pool_config->backend_desc->backend_info[slot].unnormalized_weight = v; + } + } + else if (!strncmp(key, "backend_data_directory", 22) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + char *str; + BACKEND_STATUS status; + + slot = atoi(key + 22); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: backend number %s for backend_data_directory out of range", key); + fclose(fd); + return(-1); + } + + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + status = BACKEND_INFO(slot).backend_status; + if (context == INIT_CONFIG || + (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN))) + strncpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH); + } + else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + return(-1); + } + pool_config->log_statement = v; + } + else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + return(-1); + } + pool_config->log_statement = v; + } + } + + fclose(fd); + + pool_config->backend_desc->num_backends = 0; + total_weight = 0.0; + + for (i=0;ibackend_desc->num_backends = i+1; + } + } + + pool_debug("num_backends: %d num_backends: %d total_weight: %f", + pool_config->backend_desc->num_backends, pool_config->backend_desc->num_backends, total_weight); + /* + * Normalize load balacing weights. What we are doing here is, + * assign 0 to RAND_MAX to each backend's weight according to the + * value weightN. For example, if two backends are assigned 1.0, + * then each backend will get RAND_MAX/2 normalized weight. + */ + for (i=0;ibackend_desc->backend_info[i].backend_port != 0) + { + pool_config->backend_desc->backend_info[i].backend_weight = + (RAND_MAX) * pool_config->backend_desc->backend_info[i].unnormalized_weight / total_weight; + pool_debug("backend %d weight: %f", i, pool_config->backend_desc->backend_info[i].backend_weight); + } + } + + if (pool_config->parallel_mode || pool_config->enable_query_cache) + { + int dist_num; + SystemDBInfo *info; + + system_db_info = malloc(sizeof(POOL_SYSTEMDB_CONNECTION_POOL)); + if (system_db_info == NULL) + { + pool_error("failed to allocate sytem_db_info"); + return -1; + } + memset(system_db_info, 0, sizeof(*system_db_info)); + + system_db_info->system_db_status = pool_shared_memory_create(sizeof(BACKEND_STATUS)); + if (system_db_info->system_db_status == NULL) + { + pool_error("failed to allocate system_db_info->system_db_status"); + return -1; + } + *system_db_info->system_db_status = CON_CONNECT_WAIT; /* which is the same as SYSDB_STATUS = CON_CONNECT_WAIT */ + + info = malloc(sizeof(SystemDBInfo)); + if (info == NULL) + { + pool_error("failed to allocate info"); + return -1; + } + + system_db_info->info = info; + info->hostname = pool_config->system_db_hostname; + info->port = pool_config->system_db_port; + info->user = pool_config->system_db_user; + info->password = pool_config->system_db_password; + info->database_name = pool_config->system_db_dbname; + info->schema_name = pool_config->system_db_schema; + info->dist_def_num = 0; + info->dist_def_slot = NULL; + + if (pool_config->parallel_mode) + { + dist_num = pool_memset_system_db_info(info); + if(dist_num < 0) + { + pool_error("failed to get systemdb info"); + return(-1); + } + } + if (pool_config->enable_query_cache) + { + info->query_cache_table_info.register_prepared_statement = NULL; + if (! pool_query_cache_table_exists()) + { + pool_error("failed to locate query_cache table. perhaps it's not defined?"); + return -1; + } + } + SYSDB_STATUS = CON_UP; + } + + return 0; +} + +static char *extract_string(char *value, POOL_TOKEN token) +{ + char *ret; + + ret = strdup(value); + if (!ret) + { + pool_error("extract_string: out of memory"); + return NULL; + } + + if (token == POOL_STRING) + { + ret[strlen(ret)-1] = '\0'; + return (ret+1); + } + return ret; +} + +static int eval_logical(char *str) +{ + int ret; + + if (!strcasecmp(str, "true")) + ret = 1; + else if (!strcasecmp(str, "false")) + ret = 0; + else if (!strcmp(str, "1")) + ret = 1; + else if (!strcmp(str, "0")) + ret = 0; + else + ret = -1; + + return ret; +} + +/* + * extract tokens separated by delimi from str. return value is an + * array of pointers to malloced strings. number of tokens is set to + * n; note that str will be destroyed by strtok(). Also return value + * points to static data, that means subsequent call will change the + * return value. + */ +#define MAXTOKENS 1024 +static char **extract_string_tokens(char *str, char *delimi, int *n) +{ + char *token; + static char *tokens[MAXTOKENS]; + + *n = 0; + + for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi)) + { + tokens[*n] = strdup(token); + if (tokens[*n] == NULL) + { + pool_error("extract_string_tokens: out of memory"); + return NULL; + } + pool_debug("extract_string_tokens: token: %s", tokens[*n]); + (*n)++; + } + return tokens; +} + +static void clear_host_entry(int slot) +{ + *pool_config->backend_desc->backend_info[slot].backend_hostname = '\0'; + pool_config->backend_desc->backend_info[slot].backend_port = 0; + pool_config->backend_desc->backend_info[slot].backend_status = CON_UNUSED; + pool_config->backend_desc->backend_info[slot].backend_weight = 0.0; +} + +#ifdef DEBUG +static void print_host_entry(int slot) +{ + pool_debug("slot: %d host: %s port: %d status: %d weight: %f", + slot, + pool_config->server_hostnames[slot], + pool_config->server_ports[slot], + pool_config->server_status[slot], + pool_config->server_weights[slot]); +} +#endif + diff --git a/pool_config.l b/pool_config.l new file mode 100644 index 0000000..ee64240 --- /dev/null +++ b/pool_config.l @@ -0,0 +1,1368 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_config.l,v 1.24 2009/01/25 10:13:15 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_config.l: read configuration file + * + */ + +%{ + +#include "pool.h" + +#include +#include +#include + +#define CHECK_CONTEXT(mask, context) ((mask) & (context)) + +/* to shut off compiler warnings */ +int yylex(void); + +POOL_CONFIG *pool_config; /* configuration values */ +POOL_SYSTEMDB_CONNECTION_POOL *system_db_info; +static unsigned Lineno; +static char *default_reset_query_list[] = {"ABORT", "RESET ALL", "SET SESSION AUTHORIZATION DEFAULT"}; + +typedef enum { + POOL_KEY = 1, + POOL_INTEGER, + POOL_REAL, + POOL_STRING, + POOL_UNQUOTED_STRING, + POOL_EQUALS, + POOL_EOL, + POOL_PARSE_ERROR +} POOL_TOKEN; + +static char *extract_string(char *value, POOL_TOKEN token); +static char **extract_string_tokens(char *str, char *delim, int *n); +static int eval_logical(char *str); +static void clear_host_entry(int slot); + +%} + +%option 8bit +%option never-interactive +%option nounput +%option noyywrap + +SIGN ("-"|"+") +DIGIT [0-9] +HEXDIGIT [0-9a-fA-F] + +INTEGER {SIGN}?({DIGIT}+|0x{HEXDIGIT}+) + +EXPONENT [Ee]{SIGN}?{DIGIT}+ +REAL {SIGN}?{DIGIT}*"."{DIGIT}*{EXPONENT}? + +LETTER [A-Za-z_\200-\377] +LETTER_OR_DIGIT [A-Za-z_0-9\200-\377] + +KEY {LETTER}{LETTER_OR_DIGIT}* + +UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])* +STRING \'([^'\n]|\\.)*\' + +%% + +\n Lineno++; return POOL_EOL; +[ \t\r]+ /* eat whitespace */ +#.*$ /* eat comment */ + +{KEY} return POOL_KEY; +{STRING} return POOL_STRING; +{UNQUOTED_STRING} return POOL_UNQUOTED_STRING; +{INTEGER} return POOL_INTEGER; +{REAL} return POOL_REAL; += return POOL_EQUALS; + +. return POOL_PARSE_ERROR; + +%% + +int pool_init_config(void) +{ + int res; + static char localhostname[256]; + int i; + + pool_config = malloc(sizeof(POOL_CONFIG)); + if (pool_config == NULL) + { + pool_error("failed to allocate pool_config"); + return(-1); + } + + memset(pool_config, 0, sizeof(POOL_CONFIG)); + + pool_config->backend_desc = pool_shared_memory_create(sizeof(BackendDesc)); + if (pool_config->backend_desc == NULL) + { + pool_error("failed to allocate pool_config->backend_desc"); + return -1; + } + + /* set hardcoded default values */ + pool_config->listen_addresses = "localhost"; + pool_config->port = 9999; + pool_config->pcp_port = 9898; + pool_config->socket_dir = DEFAULT_SOCKET_DIR; + pool_config->pcp_socket_dir = DEFAULT_SOCKET_DIR; + pool_config->backend_socket_dir = DEFAULT_SOCKET_DIR; + pool_config->pcp_timeout = 10; + pool_config->num_init_children = 32; + pool_config->max_pool = 4; + pool_config->child_life_time = 300; + pool_config->client_idle_limit = 0; + pool_config->connection_life_time = 0; + pool_config->child_max_connections = 0; + pool_config->authentication_timeout = 60; + pool_config->logdir = DEFAULT_LOGDIR; + pool_config->pid_file_name = DEFAULT_PID_FILE_NAME; + pool_config->log_statement = 0; + pool_config->log_connections = 0; + pool_config->log_hostname = 0; + pool_config->enable_pool_hba = 0; + + pool_config->replication_mode = 0; + pool_config->load_balance_mode = 0; + pool_config->replication_stop_on_mismatch = 0; + pool_config->replicate_select = 0; + pool_config->reset_query_list = default_reset_query_list; + pool_config->num_reset_queries = sizeof(default_reset_query_list)/sizeof(char *); + pool_config->reset_query_list = default_reset_query_list; + pool_config->print_timestamp = 1; + pool_config->master_slave_mode = 0; + pool_config->connection_cache = 1; + pool_config->health_check_timeout = 20; + pool_config->health_check_period = 0; + pool_config->health_check_user = "nobody"; + pool_config->failover_command = ""; + pool_config->failback_command = ""; + pool_config->insert_lock = 1; + pool_config->ignore_leading_white_space = 1; + pool_config->parallel_mode = 0; + pool_config->enable_query_cache = 0; + pool_config->system_db_hostname = "localhost"; + pool_config->system_db_port = 5432; + pool_config->system_db_dbname = "pgpool"; + pool_config->system_db_schema = "pgpool_catalog"; + pool_config->system_db_user = "pgpool"; + pool_config->system_db_password = ""; + pool_config->backend_desc->num_backends = 0; + pool_config->recovery_user = ""; + pool_config->recovery_password = ""; + pool_config->recovery_1st_stage_command = ""; + pool_config->recovery_2nd_stage_command = ""; + pool_config->recovery_timeout = 90; + pool_config->client_idle_limit_in_recovery = 0; + + res = gethostname(localhostname,sizeof(localhostname)); + if(res !=0 ) + { + pool_debug("faild to get this hostname"); + } + pool_config->pgpool2_hostname = localhostname; + + for (i=0;ilisten_addresses = strdup("*"); + else + pool_config->listen_addresses = strdup(""); + } + else if (!strcmp(key, "listen_addresses") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->listen_addresses = str; + } + + else if (!strcmp(key, "port") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 1024) + { + pool_error("pool_config: %s must be 1024 or higher numeric value", key); + fclose(fd); + return(-1); + } + pool_config->port = v; + } + else if (!strcmp(key, "pcp_port") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 1024) + { + pool_error("pool_config: %s must be 1024 or higher numeric value", key); + fclose(fd); + return(-1); + } + pool_config->pcp_port = v; + } + else if (!strcmp(key, "socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->socket_dir = str; + } + else if (!strcmp(key, "pcp_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->pcp_socket_dir = str; + } + else if (!strcmp(key, "pcp_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->pcp_timeout = v; + } + else if (!strcmp(key, "num_init_children") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 1) + { + pool_error("pool_config: %s must be higher than 1 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->num_init_children = v; + } + else if (!strcmp(key, "child_life_time") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->child_life_time = v; + } + else if (!strcmp(key, "client_idle_limit") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->client_idle_limit = v; + } + else if (!strcmp(key, "connection_life_time") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->connection_life_time = v; + } + else if (!strcmp(key, "child_max_connections") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->child_max_connections = v; + } + else if (!strcmp(key, "authentication_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->authentication_timeout = v; + } + else if (!strcmp(key, "max_pool") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->max_pool = v; + } + else if (!strcmp(key, "logdir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->logdir = str; + } + else if (!strcmp(key, "pid_file_name") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->pid_file_name = str; + } + else if (!strcmp(key, "log_connections") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->log_connections = v; + } + else if (!strcmp(key, "log_hostname") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->log_hostname = v; + } + else if (!strcmp(key, "enable_pool_hba") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->enable_pool_hba = v; + } + else if (!strcmp(key, "backend_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->backend_socket_dir = str; + } + else if (!strcmp(key, "replication_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->replication_mode = pool_config->replication_enabled = v; + + if (pool_config->master_slave_enabled && pool_config->replication_enabled) + { + pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time"); + fclose(fd); + return(-1); + } + + } + else if (!strcmp(key, "load_balance_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->load_balance_mode = v; + } + else if (!strcmp(key, "replication_stop_on_mismatch") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_debug("replication_stop_on_mismatch: %d", v); + pool_config->replication_stop_on_mismatch = v; + } + else if (!strcmp(key, "replicate_select") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_debug("replicate_select: %d", v); + pool_config->replicate_select = v; + } + else if (!strcmp(key, "reset_query_list") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->reset_query_list = extract_string_tokens(str, ";", &pool_config->num_reset_queries); + if (pool_config->reset_query_list == NULL) + { + fclose(fd); + return(-1); + } + } + + else if (!strcmp(key, "print_timestamp") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->print_timestamp = v; + } + + else if (!strcmp(key, "master_slave_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->master_slave_mode = pool_config->master_slave_enabled = v; + + if (pool_config->master_slave_enabled && pool_config->replication_enabled) + { + pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time"); + fclose(fd); + return(-1); + } + } + + else if (!strcmp(key, "connection_cache") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->connection_cache = v; + } + + else if (!strcmp(key, "health_check_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->health_check_timeout = v; + } + + else if (!strcmp(key, "health_check_period") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->health_check_period = v; + } + + else if (!strcmp(key, "health_check_user") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->health_check_user = str; + } + + else if (!strcmp(key, "failover_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->failover_command = str; + } + + else if (!strcmp(key, "failback_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->failback_command = str; + } + + else if (!strcmp(key, "recovery_user") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_user = str; + } + + else if (!strcmp(key, "recovery_password") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_password = str; + } + + else if (!strcmp(key, "recovery_1st_stage_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_1st_stage_command = str; + } + + else if (!strcmp(key, "recovery_2nd_stage_command") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->recovery_2nd_stage_command = str; + } + + else if (!strcmp(key, "recovery_timeout") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->recovery_timeout = v; + } + + else if (!strcmp(key, "client_idle_limit_in_recovery") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be greater or equal to 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->client_idle_limit_in_recovery = v; + } + + else if (!strcmp(key, "insert_lock") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->insert_lock = v; + } + + else if (!strcmp(key, "ignore_leading_white_space") && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->ignore_leading_white_space = v; + } + + else if (!strcmp(key, "parallel_mode") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->parallel_mode = v; + } + + else if (!strcmp(key, "enable_query_cache") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + pool_config->enable_query_cache = v; + } + + else if (!strcmp(key, "pgpool2_hostname") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + if(strlen(str)) + pool_config->pgpool2_hostname = str; + } + + else if (!strcmp(key, "system_db_hostname") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_hostname = str; + } + + else if (!strcmp(key, "system_db_port") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + int v = atoi(yytext); + + if (token != POOL_INTEGER || v < 0) + { + pool_error("pool_config: %s must be equal or higher than 0 numeric value", key); + fclose(fd); + return(-1); + } + pool_config->system_db_port = v; + } + + else if (!strcmp(key, "system_db_dbname") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_dbname = str; + } + + else if (!strcmp(key, "system_db_schema") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_schema = str; + } + + else if (!strcmp(key, "system_db_user") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_user = str; + } + + else if (!strcmp(key, "system_db_password") && CHECK_CONTEXT(INIT_CONFIG, context)) + { + char *str; + + if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY) + { + PARSE_ERROR(); + fclose(fd); + return(-1); + } + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + pool_config->system_db_password = str; + } + + else if (!strncmp(key, "backend_hostname", 16) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + char *str; + + slot = atoi(key + 16); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: backend number %s for backend_hostname out of range", key); + fclose(fd); + return(-1); + } + + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + if (context == INIT_CONFIG || + (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED)) + strncpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN); + } + + else if (!strncmp(key, "backend_port", 12) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + + slot = atoi(key + 12); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: host number %s for port number out of range", key); + fclose(fd); + return(-1); + } + pool_debug("pool_config: port slot number %d ", slot); + if (context == INIT_CONFIG) + { + BACKEND_INFO(slot).backend_port = atoi(yytext); + BACKEND_INFO(slot).backend_status = CON_CONNECT_WAIT; + } + else if (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED) + { + BACKEND_INFO(slot).backend_port = atoi(yytext); + BACKEND_INFO(slot).backend_status = CON_DOWN; + } + } + + else if (!strncmp(key, "backend_weight", 14) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + double v; + BACKEND_STATUS status; + + slot = atoi(key + 14); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: weight number %s for port number out of range", key); + fclose(fd); + return(-1); + } + + v = atof(yytext); + + if (v < 0.0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + fclose(fd); + return(-1); + } + + pool_debug("pool_config: weight slot number %d weight: %f", slot, v); + status = BACKEND_INFO(slot).backend_status; + if (context == INIT_CONFIG || + (context == RELOAD_CONFIG && (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))) + { + pool_config->backend_desc->backend_info[slot].unnormalized_weight = v; + } + } + else if (!strncmp(key, "backend_data_directory", 22) && + CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) && + mypid == getpid()) /* this parameter must be modified by parent pid */ + { + int slot; + char *str; + BACKEND_STATUS status; + + slot = atoi(key + 22); + if (slot < 0 || slot >= MAX_CONNECTION_SLOTS) + { + pool_error("pool_config: backend number %s for backend_data_directory out of range", key); + fclose(fd); + return(-1); + } + + str = extract_string(yytext, token); + if (str == NULL) + { + fclose(fd); + return(-1); + } + status = BACKEND_INFO(slot).backend_status; + if (context == INIT_CONFIG || + (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN))) + strncpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH); + } + else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + return(-1); + } + pool_config->log_statement = v; + } + else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context)) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + return(-1); + } + pool_config->log_statement = v; + } + } + + fclose(fd); + + pool_config->backend_desc->num_backends = 0; + total_weight = 0.0; + + for (i=0;ibackend_desc->num_backends = i+1; + } + } + + pool_debug("num_backends: %d num_backends: %d total_weight: %f", + pool_config->backend_desc->num_backends, pool_config->backend_desc->num_backends, total_weight); + /* + * Normalize load balacing weights. What we are doing here is, + * assign 0 to RAND_MAX to each backend's weight according to the + * value weightN. For example, if two backends are assigned 1.0, + * then each backend will get RAND_MAX/2 normalized weight. + */ + for (i=0;ibackend_desc->backend_info[i].backend_port != 0) + { + pool_config->backend_desc->backend_info[i].backend_weight = + (RAND_MAX) * pool_config->backend_desc->backend_info[i].unnormalized_weight / total_weight; + pool_debug("backend %d weight: %f", i, pool_config->backend_desc->backend_info[i].backend_weight); + } + } + + if (pool_config->parallel_mode || pool_config->enable_query_cache) + { + int dist_num; + SystemDBInfo *info; + + system_db_info = malloc(sizeof(POOL_SYSTEMDB_CONNECTION_POOL)); + if (system_db_info == NULL) + { + pool_error("failed to allocate sytem_db_info"); + return -1; + } + memset(system_db_info, 0, sizeof(*system_db_info)); + + system_db_info->system_db_status = pool_shared_memory_create(sizeof(BACKEND_STATUS)); + if (system_db_info->system_db_status == NULL) + { + pool_error("failed to allocate system_db_info->system_db_status"); + return -1; + } + *system_db_info->system_db_status = CON_CONNECT_WAIT; /* which is the same as SYSDB_STATUS = CON_CONNECT_WAIT */ + + info = malloc(sizeof(SystemDBInfo)); + if (info == NULL) + { + pool_error("failed to allocate info"); + return -1; + } + + system_db_info->info = info; + info->hostname = pool_config->system_db_hostname; + info->port = pool_config->system_db_port; + info->user = pool_config->system_db_user; + info->password = pool_config->system_db_password; + info->database_name = pool_config->system_db_dbname; + info->schema_name = pool_config->system_db_schema; + info->dist_def_num = 0; + info->dist_def_slot = NULL; + + if (pool_config->parallel_mode) + { + dist_num = pool_memset_system_db_info(info); + if(dist_num < 0) + { + pool_error("failed to get systemdb info"); + return(-1); + } + } + if (pool_config->enable_query_cache) + { + info->query_cache_table_info.register_prepared_statement = NULL; + if (! pool_query_cache_table_exists()) + { + pool_error("failed to locate query_cache table. perhaps it's not defined?"); + return -1; + } + } + SYSDB_STATUS = CON_UP; + } + + return 0; +} + +static char *extract_string(char *value, POOL_TOKEN token) +{ + char *ret; + + ret = strdup(value); + if (!ret) + { + pool_error("extract_string: out of memory"); + return NULL; + } + + if (token == POOL_STRING) + { + ret[strlen(ret)-1] = '\0'; + return (ret+1); + } + return ret; +} + +static int eval_logical(char *str) +{ + int ret; + + if (!strcasecmp(str, "true")) + ret = 1; + else if (!strcasecmp(str, "false")) + ret = 0; + else if (!strcmp(str, "1")) + ret = 1; + else if (!strcmp(str, "0")) + ret = 0; + else + ret = -1; + + return ret; +} + +/* + * extract tokens separated by delimi from str. return value is an + * array of pointers to malloced strings. number of tokens is set to + * n; note that str will be destroyed by strtok(). Also return value + * points to static data, that means subsequent call will change the + * return value. + */ +#define MAXTOKENS 1024 +static char **extract_string_tokens(char *str, char *delimi, int *n) +{ + char *token; + static char *tokens[MAXTOKENS]; + + *n = 0; + + for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi)) + { + tokens[*n] = strdup(token); + if (tokens[*n] == NULL) + { + pool_error("extract_string_tokens: out of memory"); + return NULL; + } + pool_debug("extract_string_tokens: token: %s", tokens[*n]); + (*n)++; + } + return tokens; +} + +static void clear_host_entry(int slot) +{ + *pool_config->backend_desc->backend_info[slot].backend_hostname = '\0'; + pool_config->backend_desc->backend_info[slot].backend_port = 0; + pool_config->backend_desc->backend_info[slot].backend_status = CON_UNUSED; + pool_config->backend_desc->backend_info[slot].backend_weight = 0.0; +} + +#ifdef DEBUG +static void print_host_entry(int slot) +{ + pool_debug("slot: %d host: %s port: %d status: %d weight: %f", + slot, + pool_config->server_hostnames[slot], + pool_config->server_ports[slot], + pool_config->server_status[slot], + pool_config->server_weights[slot]); +} +#endif + diff --git a/pool_connection_pool.c b/pool_connection_pool.c new file mode 100644 index 0000000..396657f --- /dev/null +++ b/pool_connection_pool.c @@ -0,0 +1,647 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_connection_pool.c,v 1.13.2.3 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * poo_connection_pool.c: connection pool stuff + */ +#include "config.h" + +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif +#ifdef HAVE_NETINET_TCP_H +#include +#endif +#include + +#include +#include +#include +#include +#include +#include + +#include "pool.h" + +POOL_CONNECTION_POOL *pool_connection_pool; /* connection pool */ +volatile sig_atomic_t backend_timer_expired = 0; /* flag for connection closed timer is expired */ + +static POOL_CONNECTION_POOL_SLOT *create_cp(POOL_CONNECTION_POOL_SLOT *cp, int slot); +static POOL_CONNECTION_POOL *new_connection(POOL_CONNECTION_POOL *p); +static int check_socket_status(int fd); + +/* +* initialize connection pools. this should be called once at the startup. +*/ +int pool_init_cp(void) +{ + int i; + + pool_connection_pool = (POOL_CONNECTION_POOL *)malloc(sizeof(POOL_CONNECTION_POOL)*pool_config->max_pool); + if (pool_connection_pool == NULL) + { + pool_error("pool_init_cp: malloc() failed"); + return -1; + } + memset(pool_connection_pool, 0, sizeof(POOL_CONNECTION_POOL)*pool_config->max_pool); + + for (i = 0; i < pool_config->max_pool; i++) + { + pool_connection_pool[i].info = &(MY_PROCESS_INFO.connection_info[i]); + memset(pool_connection_pool[i].info, 0, sizeof(ConnectionInfo)); + } + return 0; +} + +/* +* find connection by user and database +*/ +POOL_CONNECTION_POOL *pool_get_cp(char *user, char *database, int protoMajor, int check_socket) +{ +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + int i, j, freed = 0; + ConnectionInfo *info; + + POOL_CONNECTION_POOL *p = pool_connection_pool; + + if (p == NULL) + { + pool_error("pool_get_cp: pool_connection_pool is not initialized"); + return NULL; + } + + POOL_SETMASK2(&BlockSig, &oldmask); + + for (i=0;imax_pool;i++) + { + if (MASTER_CONNECTION(p) && + MASTER_CONNECTION(p)->sp && + MASTER_CONNECTION(p)->sp->major == protoMajor && + MASTER_CONNECTION(p)->sp->user != NULL && + strcmp(MASTER_CONNECTION(p)->sp->user, user) == 0 && + strcmp(MASTER_CONNECTION(p)->sp->database, database) == 0) + { + int sock_broken = 0; + + /* mark this connection is under use */ + MASTER_CONNECTION(p)->closetime = 0; + p->info->counter++; + POOL_SETMASK(&oldmask); + + if (check_socket) + { + for (j=0;jfd); + if (sock_broken < 0) + break; + } + else + { + sock_broken = -1; + break; + } + } + + if (sock_broken < 0) + { + pool_log("connection closed. retry to create new connection pool."); + for (j=0;jsp); + freed = 1; + } + + pool_close(CONNECTION(p, j)); + free(CONNECTION_SLOT(p, j)); + } + info = p->info; + memset(p, 0, sizeof(POOL_CONNECTION_POOL_SLOT)); + p->info = info; + memset(p->info, 0, sizeof(ConnectionInfo)); + POOL_SETMASK(&oldmask); + return NULL; + } + } + POOL_SETMASK(&oldmask); + return p; + } + p++; + } + + POOL_SETMASK(&oldmask); + return NULL; +} + +/* + * disconnect and release a connection to the database + */ +void pool_discard_cp(char *user, char *database, int protoMajor) +{ + POOL_CONNECTION_POOL *p = pool_get_cp(user, database, protoMajor, 0); + ConnectionInfo *info; + int i, freed = 0; + + if (p == NULL) + { + pool_error("pool_discard_cp: cannot get connection pool for user %s datbase %s", user, database); + return; + } + + for (i=0;isp); + freed = 1; + } + pool_close(CONNECTION(p, i)); + free(CONNECTION_SLOT(p, i)); + } + + info = p->info; + memset(p, 0, sizeof(POOL_CONNECTION_POOL)); + p->info = info; + memset(p->info, 0, sizeof(ConnectionInfo)); +} + + +/* +* create a connection pool by user and database +*/ +POOL_CONNECTION_POOL *pool_create_cp(void) +{ + int i, freed = 0; + time_t closetime; + POOL_CONNECTION_POOL *oldestp; + ConnectionInfo *info; + + POOL_CONNECTION_POOL *p = pool_connection_pool; + + if (p == NULL) + { + pool_error("pool_create_cp: pool_connection_pool is not initialized"); + return NULL; + } + + for (i=0;imax_pool;i++) + { + if (MASTER_CONNECTION(p) == NULL) + return new_connection(p); + p++; + } + + pool_debug("no empty connection slot was found"); + + /* + * no empty connection slot was found. look for the oldest connection and discard it. + */ + oldestp = p = pool_connection_pool; + closetime = MASTER_CONNECTION(p)->closetime; + for (i=0;imax_pool;i++) + { + pool_debug("user: %s database: %s closetime: %ld", + MASTER_CONNECTION(p)->sp->user, + MASTER_CONNECTION(p)->sp->database, + MASTER_CONNECTION(p)->closetime); + if (MASTER_CONNECTION(p)->closetime < closetime) + { + closetime = MASTER_CONNECTION(p)->closetime; + oldestp = p; + } + p++; + } + + p = oldestp; + pool_send_frontend_exits(p); + + pool_debug("discarding old %d th connection. user: %s database: %s", + oldestp - pool_connection_pool, + MASTER_CONNECTION(p)->sp->user, + MASTER_CONNECTION(p)->sp->database); + + for (i=0;isp); + freed = 1; + } + + pool_close(CONNECTION(p, i)); + free(CONNECTION_SLOT(p, i)); + } + + info = p->info; + memset(p, 0, sizeof(POOL_CONNECTION_POOL)); + p->info = info; + memset(p->info, 0, sizeof(ConnectionInfo)); + + return new_connection(p); +} + +/* + * set backend connection close timer + */ +void pool_connection_pool_timer(POOL_CONNECTION_POOL *backend) +{ + POOL_CONNECTION_POOL *p = pool_connection_pool; + int i; + + pool_debug("pool_connection_pool_timer: set close time %ld", time(NULL)); + + MASTER_CONNECTION(backend)->closetime = time(NULL); /* set connection close time */ + + if (pool_config->connection_life_time == 0) + return; + + /* look for any other timeout */ + for (i=0;imax_pool;i++, p++) + { + if (!MASTER_CONNECTION(p)) + continue; + if (!MASTER_CONNECTION(p)->sp) + continue; + if (MASTER_CONNECTION(p)->sp->user == NULL) + continue; + + if (p != backend && MASTER_CONNECTION(p)->closetime) + return; + } + + /* no other timer found. set my timer */ + pool_debug("pool_connection_pool_timer: set alarm after %d seconds", pool_config->connection_life_time); + pool_signal(SIGALRM, pool_backend_timer_handler); + alarm(pool_config->connection_life_time); +} + +/* + * backend connection close timer handler + */ +RETSIGTYPE pool_backend_timer_handler(int sig) +{ + backend_timer_expired = 1; +} + +void pool_backend_timer(void) +{ +#define TMINTMAX 0x7fffffff + + POOL_CONNECTION_POOL *p = pool_connection_pool; + int i, j; + time_t now; + time_t nearest = TMINTMAX; + ConnectionInfo *info; + + POOL_SETMASK(&BlockSig); + + now = time(NULL); + + pool_debug("pool_backend_timer_handler called at %ld", now); + + for (i=0;imax_pool;i++, p++) + { + if (!MASTER_CONNECTION(p)) + continue; + if (!MASTER_CONNECTION(p)->sp) + continue; + if (MASTER_CONNECTION(p)->sp->user == NULL) + continue; + + /* timer expire? */ + if (MASTER_CONNECTION(p)->closetime) + { + int freed = 0; + + pool_debug("pool_backend_timer_handler: expire time: %ld", + MASTER_CONNECTION(p)->closetime+pool_config->connection_life_time); + + if (now >= (MASTER_CONNECTION(p)->closetime+pool_config->connection_life_time)) + { + /* discard expired connection */ + pool_debug("pool_backend_timer_handler: expires user %s database %s", + MASTER_CONNECTION(p)->sp->user, MASTER_CONNECTION(p)->sp->database); + + pool_send_frontend_exits(p); + + for (j=0;jsp); + freed = 1; + } + + pool_close(CONNECTION(p, j)); + free(CONNECTION_SLOT(p, j)); + } + info = p->info; + memset(p, 0, sizeof(POOL_CONNECTION_POOL)); + p->info = info; + memset(p->info, 0, sizeof(ConnectionInfo)); + } + else + { + /* look for nearest timer */ + if (MASTER_CONNECTION(p)->closetime < nearest) + nearest = MASTER_CONNECTION(p)->closetime; + } + } + } + + /* any remaining timer */ + if (nearest != TMINTMAX) + { + nearest = pool_config->connection_life_time - (now - nearest); + if (nearest <= 0) + nearest = 1; + pool_signal(SIGALRM, pool_backend_timer_handler); + alarm(nearest); + } + + POOL_SETMASK(&UnBlockSig); +} + +/* + * connect to postmaster through INET domain socket + */ +int connect_inet_domain_socket(int slot) +{ + char *host; + int port; + + host = pool_config->backend_desc->backend_info[slot].backend_hostname; + port = pool_config->backend_desc->backend_info[slot].backend_port; + + return connect_inet_domain_socket_by_port(host, port); +} + +/* + * connect to postmaster through UNIX domain socket + */ +int connect_unix_domain_socket(int slot) +{ + int port; + char *socket_dir; + + port = pool_config->backend_desc->backend_info[slot].backend_port; + socket_dir = pool_config->backend_socket_dir; + + return connect_unix_domain_socket_by_port(port, socket_dir); +} + +int connect_unix_domain_socket_by_port(int port, char *socket_dir) +{ + struct sockaddr_un addr; + int fd; + int len; + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd == -1) + { + pool_error("connect_unix_domain_socket_by_port: setsockopt() failed: %s", strerror(errno)); + return -1; + } + + memset((char *) &addr, 0, sizeof(addr)); + ((struct sockaddr *)&addr)->sa_family = AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/.s.PGSQL.%d", socket_dir, port); + len = sizeof(struct sockaddr_un); + + for (;;) + { + if (connect(fd, (struct sockaddr *)&addr, len) < 0) + { + if (errno == EINTR || errno == EAGAIN) + continue; + + pool_error("connect_unix_domain_socket_by_port: connect() failed: %s", strerror(errno)); + close(fd); + return -1; + } + break; + } + + return fd; +} + +int connect_inet_domain_socket_by_port(char *host, int port) +{ + int fd; + int len; + int on = 1; + struct sockaddr_in addr; + struct hostent *hp; + + fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) + { + pool_error("connect_inet_domain_socket_by_port: socket() failed: %s", strerror(errno)); + return -1; + } + + /* set nodelay */ + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + (char *) &on, + sizeof(on)) < 0) + { + pool_error("connect_inet_domain_socket_by_port: setsockopt() failed: %s", strerror(errno)); + close(fd); + return -1; + } + + memset((char *) &addr, 0, sizeof(addr)); + ((struct sockaddr *)&addr)->sa_family = AF_INET; + + addr.sin_port = htons(port); + len = sizeof(struct sockaddr_in); + + hp = gethostbyname(host); + if ((hp == NULL) || (hp->h_addrtype != AF_INET)) + { + pool_error("connect_inet_domain_socket: gethostbyname() failed: %s host: %s", strerror(errno), host); + close(fd); + return -1; + } + memmove((char *) &(addr.sin_addr), + (char *) hp->h_addr, + hp->h_length); + + for (;;) + { + if (connect(fd, (struct sockaddr *)&addr, len) < 0) + { + if (errno == EINTR || errno == EAGAIN) + continue; + + pool_error("connect_inet_domain_socket: connect() failed: %s",strerror(errno)); + close(fd); + return -1; + } + break; + } + + return fd; +} + +/* + * create connection pool + */ +static POOL_CONNECTION_POOL_SLOT *create_cp(POOL_CONNECTION_POOL_SLOT *cp, int slot) +{ + BackendInfo *b = &pool_config->backend_desc->backend_info[slot]; + int fd; + + if (*b->backend_hostname == '\0') + { + fd = connect_unix_domain_socket(slot); + } + else + { + fd = connect_inet_domain_socket(slot); + } + + if (fd < 0) + { + pool_error("connection to %s(%d) failed", b->backend_hostname, b->backend_port); + return NULL; + } + + cp->con = pool_open(fd); + cp->closetime = 0; + return cp; +} + +/* + * create actual connections to backends + */ +static POOL_CONNECTION_POOL *new_connection(POOL_CONNECTION_POOL *p) +{ + POOL_CONNECTION_POOL_SLOT *s; + int active_backend_count = 0; + int i; + + for (i=0;islots[i] = s; + + if (pool_init_params(&s->con->params)) + { + return NULL; + } + + BACKEND_INFO(i).backend_status = CON_UP; + active_backend_count++; + } + + if (active_backend_count > 0) + { + p->info->create_time = time(NULL); + return p; + } + + return NULL; +} + +/* check_socket_status() + * RETURN: 0 => OK + * -1 => broken socket. + */ +static int check_socket_status(int fd) +{ + fd_set rfds; + int result; + struct timeval t; + + for (;;) + { + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + + t.tv_sec = t.tv_usec = 0; + + result = select(fd+1, &rfds, NULL, NULL, &t); + if (result < 0 && errno == EINTR) + { + continue; + } + else + { + return (result == 0 ? 0 : -1); + } + } + + return -1; +} diff --git a/pool_error.c b/pool_error.c new file mode 100644 index 0000000..e6d3261 --- /dev/null +++ b/pool_error.c @@ -0,0 +1,178 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_error.c,v 1.3.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_error.c: error and debug messages + * + */ + +#include +#include +#include +#include +#include + +#include "pool.h" + +#define MAXSTRFTIME 128 + +extern int debug; + +static char *nowsec(void); + +void pool_error(const char *fmt,...) +{ + va_list ap; +#ifdef HAVE_ASPRINTF + char *fmt2; +#endif + +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + POOL_SETMASK2(&BlockSig, &oldmask); + + if (pool_config->print_timestamp) +#ifdef HAVE_ASPRINTF + asprintf(&fmt2, "%s ERROR: pid %d: %s\n", nowsec(), (int)getpid(), fmt); + else + asprintf(&fmt2, "ERROR: pid %d: %s\n", (int)getpid(), fmt); + + if (fmt2) + { + va_start(ap, fmt); + vfprintf(stderr, fmt2, ap); + va_end(ap); + fflush(stderr); + free(fmt2); + } +#else + fprintf(stderr, "%s ERROR: pid %d: ", nowsec(), (int)getpid()); + else + fprintf(stderr, "ERROR: pid %d: ", (int)getpid()); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +#endif + + POOL_SETMASK(&oldmask); +} + +void pool_debug(const char *fmt,...) +{ + va_list ap; +#ifdef HAVE_ASPRINTF + char *fmt2; +#endif + +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + if (!debug) + return; + + POOL_SETMASK2(&BlockSig, &oldmask); + + if (pool_config->print_timestamp) +#ifdef HAVE_ASPRINTF + asprintf(&fmt2, "%s DEBUG: pid %d: %s\n", nowsec(), (int)getpid(), fmt); + else + asprintf(&fmt2, "DEBUG: pid %d: %s\n", (int)getpid(), fmt); + + if (fmt2) + { + va_start(ap, fmt); + vfprintf(stderr, fmt2, ap); + va_end(ap); + fflush(stderr); + free(fmt2); + } +#else + fprintf(stderr, "%s DEBUG: pid %d: ", nowsec(), (int)getpid()); + else + fprintf(stderr, "DEBUG: pid %d: ", (int)getpid()); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +#endif + + POOL_SETMASK(&oldmask); +} + +void pool_log(const char *fmt,...) +{ + va_list ap; +#ifdef HAVE_ASPRINTF + char *fmt2; +#endif + +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + POOL_SETMASK2(&BlockSig, &oldmask); + + if (pool_config->print_timestamp) +#ifdef HAVE_ASPRINTF + asprintf(&fmt2, "%s LOG: pid %d: %s\n", nowsec(), (int)getpid(), fmt); + else + asprintf(&fmt2, "LOG: pid %d: %s\n", (int)getpid(), fmt); + + if (fmt2) + { + va_start(ap, fmt); + vfprintf(stderr, fmt2, ap); + va_end(ap); + fflush(stderr); + free(fmt2); + } +#else + fprintf(stderr, "%s LOG: pid %d: ", nowsec(), (int)getpid()); + else + fprintf(stderr, "LOG: pid %d: ", (int)getpid()); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +#endif + + POOL_SETMASK(&oldmask); +} + +static char *nowsec(void) +{ + static char strbuf[MAXSTRFTIME]; + time_t now = time(NULL); + + strftime(strbuf, MAXSTRFTIME, "%Y-%m-%d %H:%M:%S", localtime(&now)); + return strbuf; +} diff --git a/pool_hba.c b/pool_hba.c new file mode 100644 index 0000000..3b33061 --- /dev/null +++ b/pool_hba.c @@ -0,0 +1,1436 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_hba.c,v 1.5.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008 PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_hba.c.: Routines to handle host based authentication. + * + */ + +#include +#include +#include +#include +#include + +#include "pool.h" +#include "pool_path.h" +#include "pool_ip.h" +#include "parser/pool_memory.h" +#include "parser/pg_list.h" + +#define MULTI_VALUE_SEP "\001" /* delimiter for multi-valued column strings */ +#define MAX_TOKEN 256 + +static List *hba_lines = NIL; +static List *hba_line_nums = NIL; +static char *hbaFileName; + +static POOL_MEMORY_POOL *hba_memory_context = NULL; + +static void sendAuthRequest(POOL_CONNECTION *frontend, AuthRequest areq); +static void auth_failed(POOL_CONNECTION *frontend); +static void close_all_backend_connections(void); +static bool hba_getauthmethod(POOL_CONNECTION *frontend); +static bool check_hba(POOL_CONNECTION *frontend); +static void parse_hba(List *line, int line_num, POOL_CONNECTION *frontend, bool *found_p, bool *error_p); +static void parse_hba_auth(ListCell **line_item, UserAuth *userauth_p, char **auth_arg_p, bool *error_p); +static bool check_user(char *user, char *param_str); +static bool check_db(char *dbname, char *user, char *param_str); +static void free_lines(List **lines, List **line_nums); +static void tokenize_file(const char *filename, FILE *file, List **lines, List **line_nums); +static char *tokenize_inc_file(const char *outer_filename, const char *inc_filename); +static bool pg_isblank(const char c); +static void next_token(FILE *fp, char *buf, int bufsz); +static char * next_token_expand(const char *filename, FILE *file); + +#ifdef USE_PAM +#ifdef HAVE_PAM_PAM_APPL_H +#include +#endif +#ifdef HAVE_SECURITY_PAM_APPL_H +#include +#endif + +#define PGPOOL_PAM_SERVICE "pgpool" /* Service name passed to PAM */ + +static POOL_STATUS CheckPAMAuth(POOL_CONNECTION *frontend, char *user, char *password); +static int pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, struct pam_response ** resp, void *appdata_ptr); +/* + * recv_password_packet is usually used with authentications that require a client + * password. However, pgpool's hba function only uses it for PAM authentication, + * so declare a prototype here in "#ifdef USE_PAM" to avoid compilation warning. + */ +static char *recv_password_packet(POOL_CONNECTION *frontend); + +static struct pam_conv pam_passw_conv = { + &pam_passwd_conv_proc, + NULL +}; + +static char *pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */ +static POOL_CONNECTION *pam_frontend_kludge; /* Workaround for passing + * POOL_CONNECTION *frontend + * into pam_passwd_conv_proc */ +#endif /* USE_PAM */ + + +/* + * read in hba config file + */ +void load_hba(char *hbapath) +{ + FILE *file; + + POOL_MEMORY_POOL *old_context; + if (hba_memory_context == NULL) + { + hba_memory_context = pool_memory_create(PARSER_BLOCK_SIZE); + if (hba_memory_context == NULL) + { + pool_error("load_hba: pool_memory_create() failed"); + exit(1); + } + } + /* switch memory context */ + old_context = pool_memory; + pool_memory = hba_memory_context; + + if (hba_lines || hba_line_nums) + free_lines(&hba_lines, &hba_line_nums); + + file = fopen(hbapath, "r"); + if (!file) + { + pool_error("could not open \"%s\". reason: %s", + hbapath, strerror(errno)); + exit(1); + } + + pool_debug("loading \"%s\" for client authentication configuration file", + hbapath); + + tokenize_file(hbapath, file, &hba_lines, &hba_line_nums); + fclose(file); + + hbaFileName = pstrdup(hbapath); + + /* switch old memory context */ + pool_memory = old_context; +} + + +/* + * do frontend <-> pgpool authentication based on pool_hba.conf + */ +void ClientAuthentication(POOL_CONNECTION *frontend) +{ + POOL_STATUS status = POOL_ERROR; + + if (! hba_getauthmethod(frontend)) + { + pool_error("missing or erroneous pool_hba.conf file"); + pool_send_error_message(frontend, frontend->protoVersion, "XX000", + "missing or erroneous pool_hba.conf file", "", + "See pgpool log for details.", __FILE__, __LINE__); + close_all_backend_connections(); + /* + * use exit(2) since this is not so fatal. other entries in + * pool_hba.conf may be valid, so treat it as reject. + */ + child_exit(2); + } + + switch (frontend->auth_method) + { + case uaReject: + { + /* + * This could have come from an explicit "reject" entry in + * pool_hba.conf, but more likely it means there was no matching + * entry. Take pity on the poor user and issue a helpful + * error message. NOTE: this is not a security breach, + * because all the info reported here is known at the frontend + * and must be assumed known to bad guys. We're merely helping + * out the less clueful good guys. + */ + char hostinfo[NI_MAXHOST]; + char *errmessage; + int messagelen; + + getnameinfo_all(&frontend->raddr.addr, frontend->raddr.salen, + hostinfo, sizeof(hostinfo), + NULL, 0, + NI_NUMERICHOST); + + messagelen = sizeof(hostinfo) + + strlen(frontend->username) + strlen(frontend->database) + 80; + if ((errmessage = (char *)malloc(messagelen+1)) == NULL) + { + pool_error("ClientAuthentication: malloc failed: %s", strerror(errno)); + child_exit(1); + } + +#ifdef USE_SSL + snprintf(errmessage, messagelen+7, /* +7 is for "SSL off" */ + "no pool_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s", + hostinfo, frontend->username, frontend->database, + frontend->ssl ? "SSL on" : "SSL off"); +#else + snprintf(errmessage, messagelen, + "no pool_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"", + hostinfo, frontend->username, frontend->database); +#endif + pool_error(errmessage); + pool_send_error_message(frontend, frontend->protoVersion, "XX000", errmessage, + "", "", __FILE__, __LINE__); + + free(errmessage); + break; + } + +/* case uaKrb4: */ +/* break; */ + +/* case uaKrb5: */ +/* break; */ + +/* case uaIdent: */ +/* break; */ + +/* case uaMD5: */ +/* break; */ + +/* case uaCrypt: */ +/* break; */ + +/* case uaPassword: */ +/* break; */ + +#ifdef USE_PAM + case uaPAM: + pam_frontend_kludge = frontend; + status = CheckPAMAuth(frontend, frontend->username, ""); + break; +#endif /* USE_PAM */ + + case uaTrust: + status = POOL_CONTINUE; + break; + } + + if (status == POOL_CONTINUE) + sendAuthRequest(frontend, AUTH_REQ_OK); + else if (status != POOL_CONTINUE) + auth_failed(frontend); +} + + +static void sendAuthRequest(POOL_CONNECTION *frontend, AuthRequest areq) +{ + int wsize; /* number of bytes to write */ + int areq_nbo; /* areq in network byte order */ + + /* + * If AUTH_REQ_OK, then frontend is OK to connect __with_pgpool__. + * Do not send 'R' to the frontend, he still needs to authenticate + * himself with the backend. + */ + if (areq == AUTH_REQ_OK) + return; + + /* request a password */ + pool_write(frontend, "R", 1); + + if (frontend->protoVersion == PROTO_MAJOR_V3) + { +/* if (areq == AUTH_REQ_MD5) */ +/* wsize = htonl(sizeof(int)*2+4); */ +/* else if (areq == AUTH_REQ_CRYPT) */ +/* wsize = htonl(sizeof(int)*2+2); */ +/* else */ + wsize = htonl(sizeof(int)*2); + pool_write(frontend, &wsize, sizeof(int)); + } + + areq_nbo = htonl(areq); + pool_write(frontend, &areq_nbo, sizeof(int)); + + /* Add the salt for encrypted passwords. */ +/* if (areq == AUTH_REQ_MD5) */ +/* pq_sendbytes(&buf, port->md5Salt, 4); */ +/* else if (areq == AUTH_REQ_CRYPT) */ +/* pq_sendbytes(&buf, port->cryptSalt, 2); */ + + pool_flush(frontend); +} + + +#ifdef USE_PAM /* see the prototype comment */ + +/* + * Collect password response packet from frontend. + * + * Returns NULL if couldn't get password, else malloc'd string. + */ +static char *recv_password_packet(POOL_CONNECTION *frontend) +{ + int rsize; + char *passwd; + char *returnVal; + + if (frontend->protoVersion == PROTO_MAJOR_V3) + { + /* Expect 'p' message type */ + char kind; + + if (pool_read(frontend, &kind, 1) < 0) + return NULL; + + if (kind != 'p') + { + pool_error("expected password response, got message type %c", + kind); + return NULL; /* bad message type */ + } + } + /* pre-3.0 protocol does not send a message type */ + + if (pool_read(frontend, &rsize, sizeof(int)) < 0) + return NULL; + + rsize = ntohl(rsize) - 4; + passwd = pool_read2(frontend, rsize); /* retrieve password */ + if (passwd == NULL) + return NULL; + + /* Do not echo password to logs, for security. */ + pool_debug("received password packet from frontend for pgpool's HBA"); + + /* + * Return the received string. Note we do not attempt to do any + * character-set conversion on it; since we don't yet know the + * client's encoding, there wouldn't be much point. + */ + returnVal = strdup(passwd); + if (returnVal == NULL) + { + pool_error("recv_password_packet: strdup failed: %s", strerror(errno)); + exit(1); + } + return returnVal; +} + +#endif /* USE_PAM */ + +/* + * Tell the user the authentication failed. + */ +static void auth_failed(POOL_CONNECTION *frontend) +{ + bool send_error_to_frontend = true; + int messagelen; + char *errmessage; + + messagelen = strlen(frontend->username) + 100; + if ((errmessage = (char *)malloc(messagelen+1)) == NULL) + { + pool_error("auth_failed: malloc failed: %s", strerror(errno)); + child_exit(1); + } + + switch (frontend->auth_method) + { + case uaReject: + snprintf(errmessage, messagelen, + "authentication with pgpool failed for user \"%s\": host rejected", + frontend->username); + /* + * if uaReject, frontend should have received 'E' and disconnected already. + */ + send_error_to_frontend = false; + break; +/* case uaKrb4: */ +/* snprintf(errmessage, messagelen, */ +/* "Kerberos 4 authentication with pgpool failed for user \"%s\"", */ +/* frontend->username); */ +/* break; */ +/* case uaKrb5: */ +/* snprintf(errmessage, messagelen, */ +/* "Kerberos 5 authentication with pgpool failed for user \"%s\"", */ +/* frontend->username); */ +/* break; */ + case uaTrust: + snprintf(errmessage, messagelen, + "\"trust\" authentication with pgpool failed for user \"%s\"", + frontend->username); + break; +/* case uaIdent: */ +/* snprintf(errmessage, messagelen, */ +/* "Ident authentication with pgpool failed for user \"%s\"", */ +/* frontend->username); */ +/* break; */ +/* case uaMD5: */ +/* case uaCrypt: */ +/* case uaPassword: */ +/* snprintf(errmessage, messagelen, */ +/* "password authentication with pgpool failed for user \"%s\"", */ +/* frontend->username); */ +/* break; */ +#ifdef USE_PAM + case uaPAM: + snprintf(errmessage, messagelen, + "PAM authentication with pgpool failed for user \"%s\"", + frontend->username); + break; +#endif /* USE_PAM */ + default: + snprintf(errmessage, messagelen, + "authentication with pgpool failed for user \"%s\": invalid authentication method", + frontend->username); + break; + } + + pool_error(errmessage); + if (send_error_to_frontend) + pool_send_error_message(frontend, frontend->protoVersion, "XX000", errmessage, + "", "", __FILE__, __LINE__); + + /* + * don't need to free(errmessage). I will just kill myself. + */ + close_all_backend_connections(); + child_exit(2); +} + + +/* + * Close all of the cached backend connections. + * + * This is exactly the same as send_frontend_exits() in child.c. + */ +static void close_all_backend_connections(void) +{ + int i; + POOL_CONNECTION_POOL *p = pool_connection_pool; + +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + POOL_SETMASK2(&BlockSig, &oldmask); + + for (i=0;imax_pool;i++, p++) + { + if (!MASTER_CONNECTION(p)) + continue; + if (MASTER_CONNECTION(p)->sp->user == NULL) + continue; + pool_send_frontend_exits(p); + } + + POOL_SETMASK(&oldmask); +} + + +/* + * Determine what authentication method should be used when accessing database + * "database" from frontend "raddr", user "user". Return the method and + * an optional argument (stored in fields of *frontend), and true for success. + * + * Note that false indicates a problem with the hba config file. + * If the file is OK but does not contain any entry matching the request, + * we return true and method = uaReject. + */ +static bool hba_getauthmethod(POOL_CONNECTION *frontend) +{ + if (check_hba(frontend)) + return true; + else + return false; +} + + +/* + * Scan the (pre-parsed) hba file line by line, looking for a match + * to the port's connection request. + */ +static bool check_hba(POOL_CONNECTION *frontend) +{ + bool found_entry = false; + bool error = false; + ListCell *line; + ListCell *line_num; + + forboth(line, hba_lines, line_num, hba_line_nums) + { + parse_hba(lfirst(line), lfirst_int(line_num), + frontend, &found_entry, &error); + if (found_entry || error) + break; + } + + if (!error) + { + /* If no matching entry was found, synthesize 'reject' entry. */ + if (!found_entry) + frontend->auth_method = uaReject; + return true; + } + else + return false; +} + + +/* + * Process one line from the hba config file. + * + * See if it applies to a connection from a frontend with IP address + * frontend->raddr to a database named frontend->database. If so, return + * *found_p true and fill in the auth arguments into the appropriate + * frontend fields. If not, leave *found_p as it was. If the record has + * a syntax error, return *error_p true, after issuing a message to the + * log. If no error, leave *error_p as it was. + */ +static void parse_hba(List *line, int line_num, POOL_CONNECTION *frontend, + bool *found_p, bool *error_p) +{ + char *token; + char *db, *db_tmp; + char *user, *user_tmp; + struct addrinfo *gai_result; + struct addrinfo hints; + int ret; + struct sockaddr_storage addr; + struct sockaddr_storage mask; + char *cidr_slash; + ListCell *line_item; + + line_item = list_head(line); + /* Check the record type. */ + token = lfirst(line_item); + if (strcmp(token, "local") == 0) + { + /* Get the database. */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + db = lfirst(line_item); + + /* Get the user. */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + user = lfirst(line_item); + + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + + /* Read the rest of the line. */ + parse_hba_auth(&line_item, &frontend->auth_method, + &frontend->auth_arg, error_p); + if (*error_p) + goto hba_syntax; + + /* Disallow auth methods that always need TCP/IP sockets to work */ + /* + if (frontend->auth_method == uaKrb4 || + frontend->auth_method == uaKrb5) + goto hba_syntax; + */ + + /* Does not match if connection isn't AF_UNIX */ + if (!IS_AF_UNIX(frontend->raddr.addr.ss_family)) + return; + } + else if (strcmp(token, "host") == 0 + || strcmp(token, "hostssl") == 0 + || strcmp(token, "hostnossl") == 0) + { + if (token[4] == 's') /* "hostssl" */ + { +#ifdef USE_SSL + /* Record does not match if we are not on an SSL connection */ + if (!frontend->ssl) + return; + + /* Placeholder to require specific SSL level, perhaps? */ + /* Or a client certificate */ + + /* Since we were on SSL, proceed as with normal 'host' mode */ +#else + /* We don't accept this keyword at all if no SSL support */ + goto hba_syntax; +#endif + } +#ifdef USE_SSL + else if (token[4] == 'n') /* "hostnossl" */ + { + /* Record does not match if we are on an SSL connection */ + if (frontend->ssl) + return; + } +#endif + + /* Get the database. */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + db = lfirst(line_item); + + /* Get the user. */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + user = lfirst(line_item); + + /* Read the IP address field. (with or without CIDR netmask) */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + token = lfirst(line_item); + + /* Check if it has a CIDR suffix and if so isolate it */ + cidr_slash = strchr(token, '/'); + if (cidr_slash) + *cidr_slash = '\0'; + + /* Get the IP address either way */ + hints.ai_flags = AI_NUMERICHOST; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = 0; + hints.ai_protocol = 0; + hints.ai_addrlen = 0; + hints.ai_canonname = NULL; + hints.ai_addr = NULL; + hints.ai_next = NULL; + + ret = getaddrinfo_all(token, NULL, &hints, &gai_result); + if (ret || !gai_result) + { + pool_log("invalid IP address \"%s\" in file \"%s\" line %d: %s", + token, hbaFileName, line_num, gai_strerror(ret)); + if (cidr_slash) + *cidr_slash = '/'; + if (gai_result) + freeaddrinfo_all(hints.ai_family, gai_result); + goto hba_other_error; + } + + if (cidr_slash) + *cidr_slash = '/'; + + memcpy(&addr, gai_result->ai_addr, gai_result->ai_addrlen); + freeaddrinfo_all(hints.ai_family, gai_result); + + /* Get the netmask */ + if (cidr_slash) + { + if (SockAddr_cidr_mask(&mask, cidr_slash + 1, addr.ss_family) < 0) + goto hba_syntax; + } + else + { + /* Read the mask field. */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + token = lfirst(line_item); + + ret = getaddrinfo_all(token, NULL, &hints, &gai_result); + if (ret || !gai_result) + { + pool_log("invalid IP mask \"%s\" in file \"%s\" line %d: %s", + token, hbaFileName, line_num, gai_strerror(ret)); + if (gai_result) + freeaddrinfo_all(hints.ai_family, gai_result); + goto hba_other_error; + } + + memcpy(&mask, gai_result->ai_addr, gai_result->ai_addrlen); + freeaddrinfo_all(hints.ai_family, gai_result); + + if (addr.ss_family != mask.ss_family) + { + pool_log("IP address and mask do not match in file \"%s\" line %d", + hbaFileName, line_num); + goto hba_other_error; + } + } + + if (addr.ss_family != frontend->raddr.addr.ss_family) + { + /* + * Wrong address family. We allow only one case: if the file + * has IPv4 and the port is IPv6, promote the file address to + * IPv6 and try to match that way. + */ +#ifdef HAVE_IPV6 + if (addr.ss_family == AF_INET && frontend->raddr.addr.ss_family == AF_INET6) + { + promote_v4_to_v6_addr(&addr); + promote_v4_to_v6_mask(&mask); + } + else +#endif /* HAVE_IPV6 */ + { + /* Line doesn't match client port, so ignore it. */ + return; + } + } + + /* Ignore line if client port is not in the matching addr range. */ + if (!rangeSockAddr(&frontend->raddr.addr, &addr, &mask)) + return; + + /* Read the rest of the line. */ + line_item = lnext(line_item); + if (!line_item) + goto hba_syntax; + parse_hba_auth(&line_item, &frontend->auth_method, + &frontend->auth_arg, error_p); + if (*error_p) + goto hba_syntax; + } + else + goto hba_syntax; + + /* Does the entry match database and user? */ + /* + * duplicate db and username since strtok() in check_db() and check_user() + * will override '\001' with '\0'. + */ + db_tmp = strdup(db); + if (db_tmp == NULL) + { + pool_error("parse_hba: strdup failed: %s", strerror(errno)); + exit(1); + } + user_tmp = strdup(user); + if (user_tmp == NULL) + { + pool_error("parse_hba: strdup failed: %s", strerror(errno)); + exit(1); + } + if (!check_db(frontend->database, frontend->username, db_tmp)) + return; + if (!check_user(frontend->username, user_tmp)) + return; + free(db_tmp); + free(user_tmp); + + /* Success */ + *found_p = true; + return; + + hba_syntax: + if (line_item) + pool_log("invalid entry in file \"%s\" at line %d, token \"%s\"", + hbaFileName, line_num, (char *) lfirst(line_item)); + else + pool_log("missing field in file \"%s\" at end of line %d", + hbaFileName, line_num); + + /* Come here if suitable message already logged */ + hba_other_error: + *error_p = true; +} + + +/* + * Scan the rest of a host record (after the mask field) + * and return the interpretation of it as *userauth_p, *auth_arg_p, and + * *error_p. *line_item points to the next token of the line, and is + * advanced over successfully-read tokens. + */ +static void parse_hba_auth(ListCell **line_item, UserAuth *userauth_p, + char **auth_arg_p, bool *error_p) +{ + char *token; + + *auth_arg_p = NULL; + + if (!*line_item) + { + *error_p = true; + return; + } + + token = lfirst(*line_item); + if (strcmp(token, "trust") == 0) + *userauth_p = uaTrust; + /* + else if (strcmp(token, "ident") == 0) + *userauth_p = uaIdent; + else if (strcmp(token, "password") == 0) + *userauth_p = uaPassword; + else if (strcmp(token, "krb4") == 0) + *userauth_p = uaKrb4; + else if (strcmp(token, "krb5") == 0) + *userauth_p = uaKrb5; + */ + else if (strcmp(token, "reject") == 0) + *userauth_p = uaReject; + /* + else if (strcmp(token, "md5") == 0) + *userauth_p = uaMD5; + else if (strcmp(token, "crypt") == 0) + *userauth_p = uaCrypt; + */ +#ifdef USE_PAM + else if (strcmp(token, "pam") == 0) + *userauth_p = uaPAM; +#endif /* USE_PAM */ + else + { + *error_p = true; + return; + } + *line_item = lnext(*line_item); + + /* Get the authentication argument token, if any */ + if (*line_item) + { + token = lfirst(*line_item); + *auth_arg_p = strdup(token); + if (*auth_arg_p == NULL) + { + pool_error("parse_hba_auth: strdup failed: %s", strerror(errno)); + exit(1); + } + *line_item = lnext(*line_item); + /* If there is more on the line, it is an error */ + if (*line_item) + *error_p = true; + } +} + + +/* + * Check comma user list for a specific user, handle group names. + */ +static bool check_user(char *user, char *param_str) +{ + char *tok; + + for (tok = strtok(param_str, MULTI_VALUE_SEP); + tok != NULL; tok = strtok(NULL, MULTI_VALUE_SEP)) + { + if (tok[0] == '+') + { + /* + * pgpool cannot accept groups. commented lines below are the + * original code. + */ + pool_error("group token \"+\" is not supported in pgpool"); + return false; +/* if (check_group(tok + 1, user)) */ +/* return true; */ + } + else if (strcmp(tok, user) == 0 || strcmp(tok, "all\n") == 0) + return true; + } + + return false; +} + + +/* + * Check to see if db/user combination matches param string. + */ +static bool check_db(char *dbname, char *user, char *param_str) +{ + char *tok; + + for (tok = strtok(param_str, MULTI_VALUE_SEP); + tok != NULL; tok = strtok(NULL, MULTI_VALUE_SEP)) + { + if (strcmp(tok, "all\n") == 0) + return true; + else if (strcmp(tok, "sameuser\n") == 0) + { + if (strcmp(dbname, user) == 0) + return true; + } + else if (strcmp(tok, "samegroup\n") == 0) + { + /* + * pgpool cannot accept groups. commented lines below are the + * original code. + */ + pool_error("group token \"samegroup\" is not supported in pgpool"); + return false; +/* if (check_group(dbname, user)) */ +/* return true; */ + } + else if (strcmp(tok, dbname) == 0) + return true; + } + + return false; +} + + +/* + * tokenize the given file, storing the resulting data into two lists: + * a list of sublists, each sublist containing the tokens in a line of + * the file, and a list of line numbers. + * + * filename must be the absolute path to the target file. + */ +static void tokenize_file(const char *filename, FILE *file, + List **lines, List **line_nums) +{ + List *current_line = NIL; + int line_number = 1; + char *buf; + + *lines = *line_nums = NIL; + + while (!feof(file)) + { + buf = next_token_expand(filename, file); + + /* add token to list, unless we are at EOL or comment start */ + if (buf[0]) + { + if (current_line == NIL) + { + /* make a new line List, record its line number */ + current_line = lappend(current_line, buf); + *lines = lappend(*lines, current_line); + *line_nums = lappend_int(*line_nums, line_number); + } + else + { + /* append token to current line's list */ + current_line = lappend(current_line, buf); + } + } + else + { + /* we are at real or logical EOL, so force a new line List */ + current_line = NIL; + /* Advance line number whenever we reach EOL */ + line_number++; + /* Don't forget to free the next_token_expand result */ + free(buf); + } + } +} + + +static char * tokenize_inc_file(const char *outer_filename, + const char *inc_filename) +{ + char *inc_fullname; + FILE *inc_file; + List *inc_lines; + List *inc_line_nums; + ListCell *line; + char *comma_str; + + if (is_absolute_path(inc_filename)) + { + /* absolute path is taken as-is */ + inc_fullname = strdup(inc_filename); + if (inc_fullname == NULL) + { + pool_error("tokenize_inc_file: strdup failed: %s", strerror(errno)); + exit(1); + } + } + else + { + /* relative path is relative to dir of calling file */ + inc_fullname = (char *)malloc(strlen(outer_filename) + 1 + + strlen(inc_filename) + 1); + if (inc_fullname == NULL) + { + pool_error("tokenize_inc_file: malloc failed: %s", strerror(errno)); + exit(1); + } + strcpy(inc_fullname, outer_filename); + get_parent_directory(inc_fullname); + join_path_components(inc_fullname, inc_fullname, inc_filename); + canonicalize_path(inc_fullname); + } + + inc_file = fopen(inc_fullname, "r"); + if (inc_file == NULL) + { + char *returnVal; + + pool_error("could not open secondary authentication file \"@%s\" as \"%s\": reason: %s", + inc_filename, inc_fullname, strerror(errno)); + free(inc_fullname); + + /* return single space, it matches nothing */ + returnVal = strdup(" "); + if (returnVal == NULL) + { + pool_error("tokenize_inc_file: malloc failed: %s", strerror(errno)); + exit(1); + } + return returnVal; + } + + /* There is possible recursion here if the file contains @ */ + tokenize_file(inc_fullname, inc_file, &inc_lines, &inc_line_nums); + + /*FreeFile(inc_file);*/ + fclose(inc_file); + free(inc_fullname); + + /* Create comma-separated string from List */ + comma_str = strdup(""); + if (comma_str == NULL) + { + pool_error("tokenize_inc_file: strdup failed: %s", strerror(errno)); + exit(1); + } + foreach(line, inc_lines) + { + List *token_list = (List *) lfirst(line); + ListCell *token; + + foreach(token, token_list) + { + int oldlen = strlen(comma_str); + int needed; + + needed = oldlen + strlen(lfirst(token)) + 1; + if (oldlen > 0) + needed++; + comma_str = realloc(comma_str, needed); + if (comma_str == NULL) + { + pool_error("tokenize_inc_file: realloc failed: %s", strerror(errno)); + exit(1); + } + if (oldlen > 0) + strcat(comma_str, MULTI_VALUE_SEP); + strcat(comma_str, lfirst(token)); + } + } + + free_lines(&inc_lines, &inc_line_nums); + + /* if file is empty, return single space rather than empty string */ + if (strlen(comma_str) == 0) + { + char *returnVal; + + free(comma_str); + returnVal = strdup(" "); + if (returnVal == NULL) + { + pool_error("tokenize_inc_file: strdup failed: %s", strerror(errno)); + exit(1); + } + return returnVal; + } + + return comma_str; +} + + +/* + * isblank() exists in the ISO C99 spec, but it's not very portable yet, + * so provide our own version. + */ +static bool pg_isblank(const char c) +{ + return c == ' ' || c == '\t' || c == '\r'; +} + + +/* + * Tokenize file and handle file inclusion and comma lists. We have + * to break apart the commas to expand any file names then + * reconstruct with commas. + * + * The result is always a malloc'd string. If it's zero-length then + * we have reached EOL. + */ +static char * next_token_expand(const char *filename, FILE *file) +{ + char buf[MAX_TOKEN]; + char *comma_str; + bool trailing_comma; + char *incbuf; + int needed; + + comma_str = strdup(""); + if (comma_str == NULL) + { + pool_error("next_token_expand: strdup failed: %s", strerror(errno)); + exit(1); + } + + do + { + next_token(file, buf, sizeof(buf)); + if (!buf[0]) + break; + + if (buf[strlen(buf) - 1] == ',') + { + trailing_comma = true; + buf[strlen(buf) - 1] = '\0'; + } + else + trailing_comma = false; + + /* Is this referencing a file? */ + if (buf[0] == '@') + incbuf = tokenize_inc_file(filename, buf + 1); + else + { + incbuf = strdup(buf); + if (incbuf == NULL) + { + pool_error("next_token_expand: strdup failed: %s", strerror(errno)); + exit(1); + } + } + + needed = strlen(comma_str) + strlen(incbuf) + 1; + if (trailing_comma) + needed++; + comma_str = realloc(comma_str, needed); + if (comma_str == NULL) + { + pool_error("next_token_expand: realloc failed: %s", strerror(errno)); + exit(1); + } + strcat(comma_str, incbuf); + if (trailing_comma) + strcat(comma_str, MULTI_VALUE_SEP); + free(incbuf); + } while (trailing_comma); + + return comma_str; +} + + +/* + * Grab one token out of fp. Tokens are strings of non-blank + * characters bounded by blank characters, beginning of line, and + * end of line. Blank means space or tab. Return the token as + * *buf. Leave file positioned at the character immediately after the + * token or EOF, whichever comes first. If no more tokens on line, + * return empty string as *buf and position the file to the beginning + * of the next line or EOF, whichever comes first. Allow spaces in + * quoted strings. Terminate on unquoted commas. Handle + * comments. Treat unquoted keywords that might be user names or + * database names specially, by appending a newline to them. + */ +static void next_token(FILE *fp, char *buf, int bufsz) +{ + int c; + char *start_buf = buf; + char *end_buf = buf + (bufsz - 2); + bool in_quote = false; + bool was_quote = false; + bool saw_quote = false; + + /*Assert(end_buf > start_buf);*/ + + /* Move over initial whitespace and commas */ + while ((c = getc(fp)) != EOF && (pg_isblank(c) || c == ',')) + ; + + if (c == EOF || c == '\n') + { + *buf = '\0'; + return; + } + + /* + * Build a token in buf of next characters up to EOF, EOL, unquoted + * comma, or unquoted whitespace. + */ + while (c != EOF && c != '\n' && + (!pg_isblank(c) || in_quote == true)) + { + /* skip comments to EOL */ + if (c == '#' && !in_quote) + { + while ((c = getc(fp)) != EOF && c != '\n') + ; + /* If only comment, consume EOL too; return EOL */ + if (c != EOF && buf == start_buf) + c = getc(fp); + break; + } + + if (buf >= end_buf) + { + *buf = '\0'; + pool_log("authentication file token too long, skipping: \"%s\"", start_buf); + /* Discard remainder of line */ + while ((c = getc(fp)) != EOF && c != '\n') + ; + break; + } + + if (c != '"' || (c == '"' && was_quote)) + *buf++ = c; + + /* We pass back the comma so the caller knows there is more */ + if ((pg_isblank(c) || c == ',') && !in_quote) + break; + + /* Literal double-quote is two double-quotes */ + if (in_quote && c == '"') + was_quote = !was_quote; + else + was_quote = false; + + if (c == '"') + { + in_quote = !in_quote; + saw_quote = true; + } + + c = getc(fp); + } + + /* + * Put back the char right after the token (critical in case it is + * EOL, since we need to detect end-of-line at next call). + */ + if (c != EOF) + ungetc(c, fp); + + *buf = '\0'; + + if (!saw_quote && + (strcmp(start_buf, "all") == 0 || + strcmp(start_buf, "sameuser") == 0 || + strcmp(start_buf, "samegroup") == 0)) + { + /* append newline to a magical keyword */ + *buf++ = '\n'; + *buf = '\0'; + } +} + + +/* + * free memory used by lines and tokens built by tokenize_file() + */ +static void free_lines(List **lines, List **line_nums) +{ + if (*lines) + { + ListCell *line; + + foreach(line, *lines) + { + List *ln = lfirst(line); + ListCell *token; + + foreach(token, ln) + free(lfirst(token)); + + list_free(ln); + } + + list_free(*lines); + *lines = NIL; + } + + if (*line_nums) + { + list_free(*line_nums); + *line_nums = NIL; + } +} + + +#ifdef USE_PAM + +/* + * PAM conversation function + */ +static int pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, + struct pam_response ** resp, void *appdata_ptr) +{ + if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF) + { + switch (msg[0]->msg_style) + { + case PAM_ERROR_MSG: + pool_log("error from underlying PAM layer: %s", + msg[0]->msg); + return PAM_CONV_ERR; + default: + pool_log("unsupported PAM conversation %d/%s", + msg[0]->msg_style, msg[0]->msg); + return PAM_CONV_ERR; + } + } + + if (!appdata_ptr) + { + /* + * Workaround for Solaris 2.6 where the PAM library is broken and + * does not pass appdata_ptr to the conversation routine + */ + appdata_ptr = pam_passwd; + } + + /* + * Password wasn't passed to PAM the first time around - let's go ask + * the client to send a password, which we then stuff into PAM. + */ + if (strlen(appdata_ptr) == 0) + { + char *passwd; + + sendAuthRequest(pam_frontend_kludge, AUTH_REQ_PASSWORD); + passwd = recv_password_packet(pam_frontend_kludge); + + if (passwd == NULL) + return PAM_CONV_ERR; /* client didn't want to send password */ + + if (strlen(passwd) == 0) + { + pool_log("empty password returned by client"); + return PAM_CONV_ERR; + } + appdata_ptr = passwd; + } + + /* + * PAM will free this memory in * pam_end() + */ + *resp = calloc(num_msg, sizeof(struct pam_response)); + if (!*resp) + { + /* originally, it was logged as LOG */ + pool_error("pam_passwd_conv_proc: calloc failed: %s", strerror(errno)); + return PAM_CONV_ERR; + } + + (*resp)[0].resp = strdup((char *) appdata_ptr); + if ((*resp)[0].resp == NULL) + { + pool_error("pam_passwd_conv_proc: strdup failed: %s", strerror(errno)); + exit(1); + } + (*resp)[0].resp_retcode = 0; + + return ((*resp)[0].resp ? PAM_SUCCESS : PAM_CONV_ERR); +} + + +/* + * Check authentication against PAM. + */ +static POOL_STATUS CheckPAMAuth(POOL_CONNECTION *frontend, char *user, char *password) +{ + int retval; + pam_handle_t *pamh = NULL; + + /* + * Apparently, Solaris 2.6 is broken, and needs ugly static variable + * workaround + */ + pam_passwd = password; + + /* + * Set the application data portion of the conversation struct This is + * later used inside the PAM conversation to pass the password to the + * authentication module. + */ + pam_passw_conv.appdata_ptr = (char *) password; /* from password above, + * not allocated */ + + /* Optionally, one can set the service name in pool_hba.conf */ + if (frontend->auth_arg && frontend->auth_arg[0] != '\0') + retval = pam_start(frontend->auth_arg, "pgpool@", + &pam_passw_conv, &pamh); + else + retval = pam_start(PGPOOL_PAM_SERVICE, "pgpool@", + &pam_passw_conv, &pamh); + + if (retval != PAM_SUCCESS) + { + pool_log("could not create PAM authenticator: %s", + pam_strerror(pamh, retval)); + pam_passwd = NULL; /* Unset pam_passwd */ + return POOL_ERROR; + } + + retval = pam_set_item(pamh, PAM_USER, user); + if (retval != PAM_SUCCESS) + { + pool_log("pam_set_item(PAM_USER) failed: %s", + pam_strerror(pamh, retval)); + pam_passwd = NULL; /* Unset pam_passwd */ + return POOL_ERROR; + } + + retval = pam_set_item(pamh, PAM_CONV, &pam_passw_conv); + if (retval != PAM_SUCCESS) + { + pool_log("pam_set_item(PAM_CONV) failed: %s", + pam_strerror(pamh, retval)); + pam_passwd = NULL; /* Unset pam_passwd */ + return POOL_ERROR; + } + + retval = pam_authenticate(pamh, 0); + if (retval != PAM_SUCCESS) /* service name does not exist */ + { + pool_log("pam_authenticate failed: %s", + pam_strerror(pamh, retval)); + pam_passwd = NULL; /* Unset pam_passwd */ + return POOL_ERROR; + } + + retval = pam_acct_mgmt(pamh, 0); + if (retval != PAM_SUCCESS) + { + pool_log("pam_acct_mgmt failed: %s", + pam_strerror(pamh, retval)); + pam_passwd = NULL; /* Unset pam_passwd */ + return POOL_ERROR; + } + + retval = pam_end(pamh, retval); + if (retval != PAM_SUCCESS) + { + pool_log("could not release PAM authenticator: %s", + pam_strerror(pamh, retval)); + } + + pam_passwd = NULL; /* Unset pam_passwd */ + + return (retval == PAM_SUCCESS ? POOL_CONTINUE : POOL_ERROR); +} + +#endif /* USE_PAM */ diff --git a/pool_hba.conf.sample b/pool_hba.conf.sample new file mode 100644 index 0000000..b2fe374 --- /dev/null +++ b/pool_hba.conf.sample @@ -0,0 +1,69 @@ +# pgpool Client Authentication Configuration File +# =============================================== +# +# The format rule in this file follows the rules in the PostgreSQL +# Administrator's Guide. Refer to chapter "Client Authentication" for a +# complete description. A short synopsis follows. +# +# This file controls: which hosts are allowed to connect, how clients +# are authenticated, which user names they can use, which databases they +# can access. Records take one of these forms: +# +# local DATABASE USER METHOD [OPTION] +# host DATABASE USER CIDR-ADDRESS METHOD [OPTION] +# hostnossl DATABASE USER CIDR-ADDRESS METHOD [OPTION] +# +# (The uppercase items must be replaced by actual values.) +# +# The first field is the connection type: "local" is a Unix-domain socket, +# "host" is a plain TCP/IP socket since pgpool currently doest not support +# SSL connection. "hostnossl" is also a plain TCP/IP socket. +# +# DATABASE can be "all", "sameuser", a database name, or a comma-separated +# list thereof. Note that "samegroup" like in PostgreSQL's pg_hba.conf +# file is not supported, since pgpool does not know which group a user +# belongs to. Also note that the database specified here may not exist in +# the backend PostgreSQL. pgpool will authenticate based on the database's +# name, not based on whether it exists or not. +# +# USER can be "all", a user name, or a comma-separated list thereof. In +# both the DATABASE and USER fields you can also write a file name prefixed +# with "@" to include names from a separate file. Note that a group name +# prefixed with "+" like in PostgreSQL's pg_hba.conf file is not supported +# because of the same reason as "samegroup" token. Also note that a user +# name specified here may not exist in the backend PostgreSQL. pgpool will +# authenticate based on the user's name, not based on whether he/she exists. +# +# CIDR-ADDRESS specifies the set of hosts the record matches. +# It is made up of an IP address and a CIDR mask that is an integer +# (between 0 and 32 (IPv4) that specifies the number of significant bits in +# the mask. Alternatively, you can write an IP address and netmask in +# separate columns to specify the set of hosts. +# +# METHOD can be "trust", "reject", or "pam". Note that "pam" sends passwords +# in clear text. +# +# OPTION is the name of the PAM service. Default service name is "pgpool" +# +# Database and user names containing spaces, commas, quotes and other special +# characters must be quoted. Quoting one of the keywords "all" or "sameuser" +# makes the name lose its special character, and just match a database or +# username with that name. +# +# This file is read on pgpool startup. If you edit the file on a running +# system, you have to restart the pgpool for the changes to take effect. + +# Put your actual configuration here +# ---------------------------------- +# +# If you want to allow non-local connections, you need to add more +# "host" records. In that case you will also need to make pgpool listen +# on a non-local interface via the listen_addresses configuration parameter. +# + +# TYPE DATABASE USER CIDR-ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all all trust +# IPv4 local connections: +host all all 127.0.0.1/32 trust diff --git a/pool_ip.c b/pool_ip.c new file mode 100644 index 0000000..86876cc --- /dev/null +++ b/pool_ip.c @@ -0,0 +1,565 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_ip.c,v 1.2.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * This file was imported from PostgreSQL 8.0.8 source code. + * See below for the copyright and description. + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008 PgPool Global Development Group + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * ------------------------------ + * + * + * This file and the IPV6 implementation were initially provided by + * Nigel Kukard , Linux Based Systems Design + * http://www.lbsd.net. + * + * pool_ip.c.: IPv6-aware network access. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "pool.h" +#include "pool_ip.h" + + +static int rangeSockAddrAF_INET(const struct sockaddr_in * addr, + const struct sockaddr_in * netaddr, + const struct sockaddr_in * netmask); + +#ifdef HAVE_IPV6 +static int rangeSockAddrAF_INET6(const struct sockaddr_in6 * addr, + const struct sockaddr_in6 * netaddr, + const struct sockaddr_in6 * netmask); +#endif + +static int getaddrinfo_unix(const char *path, + const struct addrinfo * hintsp, + struct addrinfo ** result); + +static int getnameinfo_unix(const struct sockaddr_un * sa, int salen, + char *node, int nodelen, + char *service, int servicelen, + int flags); + +/* + * pool_getnameinfo_all - get name info for Unix, IPv4 and IPv6 sockets + * caller MUST allocate NI_MAXHOST, NI_MAXSERV bytes for remote_host and remote_port + */ +void pool_getnameinfo_all(SockAddr *saddr, char *remote_host, char *remote_port) +{ + remote_host[0] = '\0'; + remote_port[0] = '\0'; + + if (getnameinfo_all(&saddr->addr, saddr->salen, + remote_host, NI_MAXHOST, + remote_port, NI_MAXSERV, + (pool_config->log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV)) + { + int ret = getnameinfo_all(&saddr->addr, saddr->salen, + remote_host, NI_MAXHOST, + remote_port, NI_MAXSERV, + NI_NUMERICHOST | NI_NUMERICSERV); + if (ret) + pool_error("getnameinfo_all() failed: %s", gai_strerror(ret)); + } +} + +/* + * getaddrinfo_all - get address info for Unix, IPv4 and IPv6 sockets + */ +int +getaddrinfo_all(const char *hostname, const char *servname, + const struct addrinfo * hintp, struct addrinfo ** result) +{ + /* not all versions of getaddrinfo() zero *result on failure */ + *result = NULL; + + if (hintp->ai_family == AF_UNIX) + return getaddrinfo_unix(servname, hintp, result); + + /* NULL has special meaning to getaddrinfo(). */ + return getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname, + servname, hintp, result); +} + + +/* + * freeaddrinfo_all - free addrinfo structures for IPv4, IPv6, or Unix + * + * Note: the ai_family field of the original hint structure must be passed + * so that we can tell whether the addrinfo struct was built by the system's + * getaddrinfo() routine or our own getaddrinfo_unix() routine. Some versions + * of getaddrinfo() might be willing to return AF_UNIX addresses, so it's + * not safe to look at ai_family in the addrinfo itself. + */ +void +freeaddrinfo_all(int hint_ai_family, struct addrinfo * ai) +{ + if (hint_ai_family == AF_UNIX) + { + /* struct was built by getaddrinfo_unix (see getaddrinfo_all) */ + while (ai != NULL) + { + struct addrinfo *p = ai; + + ai = ai->ai_next; + free(p->ai_addr); + free(p); + } + } + else + { + /* struct was built by getaddrinfo() */ + if (ai != NULL) + freeaddrinfo(ai); + } +} + + +/* + * getnameinfo_all - get name info for Unix, IPv4 and IPv6 sockets + * + * The API of this routine differs from the standard getnameinfo() definition + * in two ways: first, the addr parameter is declared as sockaddr_storage + * rather than struct sockaddr, and second, the node and service fields are + * guaranteed to be filled with something even on failure return. + */ +int +getnameinfo_all(const struct sockaddr_storage * addr, int salen, + char *node, int nodelen, + char *service, int servicelen, + int flags) +{ + int rc; + + if (addr && addr->ss_family == AF_UNIX) + rc = getnameinfo_unix((const struct sockaddr_un *) addr, salen, + node, nodelen, + service, servicelen, + flags); + else + rc = getnameinfo((const struct sockaddr *) addr, salen, + node, nodelen, + service, servicelen, + flags); + + if (rc != 0) + { + if (node) + strncpy(node, "???", nodelen); + if (service) + strncpy(service, "???", servicelen); + } + + return rc; +} + + +#ifndef HAVE_GAI_STRERROR +const char * +gai_strerror(int errcode) +{ +#ifdef HAVE_HSTRERROR + int hcode; + + switch (errcode) + { + case EAI_NONAME: + hcode = HOST_NOT_FOUND; + break; + case EAI_AGAIN: + hcode = TRY_AGAIN; + break; + case EAI_FAIL: + default: + hcode = NO_RECOVERY; + break; + } + + return hstrerror(hcode); +#else /* !HAVE_HSTRERROR */ + + switch (errcode) + { + case EAI_NONAME: + return "Unknown host"; + case EAI_AGAIN: + return "Host name lookup failure"; + /* Errors below are probably WIN32 only */ +#ifdef EAI_BADFLAGS + case EAI_BADFLAGS: + return "Invalid argument"; +#endif +#ifdef EAI_FAMILY + case EAI_FAMILY: + return "Address family not supported"; +#endif +#ifdef EAI_MEMORY + case EAI_MEMORY: + return "Not enough memory"; +#endif +#ifdef EAI_NODATA +#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the + * same value */ + case EAI_NODATA: + return "No host data of that type was found"; +#endif +#endif +#ifdef EAI_SERVICE + case EAI_SERVICE: + return "Class type not found"; +#endif +#ifdef EAI_SOCKTYPE + case EAI_SOCKTYPE: + return "Socket type not supported"; +#endif + default: + return "Unknown server error"; + } +#endif /* HAVE_HSTRERROR */ +} +#endif /* HAVE_GAI_STRERROR */ + + +/* + * getaddrinfo_unix - get unix socket info using IPv6-compatible API + * + * Bugs: only one addrinfo is set even though hintsp is NULL or + * ai_socktype is 0 + * AI_CANONNAME is not supported. + * + */ +static int +getaddrinfo_unix(const char *path, const struct addrinfo * hintsp, + struct addrinfo ** result) +{ + struct addrinfo hints; + struct addrinfo *aip; + struct sockaddr_un *unp; + + *result = NULL; + + memset(&hints, 0, sizeof(hints)); + + if (strlen(path) >= sizeof(unp->sun_path)) + return EAI_FAIL; + + if (hintsp == NULL) + { + hints.ai_family = AF_UNIX; + hints.ai_socktype = SOCK_STREAM; + } + else + memcpy(&hints, hintsp, sizeof(hints)); + + if (hints.ai_socktype == 0) + hints.ai_socktype = SOCK_STREAM; + + if (hints.ai_family != AF_UNIX) + { + /* shouldn't have been called */ + return EAI_FAIL; + } + + aip = calloc(1, sizeof(struct addrinfo)); + if (aip == NULL) + return EAI_MEMORY; + + unp = calloc(1, sizeof(struct sockaddr_un)); + if (unp == NULL) + { + free(aip); + return EAI_MEMORY; + } + + aip->ai_family = AF_UNIX; + aip->ai_socktype = hints.ai_socktype; + aip->ai_protocol = hints.ai_protocol; + aip->ai_next = NULL; + aip->ai_canonname = NULL; + *result = aip; + + unp->sun_family = AF_UNIX; + aip->ai_addr = (struct sockaddr *) unp; + aip->ai_addrlen = sizeof(struct sockaddr_un); + + strcpy(unp->sun_path, path); + +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN + unp->sun_len = sizeof(struct sockaddr_un); +#endif + + return 0; +} + +/* + * Convert an address to a hostname. + */ +static int +getnameinfo_unix(const struct sockaddr_un * sa, int salen, + char *node, int nodelen, + char *service, int servicelen, + int flags) +{ + int ret = -1; + + /* Invalid arguments. */ + if (sa == NULL || sa->sun_family != AF_UNIX || + (node == NULL && service == NULL)) + return EAI_FAIL; + + /* We don't support those. */ + if ((node && !(flags & NI_NUMERICHOST)) + || (service && !(flags & NI_NUMERICSERV))) + return EAI_FAIL; + + if (node) + { + ret = snprintf(node, nodelen, "%s", "[local]"); + if (ret == -1 || ret > nodelen) + return EAI_MEMORY; + } + + if (service) + { + ret = snprintf(service, servicelen, "%s", sa->sun_path); + if (ret == -1 || ret > servicelen) + return EAI_MEMORY; + } + + return 0; +} + + +/* + * rangeSockAddr - is addr within the subnet specified by netaddr/netmask ? + * + * Note: caller must already have verified that all three addresses are + * in the same address family; and AF_UNIX addresses are not supported. + */ +int +rangeSockAddr(const struct sockaddr_storage * addr, + const struct sockaddr_storage * netaddr, + const struct sockaddr_storage * netmask) +{ + if (addr->ss_family == AF_INET) + return rangeSockAddrAF_INET((struct sockaddr_in *) addr, + (struct sockaddr_in *) netaddr, + (struct sockaddr_in *) netmask); +#ifdef HAVE_IPV6 + else if (addr->ss_family == AF_INET6) + return rangeSockAddrAF_INET6((struct sockaddr_in6 *) addr, + (struct sockaddr_in6 *) netaddr, + (struct sockaddr_in6 *) netmask); +#endif + else + return 0; +} + +static int +rangeSockAddrAF_INET(const struct sockaddr_in * addr, + const struct sockaddr_in * netaddr, + const struct sockaddr_in * netmask) +{ + if (((addr->sin_addr.s_addr ^ netaddr->sin_addr.s_addr) & + netmask->sin_addr.s_addr) == 0) + return 1; + else + return 0; +} + + +#ifdef HAVE_IPV6 +static int +rangeSockAddrAF_INET6(const struct sockaddr_in6 * addr, + const struct sockaddr_in6 * netaddr, + const struct sockaddr_in6 * netmask) +{ + int i; + + for (i = 0; i < 16; i++) + { + if (((addr->sin6_addr.s6_addr[i] ^ netaddr->sin6_addr.s6_addr[i]) & + netmask->sin6_addr.s6_addr[i]) != 0) + return 0; + } + + return 1; +} +#endif + +/* + * SockAddr_cidr_mask - make a network mask of the appropriate family + * and required number of significant bits + * + * The resulting mask is placed in *mask, which had better be big enough. + * + * Return value is 0 if okay, -1 if not. + */ +int +SockAddr_cidr_mask(struct sockaddr_storage * mask, char *numbits, int family) +{ + long bits; + char *endptr; + + bits = strtol(numbits, &endptr, 10); + + if (*numbits == '\0' || *endptr != '\0') + return -1; + + switch (family) + { + case AF_INET: + { + struct sockaddr_in mask4; + long maskl; + + if (bits < 0 || bits > 32) + return -1; + /* avoid "x << 32", which is not portable */ + if (bits > 0) + maskl = (0xffffffffUL << (32 - (int) bits)) + & 0xffffffffUL; + else + maskl = 0; + mask4.sin_addr.s_addr = htonl(maskl); + memcpy(mask, &mask4, sizeof(mask4)); + break; + } + +#ifdef HAVE_IPV6 + case AF_INET6: + { + struct sockaddr_in6 mask6; + int i; + + if (bits < 0 || bits > 128) + return -1; + for (i = 0; i < 16; i++) + { + if (bits <= 0) + mask6.sin6_addr.s6_addr[i] = 0; + else if (bits >= 8) + mask6.sin6_addr.s6_addr[i] = 0xff; + else + { + mask6.sin6_addr.s6_addr[i] = + (0xff << (8 - (int) bits)) & 0xff; + } + bits -= 8; + } + memcpy(mask, &mask6, sizeof(mask6)); + break; + } +#endif + default: + return -1; + } + + mask->ss_family = family; + return 0; +} + + +#ifdef HAVE_IPV6 + +/* + * promote_v4_to_v6_addr --- convert an AF_INET addr to AF_INET6, using + * the standard convention for IPv4 addresses mapped into IPv6 world + * + * The passed addr is modified in place; be sure it is large enough to + * hold the result! Note that we only worry about setting the fields + * that rangeSockAddr will look at. + */ +static void +promote_v4_to_v6_addr(struct sockaddr_storage * addr) +{ + struct sockaddr_in addr4; + struct sockaddr_in6 addr6; + uint32 ip4addr; + + memcpy(&addr4, addr, sizeof(addr4)); + ip4addr = ntohl(addr4.sin_addr.s_addr); + + memset(&addr6, 0, sizeof(addr6)); + + addr6.sin6_family = AF_INET6; + + addr6.sin6_addr.s6_addr[10] = 0xff; + addr6.sin6_addr.s6_addr[11] = 0xff; + addr6.sin6_addr.s6_addr[12] = (ip4addr >> 24) & 0xFF; + addr6.sin6_addr.s6_addr[13] = (ip4addr >> 16) & 0xFF; + addr6.sin6_addr.s6_addr[14] = (ip4addr >> 8) & 0xFF; + addr6.sin6_addr.s6_addr[15] = (ip4addr) & 0xFF; + + memcpy(addr, &addr6, sizeof(addr6)); +} + +/* + * promote_v4_to_v6_mask --- convert an AF_INET netmask to AF_INET6, using + * the standard convention for IPv4 addresses mapped into IPv6 world + * + * This must be different from promote_v4_to_v6_addr because we want to + * set the high-order bits to 1's not 0's. + * + * The passed addr is modified in place; be sure it is large enough to + * hold the result! Note that we only worry about setting the fields + * that rangeSockAddr will look at. + */ +static void +promote_v4_to_v6_mask(struct sockaddr_storage * addr) +{ + struct sockaddr_in addr4; + struct sockaddr_in6 addr6; + uint32 ip4addr; + int i; + + memcpy(&addr4, addr, sizeof(addr4)); + ip4addr = ntohl(addr4.sin_addr.s_addr); + + memset(&addr6, 0, sizeof(addr6)); + + addr6.sin6_family = AF_INET6; + + for (i = 0; i < 12; i++) + addr6.sin6_addr.s6_addr[i] = 0xff; + + addr6.sin6_addr.s6_addr[12] = (ip4addr >> 24) & 0xFF; + addr6.sin6_addr.s6_addr[13] = (ip4addr >> 16) & 0xFF; + addr6.sin6_addr.s6_addr[14] = (ip4addr >> 8) & 0xFF; + addr6.sin6_addr.s6_addr[15] = (ip4addr) & 0xFF; + + memcpy(addr, &addr6, sizeof(addr6)); +} + +#endif /* HAVE_IPV6 */ + diff --git a/pool_ip.h b/pool_ip.h new file mode 100644 index 0000000..97bc7fe --- /dev/null +++ b/pool_ip.h @@ -0,0 +1,65 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_ip.h,v 1.2 2008/01/29 01:56:36 y-asaba Exp $ + * + * This file was imported from PostgreSQL 8.0.8 source code. + * See below for the copyright and description. + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008 PgPool Global Development Group + * Portions Copyright (c) 2003-2005, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_ip.h.: Definitions for IPv6-aware network access. + * + */ + +#ifndef POOL_IP_H +#define POOL_IP_H + +#include "pool_type.h" + +extern int getaddrinfo_all(const char *hostname, const char *servname, + const struct addrinfo * hintp, + struct addrinfo ** result); +extern void freeaddrinfo_all(int hint_ai_family, struct addrinfo * ai); + +extern int getnameinfo_all(const struct sockaddr_storage * addr, int salen, + char *node, int nodelen, + char *service, int servicelen, + int flags); + +extern int rangeSockAddr(const struct sockaddr_storage * addr, + const struct sockaddr_storage * netaddr, + const struct sockaddr_storage * netmask); + +extern int SockAddr_cidr_mask(struct sockaddr_storage * mask, + char *numbits, int family); + +/* imported from PostgreSQL getaddrinfo.c */ +#ifndef HAVE_GAI_STRERROR +extern const char * gai_strerror(int errcode); +#endif /* HAVE_GAI_STRERROR */ + +#ifdef HAVE_IPV6 +extern void promote_v4_to_v6_addr(struct sockaddr_storage * addr); +extern void promote_v4_to_v6_mask(struct sockaddr_storage * addr); +#endif + +#define IS_AF_INET(fam) ((fam) == AF_INET) +#define IS_AF_UNIX(fam) ((fam) == AF_UNIX) + +#endif /* IP_H */ diff --git a/pool_ipc.h b/pool_ipc.h new file mode 100644 index 0000000..577fa4b --- /dev/null +++ b/pool_ipc.h @@ -0,0 +1,38 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_ipc.h,v 1.3 2008/01/29 01:56:36 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 2003-2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + */ +#ifndef IPC_H +#define IPC_H + + +typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */ + + +#define IPCProtection (0600) /* access/modify by user only */ + + +extern void shmem_exit(int code); +extern void on_shmem_exit(void (*function) (int code, Datum arg), Datum arg); +extern void on_exit_reset(void); + + +#endif /* IPC_H */ diff --git a/pool_params.c b/pool_params.c new file mode 100644 index 0000000..e23f366 --- /dev/null +++ b/pool_params.c @@ -0,0 +1,161 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_params.c,v 1.3.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * params.c: Paramter Status handling routines + * + */ +#include "config.h" + +#include +#include + +#include "pool.h" + +#define MAX_PARAM_ITEMS 128 + +/* + * initialize parameter structure + */ +int pool_init_params(ParamStatus *params) +{ + params->num = 0; + params->names = malloc(MAX_PARAM_ITEMS*sizeof(char *)); + if (params->names == NULL) + { + pool_error("pool_init_params: cannot allocate memory"); + return -1; + } + params->values = malloc(MAX_PARAM_ITEMS*sizeof(char *)); + if (params->values == NULL) + { + pool_error("pool_init_params: cannot allocate memory"); + return -1; + } + return 0; +} + +/* + * discard parameter structure + */ +void pool_discard_params(ParamStatus *params) +{ + int i; + + for (i=0;inum;i++) + { + free(params->names[i]); + free(params->values[i]); + } + free(params->names); + free(params->values); +} + +/* + * find param value by name. if found, its value is returned + * also, pos is set + * if not found, NULL is returned + */ +char *pool_find_name(ParamStatus *params, char *name, int *pos) +{ + int i; + + for (i=0;inum;i++) + { + if (!strcmp(name, params->names[i])) + { + *pos = i; + return params->values[i]; + } + } + return NULL; +} + +/* + * return name and value by index. + */ +int pool_get_param(ParamStatus *params, int index, char **name, char **value) +{ + if (index < 0 || index >= params->num) + return -1; + + *name = params->names[index]; + *value = params->values[index]; + + return 0; +} + +/* + * add or replace name/value pair + */ +int pool_add_param(ParamStatus *params, char *name, char *value) +{ + int pos; + + if (pool_find_name(params, name, &pos)) + { + /* name already exists */ + if (strlen(params->values[pos]) < strlen(value)) + { + params->values[pos] = realloc(params->values[pos], strlen(value) + 1); + if (params->values[pos] == NULL) + { + pool_error("pool_init_params: cannot allocate memory"); + return -1; + } + } + strcpy(params->values[pos], value); + } + else + { + int num; + + /* add name/value pair */ + if (params->num >= MAX_PARAM_ITEMS) + { + pool_error("pool_add_param: no more room for num"); + return -1; + } + num = params->num; + params->names[num] = strdup(name); + if (params->names[num] == NULL) + { + pool_error("pool_init_params: cannot allocate memory"); + return -1; + } + params->values[num] = strdup(value); + if (params->values[num] == NULL) + { + pool_error("pool_init_params: cannot allocate memory"); + return -1; + } + params->num++; + } + return 0; +} + +void pool_param_debug_print(ParamStatus *params) +{ + int i; + + for (i=0;inum;i++) + { + pool_debug("No.%d: name: %s value: %s", i, params->names[i], params->values[i]); + } +} diff --git a/pool_path.c b/pool_path.c new file mode 100644 index 0000000..15163cf --- /dev/null +++ b/pool_path.c @@ -0,0 +1,193 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_path.c,v 1.2.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_path.c.: small functions to manipulate paths + * + */ + +#include "pool_type.h" +#include "pool_path.h" +#include +#include + +static void trim_directory(char *path); +static void trim_trailing_separator(char *path); + +/* + * get_parent_directory + * + * Modify the given string in-place to name the parent directory of the + * named file. + */ +void get_parent_directory(char *path) +{ + trim_directory(path); +} + + +/* + * trim_directory + * + * Trim trailing directory from path, that is, remove any trailing slashes, + * the last pathname component, and the slash just ahead of it --- but never + * remove a leading slash. + */ +static void trim_directory(char *path) +{ + char *p; + + if (path[0] == '\0') + return; + + /* back up over trailing slash(es) */ + for (p = path + strlen(path) - 1; IS_DIR_SEP(*p) && p > path; p--); + + /* back up over directory name */ + for (; !IS_DIR_SEP(*p) && p > path; p--); + + /* if multiple slashes before directory name, remove 'em all */ + for (; p > path && IS_DIR_SEP(*(p - 1)); p--); + + /* don't erase a leading slash */ + if (p == path && IS_DIR_SEP(*p)) + p++; + + *p = '\0'; +} + + +/* + * join_path_components - join two path components, inserting a slash + * + * ret_path is the output area (must be of size MAXPGPATH) + * + * ret_path can be the same as head, but not the same as tail. + */ +void join_path_components(char *ret_path, const char *head, const char *tail) +{ + if (ret_path != head) + StrNCpy(ret_path, head, MAXPGPATH); + + /* + * Remove any leading "." and ".." in the tail component, + * adjusting head as needed. + */ + for (;;) + { + if (tail[0] == '.' && IS_DIR_SEP(tail[1])) + { + tail += 2; + } + else if (tail[0] == '.' && tail[1] == '\0') + { + tail += 1; + break; + } + else if (tail[0] == '.' && tail[1] == '.' && IS_DIR_SEP(tail[2])) + { + trim_directory(ret_path); + tail += 3; + } + else if (tail[0] == '.' && tail[1] == '.' && tail[2] == '\0') + { + trim_directory(ret_path); + tail += 2; + break; + } + else + break; + } + + if (*tail) + snprintf(ret_path + strlen(ret_path), MAXPGPATH - strlen(ret_path), "/%s", tail); +} + + +/* + * Clean up path by: + * o remove trailing slash + * o remove duplicate adjacent separators + * o remove trailing '.' + * o process trailing '..' ourselves + */ +void canonicalize_path(char *path) +{ + char *p, *to_p; + bool was_sep = false; + + /* + * Removing the trailing slash on a path means we never get ugly + * double trailing slashes. + */ + trim_trailing_separator(path); + + /* + * Remove duplicate adjacent separators + */ + p = path; + to_p = p; + for (; *p; p++, to_p++) + { + /* Handle many adjacent slashes, like "/a///b" */ + while (*p == '/' && was_sep) + p++; + if (to_p != p) + *to_p = *p; + was_sep = (*p == '/'); + } + *to_p = '\0'; + + /* + * Remove any trailing uses of "." and process ".." ourselves + */ + for (;;) + { + int len = strlen(path); + + if (len > 2 && strcmp(path + len - 2, "/.") == 0) + trim_directory(path); + else if (len > 3 && strcmp(path + len - 3, "/..") == 0) + { + trim_directory(path); + trim_directory(path); + /* remove directory above */ + } + else + break; + } +} + + +/* + * trim_trailing_separator + * + * trim off trailing slashes, but not a leading slash + */ +static void trim_trailing_separator(char *path) +{ + char *p; + + p = path + strlen(path); + if (p > path) + for (p--; p > path && IS_DIR_SEP(*p); p--) + *p = '\0'; +} diff --git a/pool_path.h b/pool_path.h new file mode 100644 index 0000000..9c50fd7 --- /dev/null +++ b/pool_path.h @@ -0,0 +1,81 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_path.h,v 1.2 2008/01/29 01:56:36 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_path.h.: interface to pool_path.c + * + */ + +#ifndef POOL_PATH_H +#define POOL_PATH_H + +/* + * MAXPGPATH: standard size of a pathname buffer in PostgreSQL (hence, + * maximum usable pathname length is one less). + * + * We'd use a standard system header symbol for this, if there weren't + * so many to choose from: MAXPATHLEN, MAX_PATH, PATH_MAX are all + * defined by different "standards", and often have different values + * on the same platform! So we just punt and use a reasonably + * generous setting here. + */ +#define MAXPGPATH 1024 + +#define IS_DIR_SEP(ch) ((ch) == '/') +#define is_absolute_path(filename) \ +( \ + ((filename)[0] == '/') \ +) + +/* + * StrNCpy + * Like standard library function strncpy(), except that result string + * is guaranteed to be null-terminated --- that is, at most N-1 bytes + * of the source string will be kept. + * Also, the macro returns no result (too hard to do that without + * evaluating the arguments multiple times, which seems worse). + * + * BTW: when you need to copy a non-null-terminated string (like a text + * datum) and add a null, do not do it with StrNCpy(..., len+1). That + * might seem to work, but it fetches one byte more than there is in the + * text object. One fine day you'll have a SIGSEGV because there isn't + * another byte before the end of memory. Don't laugh, we've had real + * live bug reports from real live users over exactly this mistake. + * Do it honestly with "memcpy(dst,src,len); dst[len] = '\0';", instead. + */ +#define StrNCpy(dst,src,len) \ + do \ + { \ + char * _dst = (dst); \ + size_t _len = (len); \ +\ + if (_len > 0) \ + { \ + strncpy(_dst, (src), _len); \ + _dst[_len-1] = '\0'; \ + } \ + } while (0) + +extern void get_parent_directory(char *path); +extern void join_path_components(char *ret_path, const char *head, const char *tail); +extern void canonicalize_path(char *path); + +#endif /* POOL_PATH_H */ diff --git a/pool_process_query.c b/pool_process_query.c new file mode 100644 index 0000000..5cf2b69 --- /dev/null +++ b/pool_process_query.c @@ -0,0 +1,4518 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.141.2.22 2009/10/02 07:53:08 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_process_query.c: query processing stuff + * +*/ +#include "config.h" +#include + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + + +#include +#include +#include +#include +#include + +#include "pool.h" +#include "pool_signal.h" +#include "pool_proto_modules.h" + +#ifndef FD_SETSIZE +#define FD_SETSIZE 512 +#endif + +#define INIT_STATEMENT_LIST_SIZE 8 + +#define ACTIVE_SQL_TRANSACTION_ERROR_CODE "25001" /* SET TRANSACTION ISOLATION LEVEL must be called before any query */ +#define DEADLOCK_ERROR_CODE "40P01" +#define SERIALIZATION_FAIL_ERROR_CODE "40001" +#define QUERY_CANCEL_ERROR_CODE "57014" +#define ADMIN_SHUTDOWN_ERROR_CODE "57P01" +#define CRASH_SHUTDOWN_ERROR_CODE "57P02" + +static int reset_backend(POOL_CONNECTION_POOL *backend, int qcnt); +static POOL_STATUS do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *query, int protoMajor, int pid, int key, int no_ready_for_query); +static POOL_STATUS do_error_execute_command(POOL_CONNECTION_POOL *backend, int node_id, int major); +static char *get_insert_command_table_name(InsertStmt *node); +static void reset_prepared_list(PreparedStatementList *p); +static int send_deallocate(POOL_CONNECTION_POOL *backend, PreparedStatementList *p, int n); +static int is_cache_empty(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +static POOL_STATUS ParallelForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *database, bool send_to_frontend); +static void query_cache_register(char kind, POOL_CONNECTION *frontend, char *database, char *data, int data_len); +static int extract_ntuples(char *message); +static int detect_error(POOL_CONNECTION *master, char *error_code, int major, char class, bool unread); +static int detect_postmaster_down_error(POOL_CONNECTION *master, int major); +static void free_select_result(POOL_SELECT_RESULT *result); + +static bool is_internal_transaction_needed(Node *node); +static int compare(const void *p1, const void *p2); + +/* timeout sec for pool_check_fd */ +static int timeoutsec; + +int in_load_balance; /* non 0 if in load balance mode */ +int selected_slot; /* selected DB node */ +int master_slave_dml; /* non 0 if master/slave mode is specified in config file */ + +/* + * main module for query processing + */ +POOL_STATUS pool_process_query(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + int connection_reuse, + int first_ready_for_query_received) +{ + char kind; /* packet kind (backend) */ + char fkind; /* packet kind (frontend) */ + short num_fields = 0; + fd_set readmask; + fd_set writemask; + fd_set exceptmask; + int fds; + POOL_STATUS status; + int state; /* 0: ok to issue commands 1: waiting for "ready for query" response */ + int qcnt; + int i; + + frontend->no_forward = connection_reuse; + qcnt = 0; + state = 0; + + for (;;) + { + kind = 0; + fkind = 0; + + if (state == 0 && connection_reuse) + { + int st; + + /* send query for resetting connection such as "ROLLBACK" "RESET ALL"... */ + st = reset_backend(backend, qcnt); + + if (st < 0) /* error? */ + { + /* probably we don't need this, since caller will + * close the connection to frontend after returning with POOL_END. But I + * guess I would like to be a paranoid... + */ + frontend->no_forward = 0; + return POOL_END; + } + + else if (st == 0) /* no query issued? */ + { + qcnt++; + continue; + } + + else if (st == 1) /* more query remains */ + { + state = 1; + qcnt++; + continue; + } + + else /* no more query(st == 2) */ + { + TSTATE(backend) = 'I'; + frontend->no_forward = 0; + return POOL_CONTINUE; + } + + } + + /* + * if all backends do not have any pending data in the + * receiving data cache, then issue select(2) to wait for new + * data arrival + */ + if (is_cache_empty(frontend, backend)) + { + struct timeval timeoutdata; + struct timeval *timeout; + int num_fds, was_error = 0; + + /* + * frontend idle counters. depends on the following + * select(2) call's time out is 1 second. + */ + int idle_count = 0; /* for other than in recovery */ + int idle_count_in_recovery = 0; /* for in recovery */ + + SELECT_RETRY: + FD_ZERO(&readmask); + FD_ZERO(&writemask); + FD_ZERO(&exceptmask); + + num_fds = 0; + + /* + * Do not read a message from frontend while backends process a query. + */ + if (!connection_reuse && !in_progress) + { + FD_SET(frontend->fd, &readmask); + FD_SET(frontend->fd, &exceptmask); + num_fds = Max(frontend->fd + 1, num_fds); + } + + /* + * If we are in load balance mode and the selected node is + * down, we need to re-select load_balancing_node. Note + * that we cannnot use VALID_BACKEND macro here. If + * in_load_balance == 1, VALID_BACKEND macro may return 0. + */ + if (pool_config->load_balance_mode && + BACKEND_INFO(backend->info->load_balancing_node).backend_status == CON_DOWN) + { + /* select load balancing node */ + backend->info->load_balancing_node = select_load_balancing_node(); + } + + for (i=0;ifd + 1, num_fds); + FD_SET(CONNECTION(backend, i)->fd, &readmask); + FD_SET(CONNECTION(backend, i)->fd, &exceptmask); + } + } + + /* + * wait for data arriving from frontend and backend + */ + if (pool_config->client_idle_limit > 0 || + pool_config->client_idle_limit_in_recovery > 0) + { + timeoutdata.tv_sec = 1; + timeoutdata.tv_usec = 0; + timeout = &timeoutdata; + } + else + timeout = NULL; + + fds = select(num_fds, &readmask, &writemask, &exceptmask, timeout); + + if (fds == -1) + { + if (errno == EINTR) + continue; + + pool_error("select() failed. reason: %s", strerror(errno)); + return POOL_ERROR; + } + + /* select timeout */ + if (fds == 0) + { + if (*InRecovery == 0 && pool_config->client_idle_limit > 0) + { + idle_count++; + + if (idle_count > pool_config->client_idle_limit) + { + pool_log("pool_process_query: child connection forced to terminate due to client_idle_limit(%d) reached", pool_config->client_idle_limit); + return POOL_END; + } + } + else if (*InRecovery > 0 && pool_config->client_idle_limit_in_recovery > 0) + { + idle_count_in_recovery++; + + if (idle_count_in_recovery > pool_config->client_idle_limit_in_recovery) + { + pool_log("pool_process_query: child connection forced to terminate due to client_idle_limit_in_recovery(%d) reached", pool_config->client_idle_limit_in_recovery); + return POOL_END; + } + } + goto SELECT_RETRY; + } + + for (i = 0; i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i)) + { + /* + * make sure that connection slot exists + */ + if (CONNECTION_SLOT(backend, i) == 0) + { + pool_log("FATAL ERROR: VALID_BACKEND returns non 0 but connection slot is empty. backend id:%d RAW_MODE:%d in_load_balance:%d LOAD_BALANCE_STATUS:%d status:%d", + i, RAW_MODE, in_load_balance, LOAD_BALANCE_STATUS(i), BACKEND_INFO(i).backend_status); + was_error = 1; + break; + } + + if (FD_ISSET(CONNECTION(backend, i)->fd, &readmask)) + { + /* + * admin shutdown postmaster or postmaster goes down + */ + if (detect_postmaster_down_error(CONNECTION(backend, i), MAJOR(backend)) == SPECIFIED_ERROR) + { + /* detach backend node. */ + was_error = 1; + if (!VALID_BACKEND(i)) + break; + notice_backend_error(i); + sleep(5); + break; + } + status = read_kind_from_backend(frontend, backend, &kind); + if (status != POOL_CONTINUE) + return status; + break; + } + } + } + + if (was_error) + continue; + + if (!connection_reuse && !in_progress) + { + if (FD_ISSET(frontend->fd, &exceptmask)) + return POOL_END; + else if (FD_ISSET(frontend->fd, &readmask)) + { + status = ProcessFrontendResponse(frontend, backend); + if (status != POOL_CONTINUE) + return status; + + continue; + } + if (kind == 0) + continue; + } + + if (FD_ISSET(MASTER(backend)->fd, &exceptmask)) + { + return POOL_ERROR; + } + } + else + { + if (frontend->len > 0 && !in_progress) + { + status = ProcessFrontendResponse(frontend, backend); + if (status != POOL_CONTINUE) + return status; + + continue; + } + } + + /* this is the synchronous point */ + if (kind == 0) + { + status = read_kind_from_backend(frontend, backend, &kind); + if (status != POOL_CONTINUE) + return status; + } + + /* reload config file */ + if (got_sighup) + { + pool_get_config(get_config_file_name(), RELOAD_CONFIG); + if (pool_config->enable_pool_hba) + load_hba(get_hba_file_name()); + if (pool_config->parallel_mode) + pool_memset_system_db_info(system_db_info->info); + got_sighup = 0; + } + + first_ready_for_query_received = 0; + + /* + * Process backend Response + */ + + /* + * Sanity check + */ + if (kind == 0) + { + pool_error("pool_process_query: kind is 0!"); + return POOL_ERROR; + } + + pool_debug("pool_process_query: kind from backend: %c", kind); + + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + switch (kind) + { + case 'G': + /* CopyIn response */ + status = CopyInResponse(frontend, backend); + break; + case 'S': + /* Parameter Status */ + status = ParameterStatus(frontend, backend); + break; + case 'Z': + /* Ready for query */ + status = ReadyForQuery(frontend, backend, 1); + break; + default: + status = SimpleForwardToFrontend(kind, frontend, backend); + if (pool_flush(frontend)) + return POOL_END; + break; + } + } + else + { + switch (kind) + { + case 'A': + /* Notification response */ + status = NotificationResponse(frontend, backend); + break; + + case 'B': + /* BinaryRow */ + status = BinaryRow(frontend, backend, num_fields); + break; + + case 'C': + /* Complete command response */ + status = CompleteCommandResponse(frontend, backend); + break; + + case 'D': + /* AsciiRow */ + status = AsciiRow(frontend, backend, num_fields); + break; + + case 'E': + /* Error Response */ + status = ErrorResponse(frontend, backend); + break; + + case 'G': + /* CopyIn Response */ + status = CopyInResponse(frontend, backend); + break; + + case 'H': + /* CopyOut Response */ + status = CopyOutResponse(frontend, backend); + break; + + case 'I': + /* Empty Query Response */ + status = EmptyQueryResponse(frontend, backend); + break; + + case 'N': + /* Notice Response */ + status = NoticeResponse(frontend, backend); + break; + + case 'P': + /* CursorResponse */ + status = CursorResponse(frontend, backend); + break; + + case 'T': + /* RowDescription */ + status = RowDescription(frontend, backend, &num_fields); + break; + + case 'V': + /* FunctionResultResponse and FunctionVoidResponse */ + status = FunctionResultResponse(frontend, backend); + break; + + case 'Z': + /* Ready for query */ + status = ReadyForQuery(frontend, backend, 1); + break; + + default: + pool_error("Unknown message type %c(%02x)", kind, kind); + exit(1); + } + } + + if (status != POOL_CONTINUE) + return status; + + if (kind == 'Z' && frontend->no_forward && state == 1) + { + state = 0; + } + + } + return POOL_CONTINUE; +} + + +/* + * set_fd,isset_fs,zero_fd are used + * for check fd in parallel mode + */ + +/* used only in pool_parallel_exec */ +#define BITS (8 * sizeof(long int)) + +static void set_fd(unsigned long fd ,unsigned long *setp) +{ + unsigned long tmp = fd / FD_SETSIZE; + unsigned long rem = fd % FD_SETSIZE; + setp[tmp] |= (1UL< 0) + stime = sleep(stime); + } + + /* process status reporting? */ + if (strncasecmp(sq, string, strlen(sq)) == 0) + { + pool_debug("process reporting"); + process_reporting(frontend, backend); + in_progress = 0; + return POOL_CONTINUE; + } + + /* In this loop,forward the query to the all backends */ + for (i=0;ifd; + num_fds = Max(fd + 1, num_fds); + if(!isset_fd(fd,donemask)) + { + FD_SET(fd, &readmask); + FD_SET(fd, &exceptmask); + pool_debug("pool_parallel_query: %d th FD_SET: %d",i, CONNECTION(backend, i)->fd); + } + } + } + + pool_debug("pool_parallel_query: num_fds: %d", num_fds); + + fds = select(num_fds, &readmask, &writemask, &exceptmask, NULL); + + if (fds == -1) + { + if (errno == EINTR) + continue; + + pool_error("select() failed. reason: %s", strerror(errno)); + return POOL_ERROR; + } + + if (fds == 0) + { + return POOL_CONTINUE; + } + + /* get header of protocol */ + for (i=0;ifd, &readmask)) + { + continue; + } + else + { + status = read_kind_from_one_backend(frontend, backend, &kind,i); + if (status != POOL_CONTINUE) + return status; + + if (used_count == 0) + { + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + send_to_frontend); + pool_debug("pool_parallel_exec: kind from backend: %c", kind); + } + else + { + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + false); + pool_debug("pool_parallel_exec: dummy kind from backend: %c", kind); + } + + if (status != POOL_CONTINUE) + return status; + + if(kind == 'C' || kind == 'E' || kind == 'c') + { + if(used_count == NUM_BACKENDS -1) + return POOL_CONTINUE; + + used_count++; + set_fd(CONNECTION(backend, i)->fd, donemask); + continue; + } + + /* get body of protocol */ + for(;;) + { + if (pool_read(CONNECTION(backend, i), &kind, 1) < 0) + { + pool_error("pool_parallel_exec: failed to read kind from %d th backend", i); + return POOL_ERROR; + } + + /* + * Sanity check + */ + if (kind == 0) + { + pool_error("pool_parallel_exec: kind is 0!"); + return POOL_ERROR; + } + + if((kind == 'E' ) && + used_count != NUM_BACKENDS -1) + { + if(error_flag ==0) + { + pool_debug("pool_parallel_exec: kind from backend: %c", kind); + + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + send_to_frontend); + error_flag++; + } else { + pool_debug("pool_parallel_exec: dummy from backend: %c", kind); + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + false); + } + used_count++; + set_fd(CONNECTION(backend, i)->fd, donemask); + break; + } + + if((kind == 'c' || kind == 'C') && + used_count != NUM_BACKENDS -1) + { + pool_debug("pool_parallel_exec: dummy from backend: %c", kind); + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + false); + used_count++; + set_fd(CONNECTION(backend, i)->fd, donemask); + break; + } + if((kind == 'C' || kind == 'c' || kind == 'E') && + used_count == NUM_BACKENDS -1) + { + pool_debug("pool_parallel_exec: kind from backend: D %lu", datacount); + + if(error_flag == 0) + { + pool_debug("pool_parallel_exec: kind from backend: %c", kind); + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + send_to_frontend); + } else { + pool_debug("pool_parallel_exec: dummy from backend: %c", kind); + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + false); + } + return POOL_CONTINUE; + } + + if(kind == 'D') + datacount++; + else + pool_debug("pool_parallel_exec: kind from backend: %c", kind); + + status = ParallelForwardToFrontend(kind, + frontend, + CONNECTION(backend, i), + backend->info->database, + send_to_frontend); + + if (status != POOL_CONTINUE) + { + return status; + } + else + { + pool_flush(frontend); + } + } + } + } + } +} + + + +/* + * send SimpleQuery message to a node. + */ +POOL_STATUS send_simplequery_message(POOL_CONNECTION *backend, int len, char *string, int major) +{ + /* forward the query to the backend */ + pool_write(backend, "Q", 1); + + if (major == PROTO_MAJOR_V3) + { + int sendlen = htonl(len + 4); + pool_write(backend, &sendlen, sizeof(sendlen)); + } + + if (pool_write_and_flush(backend, string, len) < 0) + { + return POOL_END; + } + + return POOL_CONTINUE; +} + +/* + * Wait for query response from single node. This checks frontend + * connection by writing dummy parameter status packet every 30 + * seccond, and if the connection broke, returns error since there's + * no point in that waiting until backend returns response. + */ +POOL_STATUS wait_for_query_response(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *string, int protoVersion) +{ +#define DUMMY_PARAMETER "pgpool_dummy_param" +#define DUMMY_VALUE "pgpool_dummy_value" + + int status; + int plen; + + pool_debug("wait_for_query_response: waiting for backend %d completing the query", backend->db_node_id); + + for (;;) + { + /* Check to see if data from backend is ready */ + pool_set_timeout(30); + status = pool_check_fd(backend); + pool_set_timeout(0); + + if (status < 0) /* error ? */ + { + pool_error("wait_for_query_response: backend error occured while waiting for backend response"); + return POOL_END; + } + else if (status > 0) /* data is not ready */ + { + if (protoVersion == PROTO_MAJOR_V3) + { + /* Write dummy parameter staus packet to check if the socket to frontend is ok */ + if (pool_write(frontend, "S", 1) < 0) + return POOL_END; + plen = sizeof(DUMMY_PARAMETER)+sizeof(DUMMY_VALUE)+sizeof(plen); + plen = htonl(plen); + if (pool_write(frontend, &plen, sizeof(plen)) < 0) + return POOL_END; + if (pool_write(frontend, DUMMY_PARAMETER, sizeof(DUMMY_PARAMETER)) < 0) + return POOL_END; + if (pool_write(frontend, DUMMY_VALUE, sizeof(DUMMY_VALUE)) < 0) + return POOL_END; + if (pool_flush_it(frontend) < 0) + { + pool_error("wait_for_query_response: frontend error occured while waiting for backend reply"); + return POOL_END; + } + + } else /* Protocol version 2 */ + { +/* + * If you want to monitor client connection even if you are using V2 protocol, + * define following + */ +#undef SEND_NOTICE_ON_PROTO2 +#ifdef SEND_NOTICE_ON_PROTO2 + static char *notice_message = {"keep alive checking from pgpool-II"}; + + /* Write notice message packet to check if the socket to frontend is ok */ + if (pool_write(frontend, "N", 1) < 0) + return POOL_END; + if (pool_write(frontend, notice_message, strlen(notice_message)+1) < 0) + return POOL_END; + if (pool_flush_it(frontend) < 0) + { + pool_error("wait_for_query_response: frontend error occured while waiting for backend reply"); + return POOL_END; + } +#endif + } + } + else + break; + } + + return POOL_CONTINUE; +} + + +/* + * Extended query protocol has to send Flush message. + */ +POOL_STATUS send_extended_protocol_message(POOL_CONNECTION_POOL *backend, + int node_id, char *kind, + int len, char *string) +{ + POOL_CONNECTION *cp = CONNECTION(backend, node_id); + int sendlen; + + /* forward the query to the backend */ + pool_write(cp, kind, 1); + sendlen = htonl(len + 4); + pool_write(cp, &sendlen, sizeof(sendlen)); + pool_write(cp, string, len); + + /* + * send "Flush" message so that backend notices us + * the completion of the command + */ + pool_write(cp, "H", 1); + sendlen = htonl(4); + if (pool_write_and_flush(cp, &sendlen, sizeof(sendlen)) < 0) + { + return POOL_ERROR; + } + + return POOL_CONTINUE; +} + +POOL_STATUS send_execute_message(POOL_CONNECTION_POOL *backend, + int node_id, int len, char *string) +{ + return send_extended_protocol_message(backend, node_id, "E", len, string); +} + +/* + * wait until read data is ready + */ +int synchronize(POOL_CONNECTION *cp) +{ + return pool_check_fd(cp); +} + +/* + * set timeout in seconds for pool_check_fd + * if timeoutval < 0, we assume no timeout(wait forever). + */ +void pool_set_timeout(int timeoutval) +{ + if (timeoutval > 0) + timeoutsec = timeoutval; + else + timeoutsec = 0; +} + +/* + * Wait until read data is ready. + * return values: 0: normal 1: data is not ready -1: error + */ +int pool_check_fd(POOL_CONNECTION *cp) +{ + fd_set readmask; + fd_set exceptmask; + int fd; + int fds; + struct timeval timeout; + struct timeval *timeoutp; + + fd = cp->fd; + + if (timeoutsec > 0) + { + timeout.tv_sec = timeoutsec; + timeout.tv_usec = 0; + timeoutp = &timeout; + } + else + timeoutp = NULL; + + for (;;) + { + FD_ZERO(&readmask); + FD_ZERO(&exceptmask); + FD_SET(fd, &readmask); + FD_SET(fd, &exceptmask); + + fds = select(fd+1, &readmask, NULL, &exceptmask, timeoutp); + if (fds == -1) + { + if (errno == EAGAIN || errno == EINTR) + continue; + + pool_error("pool_check_fd: select() failed. reason %s", strerror(errno)); + break; + } + else if (fds == 0) /* timeout */ + return 1; + + if (FD_ISSET(fd, &exceptmask)) + { + pool_error("pool_check_fd: exception occurred"); + break; + } + return 0; + } + return -1; +} + +/* + * Process "show pool_status" query. + */ +void process_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + static char *cursorname = "blank"; + static short num_fields = 3; + static char *field_names[] = {"item", "value", "description"}; + static int oid = 0; + static short fsize = -1; + static int mod = 0; + short n; + int i, j; + short s; + int len; + short colnum; + + static unsigned char nullmap[2] = {0xff, 0xff}; + int nbytes = (num_fields + 7)/8; + +#define POOLCONFIG_MAXNAMELEN 32 +#define POOLCONFIG_MAXVALLEN 512 +#define POOLCONFIG_MAXDESCLEN 64 + + typedef struct { + char name[POOLCONFIG_MAXNAMELEN+1]; + char value[POOLCONFIG_MAXVALLEN+1]; + char desc[POOLCONFIG_MAXDESCLEN+1]; + } POOL_REPORT_STATUS; + +#define MAXITEMS 128 + + POOL_REPORT_STATUS status[MAXITEMS]; + + short nrows; + int size; + int hsize; + + i = 0; + + strncpy(status[i].name, "listen_addresses", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->listen_addresses); + strncpy(status[i].desc, "host name(s) or IP address(es) to listen to", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "port", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->port); + strncpy(status[i].desc, "pgpool accepting port number", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "socket_dir", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->socket_dir); + strncpy(status[i].desc, "pgpool socket directory", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "num_init_children", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->num_init_children); + strncpy(status[i].desc, "# of children initially pre-forked", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "child_life_time", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->child_life_time); + strncpy(status[i].desc, "if idle for this seconds, child exits", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "connection_life_time", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->connection_life_time); + strncpy(status[i].desc, "if idle for this seconds, connection closes", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "client_idle_limit", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->client_idle_limit); + strncpy(status[i].desc, "if idle for this seconds, child connection closes", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "child_max_connections", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->child_max_connections); + strncpy(status[i].desc, "if max_connections received, chile exits", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "max_pool", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->max_pool); + strncpy(status[i].desc, "max # of connection pool per child", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "authentication_timeout", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->authentication_timeout); + strncpy(status[i].desc, "maximum time in seconds to complete client authentication", POOLCONFIG_MAXNAMELEN); + i++; + + strncpy(status[i].name, "logdir", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->logdir); + strncpy(status[i].desc, "logging directory", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "pid_file_name", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pid_file_name); + strncpy(status[i].desc, "path to pid file", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "backend_socket_dir", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->backend_socket_dir); + strncpy(status[i].desc, "Unix domain socket directory for the PostgreSQL server", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "replication_mode", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replication_mode); + strncpy(status[i].desc, "non 0 if operating in replication mode", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "load_balance_mode", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->load_balance_mode); + strncpy(status[i].desc, "non 0 if operating in load balancing mode", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "replication_stop_on_mismatch", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replication_stop_on_mismatch); + strncpy(status[i].desc, "stop replication mode on fatal error", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "replicate_select", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replicate_select); + strncpy(status[i].desc, "non 0 if SELECT statement is replicated", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "reset_query_list", POOLCONFIG_MAXNAMELEN); + *(status[i].value) = '\0'; + for (j=0;jnum_reset_queries;j++) + { + int len; + len = POOLCONFIG_MAXVALLEN - strlen(status[i].value); + strncat(status[i].value, pool_config->reset_query_list[j], len); + len = POOLCONFIG_MAXVALLEN - strlen(status[i].value); + strncat(status[i].value, ";", len); + } + strncpy(status[i].desc, "queries issued at the end of session", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "print_timestamp", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->print_timestamp); + strncpy(status[i].desc, "if true print time stamp to each log line", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "master_slave_mode", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->master_slave_mode); + strncpy(status[i].desc, "if true, operate in master/slave mode", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "connection_cache", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->connection_cache); + strncpy(status[i].desc, "if true, cache connection pool", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "health_check_timeout", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->health_check_timeout); + strncpy(status[i].desc, "health check timeout", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "health_check_period", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->health_check_period); + strncpy(status[i].desc, "health check period", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "health_check_user", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->health_check_user); + strncpy(status[i].desc, "health check user", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "failover_command", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->failover_command); + strncpy(status[i].desc, "failover command", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "failback_command", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->failover_command); + strncpy(status[i].desc, "failback command", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "insert_lock", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->insert_lock); + strncpy(status[i].desc, "insert lock", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "ignore_leading_white_space", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->ignore_leading_white_space); + strncpy(status[i].desc, "ignore leading white spaces", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "replication_enabled", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replication_enabled); + strncpy(status[i].desc, "non 0 if actually operating in replication mode", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "master_slave_enabled", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->master_slave_enabled); + strncpy(status[i].desc, "non 0 if actually operating in master/slave", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "num_reset_queries", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->num_reset_queries); + strncpy(status[i].desc, "number of queries in reset_query_list", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "pcp_port", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->pcp_port); + strncpy(status[i].desc, "PCP port # to bind", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "pcp_socket_dir", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pcp_socket_dir); + strncpy(status[i].desc, "PCP socket directory", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "pcp_timeout", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->pcp_timeout); + strncpy(status[i].desc, "PCP timeout for an idle client", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "log_statement", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_statement); + strncpy(status[i].desc, "if non 0, logs all SQL statements", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "log_connections", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_connections); + strncpy(status[i].desc, "if true, print incoming connections to the log", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "log_hostname", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_hostname); + strncpy(status[i].desc, "if true, resolve hostname for ps and log print", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "enable_pool_hba", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->enable_pool_hba); + strncpy(status[i].desc, "if true, use pool_hba.conf for client authentication", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "recovery_user", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_user); + strncpy(status[i].desc, "online recovery user", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "recovery_password", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_password); + strncpy(status[i].desc, "online recovery password", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "recovery_1st_stage_command", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_1st_stage_command); + strncpy(status[i].desc, "execute a command in first stage.", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "recovery_2nd_stage_command", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_2nd_stage_command); + strncpy(status[i].desc, "execute a command in second stage.", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "recovery_timeout", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->recovery_timeout); + strncpy(status[i].desc, "max time in seconds to wait for the recovering node's postmaster", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "client_idle_limit_in_recovery", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->client_idle_limit_in_recovery); + strncpy(status[i].desc, "if idle for this seconds, child connection closes in recovery 2nd statge", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "parallel_mode", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->parallel_mode); + strncpy(status[i].desc, "if non 0, run in parallel query mode", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "enable_query_cache", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->enable_query_cache); + strncpy(status[i].desc, "if non 0, use query cache", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "pgpool2_hostname", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pgpool2_hostname); + strncpy(status[i].desc, "pgpool2 hostname", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "system_db_hostname", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_hostname); + strncpy(status[i].desc, "system DB hostname", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "system_db_port", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->system_db_port); + strncpy(status[i].desc, "system DB port number", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "system_db_dbname", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_dbname); + strncpy(status[i].desc, "system DB name", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "system_db_schema", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_schema); + strncpy(status[i].desc, "system DB schema name", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "system_db_user", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_user); + strncpy(status[i].desc, "user name to access system DB", POOLCONFIG_MAXDESCLEN); + i++; + + strncpy(status[i].name, "system_db_password", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_password); + strncpy(status[i].desc, "password to access system DB", POOLCONFIG_MAXDESCLEN); + i++; + + for (j = 0; j < NUM_BACKENDS; j++) + { + if (BACKEND_INFO(j).backend_port == 0) + continue; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_hostname%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", BACKEND_INFO(j).backend_hostname); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "backend #%d hostname", j); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_port%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", BACKEND_INFO(j).backend_port); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "backend #%d port number", j); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_weight%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%f", BACKEND_INFO(j).backend_weight); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "weight of backend #%d", j); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend status%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", BACKEND_INFO(j).backend_status); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "status of backend #%d", j); + i++; + } + + nrows = i; + + if (MAJOR(backend) == PROTO_MAJOR_V2) + { + /* cursor response */ + pool_write(frontend, "P", 1); + pool_write(frontend, cursorname, strlen(cursorname)+1); + } + + /* row description */ + pool_write(frontend, "T", 1); + + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + len = sizeof(num_fields) + sizeof(len); + + for (i=0;ifd); + pool_flush_it(CONNECTION(backend, i)); + pool_unset_nonblock(CONNECTION(backend, i)->fd); + } + } +} + +/* + * ------------------------------------------------------- + * V3 functions + * ------------------------------------------------------- + */ + +/* + * This function transmits to a parallel Query to each backend, + * and receives the results from backends . + * + */ +static POOL_STATUS ParallelForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *database, bool send_to_frontend) +{ + int len; + char *p; + int status; + + if (send_to_frontend) + { + pool_write(frontend, &kind, 1); + } + + status = pool_read(backend, &len, sizeof(len)); + if (status < 0) + { + pool_error("ParallelForwardToFrontend: error while reading message length"); + return POOL_END; + } + + if (send_to_frontend) + { + pool_write(frontend, &len, sizeof(len)); + } + + len = ntohl(len) - 4 ; + + if (len <= 0) + return POOL_CONTINUE; + + p = pool_read2(backend, len); + if (p == NULL) + return POOL_END; + + status = POOL_CONTINUE; + if (send_to_frontend) + { + status = pool_write(frontend, p, len); + if (pool_config->enable_query_cache && SYSDB_STATUS == CON_UP && status == 0) + { + query_cache_register(kind, frontend, database, p, len); + } + } + + return status; +} + +POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + int len, len1 = 0; + char *p = NULL; + char *p1 = NULL; + char *p2 = NULL; + int status; + int sendlen; + int i; + int command_ok_row_count = 0; + int delete_or_update = 0; + char kind1; + POOL_STATUS ret; + + /* + * Check if packet kind == 'C'(Command complete), '1'(Parse + * complete), '3'(Close complete). If so, then register or + * unregister pending prepared statement. + */ + if ((kind == 'C' || kind == '1' || kind == '3') && + pending_function) + { + pending_function(&prepared_list, pending_prepared_portal); + if (pending_prepared_portal && + pending_prepared_portal->stmt && + IsA(pending_prepared_portal->stmt, DeallocateStmt)) + { + free(pending_prepared_portal->portal_name); + pending_prepared_portal->portal_name = NULL; + pool_memory_delete(pending_prepared_portal->prepare_ctxt, 0); + free(pending_prepared_portal); + } + } + else if (kind == 'E' && pending_function) + { + /* An error occurred with PREPARE or DEALLOCATE command. + * Free pending portal object. + */ + if (pending_prepared_portal) + { + free(pending_prepared_portal->portal_name); + pending_prepared_portal->portal_name = NULL; + pool_memory_delete(pending_prepared_portal->prepare_ctxt, 0); + free(pending_prepared_portal); + } + } + else if (kind == 'C' && select_in_transaction) + { + select_in_transaction = 0; + execute_select = 0; + } + + /* + * Remove a pending function if a received message is not + * NoticeResponse. + */ + if (kind != 'N') + { + pending_function = NULL; + pending_prepared_portal = NULL; + } + + status = pool_read(MASTER(backend), &len, sizeof(len)); + len = ntohl(len); + len -= 4; + len1 = len; + + p = pool_read2(MASTER(backend), len); + if (p == NULL) + return POOL_END; + p1 = malloc(len); + if (p1 == NULL) + { + pool_error("SimpleForwardToFrontend: malloc failed"); + return POOL_ERROR; + } + memcpy(p1, p, len); + + if (kind == 'C') /* packet kind is "Command Complete"? */ + { + command_ok_row_count = extract_ntuples(p); + + /* + * if we are in the parallel mode, we have to sum up the number + * of affected rows + */ + if (PARALLEL_MODE && is_parallel_table && + (strstr(p, "UPDATE") || strstr(p, "DELETE"))) + { + delete_or_update = 1; + } + } + + for (i=0;idata, "", + "check data consistency between master and other db node", __FILE__, __LINE__); + pool_error(msg->data); + free_string(msg); + } + else + { + if (delete_or_update) + { + char tmp[32]; + + strncpy(tmp, p1, 7); + sprintf(tmp+7, "%d", command_ok_row_count); + + p2 = strdup(tmp); + if (p2 == NULL) + { + pool_error("SimpleForwardToFrontend: malloc failed"); + free(p1); + return POOL_ERROR; + } + + free(p1); + p1 = p2; + len1 = strlen(p2) + 1; + } + + pool_write(frontend, &kind, 1); + sendlen = htonl(len1+4); + pool_write(frontend, &sendlen, sizeof(sendlen)); + pool_write(frontend, p1, len1); + } + + /* save the received result for each kind */ + if (pool_config->enable_query_cache && SYSDB_STATUS == CON_UP) + { + query_cache_register(kind, frontend, backend->info->database, p1, len1); + } + + free(p1); + if (status) + return POOL_END; + + if (kind == 'A') /* notification response */ + { + pool_flush(frontend); /* we need to immediately notice to frontend */ + } + else if (kind == 'E') /* error response? */ + { + int i; + int res1; + char *p1; + + /* + * check if the error was PANIC or FATAL. If so, we just flush + * the message and exit since the backend will close the + * channel immediately. + */ + for (;;) + { + char e; + + e = *p++; + if (e == '\0') + break; + + if (e == 'S' && (strcasecmp("PANIC", p) == 0 || strcasecmp("FATAL", p) == 0)) + { + pool_flush(frontend); + return POOL_END; + } + else + { + while (*p++) + ; + continue; + } + } + + if (select_in_transaction) + { + int i; + + in_load_balance = 0; + REPLICATION = 1; + for (i = 0; i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + { + /* + * We must abort transaction to sync transaction state. + * If the error was caused by an Execute message, + * we must send invalid Execute message to abort + * transaction. + * + * Because extended query protocol ignores all + * messages before receiving Sync message inside error state. + */ + if (execute_select) + do_error_execute_command(backend, i, PROTO_MAJOR_V3); + else + do_error_command(CONNECTION(backend, i), PROTO_MAJOR_V3); + } + } + select_in_transaction = 0; + execute_select = 0; + } + + for (i = 0;i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i)) + { + POOL_CONNECTION *cp = CONNECTION(backend, i); + + /* We need to send "sync" message to backend in extend mode + * so that it accepts next command. + * Note that this may be overkill since client may send + * it by itself. Moreover we do not need it in non-extend mode. + * At this point we regard it is not harmful since error response + * will not be sent too frequently. + */ + pool_write(cp, "S", 1); + res1 = htonl(4); + if (pool_write_and_flush(cp, &res1, sizeof(res1)) < 0) + { + return POOL_END; + } + } + } + + while ((ret = read_kind_from_backend(frontend, backend, &kind1)) == POOL_CONTINUE) + { + if (kind1 == 'Z') /* ReadyForQuery? */ + break; + + ret = SimpleForwardToFrontend(kind1, frontend, backend); + if (ret != POOL_CONTINUE) + return ret; + pool_flush(frontend); + } + + if (ret != POOL_CONTINUE) + return ret; + + for (i = 0; i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i)) + { + status = pool_read(CONNECTION(backend, i), &res1, sizeof(res1)); + if (status < 0) + { + pool_error("SimpleForwardToFrontend: error while reading message length"); + return POOL_END; + } + res1 = ntohl(res1) - sizeof(res1); + p1 = pool_read2(CONNECTION(backend, i), res1); + if (p1 == NULL) + return POOL_END; + } + } + } + return POOL_CONTINUE; +} + +POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + int len; + int sendlen; + char *p; + int i; + char *name; + POOL_STATUS ret; + + for (i=0;iportal_name) + free(portal->portal_name); + portal->portal_name = strdup(portal_name); + } + } + + /* Close message with prepared statement name. */ + else if (kind == 'C' && *p == 'S' && *(p + 1)) + { + POOL_MEMORY_POOL *old_context = pool_memory; + DeallocateStmt *deallocate_stmt; + + pending_prepared_portal = create_portal(); + if (pending_prepared_portal == NULL) + { + pool_error("SimpleForwardToBackend: malloc failed: %s", strerror(errno)); + return POOL_END; + } + + pool_memory = pending_prepared_portal->prepare_ctxt; + name = pstrdup(p+1); + if (name == NULL) + { + pool_error("SimpleForwardToBackend: malloc failed: %s", strerror(errno)); + pool_memory = old_context; + return POOL_END; + } + + /* Translate from Close message to DEALLOCATE statement.*/ + deallocate_stmt = palloc(sizeof(DeallocateStmt)); + if (deallocate_stmt == NULL) + { + pool_error("SimpleForwardToBackend: malloc failed: %s", strerror(errno)); + pool_memory = old_context; + return POOL_END; + } + deallocate_stmt->name = name; + pending_prepared_portal->stmt = (Node *)deallocate_stmt; + pending_prepared_portal->portal_name = NULL; + pending_function = del_prepared_list; + pool_memory = old_context; + } + + if (kind == 'B' || kind == 'D' || kind == 'C') + { + int i; + char kind1; + + for (i = 0;i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i)) + { + POOL_CONNECTION *cp = CONNECTION(backend, i); + + /* + * send "Flush" message so that backend notices us + * the completion of the command + */ + pool_write(cp, "H", 1); + sendlen = htonl(4); + if (pool_write_and_flush(cp, &sendlen, sizeof(sendlen)) < 0) + { + return POOL_END; + } + } + } + + /* + * Describe message with a portal name will receive two messages. + * 1. ParameterDescription + * 2. RowDescriptions or NoData + * So we read one message here. + */ + if (kind == 'D' && *p == 'S') + { + ret = read_kind_from_backend(frontend, backend, &kind1); + if (ret != POOL_CONTINUE) + return ret; + SimpleForwardToFrontend(kind1, frontend, backend); + if (pool_flush(frontend)) + return POOL_END; + } + + /* + * Forward to frontend until a NOTICE message received. + */ + for (;;) + { + ret = read_kind_from_backend(frontend, backend, &kind1); + if (ret != POOL_CONTINUE) + return ret; + SimpleForwardToFrontend(kind1, frontend, backend); + if (pool_flush(frontend) < 0) + return POOL_ERROR; + + if (kind1 != 'N') + break; + } + } + + return POOL_CONTINUE; +} + +POOL_STATUS ParameterStatus(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + int len, len1 = 0; + int *len_array; + int sendlen; + char *p; + char *name; + char *value; + POOL_STATUS status; + char parambuf[1024]; /* parameter + value string buffer. XXX is this enough? */ + int i; + + pool_write(frontend, "S", 1); + + len_array = pool_read_message_length2(backend); + + if (len_array == NULL) + { + return POOL_END; + } + + len = len_array[MASTER_NODE_ID]; + sendlen = htonl(len); + pool_write(frontend, &sendlen, sizeof(sendlen)); + + for (i=0;iparams, name, value); + } + +#ifdef DEBUG + pool_param_debug_print(&MASTER(backend)->params); +#endif + } + } + + status = pool_write(frontend, parambuf, len1); + return status; +} + +/* + * Reset backend status. return values are: + * 0: no query was issued 1: a query was issued 2: no more queries remain -1: error + */ +static int reset_backend(POOL_CONNECTION_POOL *backend, int qcnt) +{ + char *query; + int qn; + + /* + * Reset all state variables + */ + in_progress = 0; + in_load_balance = 0; + + /* + * Until pgpool-II 2.2.3 we don't have following 2 lines. + * If we were executing someting in load balance mode, and if + * frontend failed before executing end_loadl_balance() in + * ReadyForQuery(), these variables remained and we may do + * something only in master node! + */ + REPLICATION = pool_config->replication_mode; + MASTER_SLAVE = pool_config->master_slave_mode; + + force_replication = 0; + internal_transaction_started = 0; + mismatch_ntuples = 0; + select_in_transaction = 0; + execute_select = 0; + receive_extended_begin = 0; + + qn = pool_config->num_reset_queries; + + /* + * After execution of all SQL commands in the reset_query_list, we + * remove all prepared objects in the prepared_list. + */ + if (qcnt >= qn) + { + if (prepared_list.cnt == 0) + { + /* + * Either no prepared objects were created or DISCARD ALL + * or DEALLOCATE ALL is on the reset_query_list and they + * were executed. The latter causes call to + * reset_prepared_list which removes all prepared objects. + */ + reset_prepared_list(&prepared_list); + return 2; + } + + /* Delete from prepared list */ + if (send_deallocate(backend, &prepared_list, 0)) + { + /* Deallocate failed. We are in unknown state. Ask caller + * to reset backend connection. + */ + reset_prepared_list(&prepared_list); + return -1; + } + /* + * If DEALLOCATE returns ERROR response, instead of + * CommandComplete, del_prepared_list is not called and the + * prepared object keeps on sitting on the prepared list. This + * will cause infinite call to reset_backend. So we call + * del_prepared_list() again. This is harmless since trying to + * remove same prepared object will be ignored. + */ + del_prepared_list(&prepared_list, prepared_list.portal_list[0]); + return 1; + } + + query = pool_config->reset_query_list[qcnt]; + + /* if transaction state is idle, we don't need to issue ABORT */ + if (TSTATE(backend) == 'I' && !strcmp("ABORT", query)) + return 0; + + pool_set_timeout(10); + + if (SimpleQuery(NULL, backend, query) != POOL_CONTINUE) + { + pool_set_timeout(0); + return -1; + } + + pool_set_timeout(0); + return 1; +} + +/* + * return non 0 if load balance is possible + */ +int load_balance_enabled(POOL_CONNECTION_POOL *backend, Node* node, char *sql) +{ + return (pool_config->load_balance_mode && + (DUAL_MODE || pool_config->parallel_mode) && + MAJOR(backend) == PROTO_MAJOR_V3 && + TSTATE(backend) == 'I' && + is_select_query(node, sql) && + !is_sequence_query(node)); +} + + +/* + * returns non 0 if the SQL statement can be load + * balanced. Followings are statemnts go into this category. + * + * - SELECT without FOR UPDATE/SHARE + * - COPY TO STDOUT + * - DECLARE..SELECT (without INTO nor FOR UPDATE/SHARE) + * - FETCH + * - CLOSE + * + * note that for SELECT INTO, this function returns 0 + */ +int is_select_query(Node *node, char *sql) +{ + if (node == NULL) + return 0; + + /* + * 2009/5/1 Tatsuo says: This test is not bogus. As of 2.2, pgpool + * sets Portal->sql_string to NULL for SQL command PREPARE. + * Usually this is ok, since in most cases SQL command EXECUTE + * follows anyway. Problem is, some applications mix PREPARE with + * extended protocol command "EXECUTE" and so on. Execute() seems + * to think this never happens but it is not real. Someday we + * should extract actual query string from PrepareStmt->query and + * set it to Portal->sql_string. + */ + if (sql == NULL) + return 0; + + if (pool_config->ignore_leading_white_space) + { + /* ignore leading white spaces */ + while (*sql && isspace(*sql)) + sql++; + } + + if (IsA(node, SelectStmt) || IsA(node, DeclareCursorStmt)) + { + SelectStmt *select_stmt; + + if (IsA(node, SelectStmt)) + select_stmt = (SelectStmt *)node; + else + select_stmt = (SelectStmt *)((DeclareCursorStmt *)node)->query; + + if (select_stmt->intoClause || select_stmt->lockingClause) + return 0; + + if (IsA(node, SelectStmt)) + return (*sql == 's' || *sql == 'S' || *sql == '('); + else + return (*sql == 'd' || *sql == 'D'); + } + else if (IsA(node, FetchStmt) || IsA(node, ClosePortalStmt)) + { + return (*sql == 'f' || *sql == 'F' || *sql == 'c' || *sql == 'C'); + } + else if (IsA(node, CopyStmt)) + { + CopyStmt *copy_stmt = (CopyStmt *)node; + return (copy_stmt->is_from == FALSE && + copy_stmt->filename == NULL); + } + return 0; +} + +/* + * returns non 0 if SQL is SELECT statement including nextval() or + * setval() call + */ +int is_sequence_query(Node *node) +{ + SelectStmt *select_stmt; + ListCell *lc; + + if (node == NULL || !IsA(node, SelectStmt)) + return 0; + + select_stmt = (SelectStmt *)node; + foreach (lc, select_stmt->targetList) + { + if (IsA(lfirst(lc), ResTarget)) + { + ResTarget *t; + FuncCall *fc; + ListCell *c; + + t = (ResTarget *) lfirst(lc); + if (IsA(t->val, FuncCall)) + { + fc = (FuncCall *) t->val; + foreach (c, fc->funcname) + { + Value *v = lfirst(c); + if (strncasecmp(v->val.str, "NEXTVAL", 7) == 0) + return 1; + else if (strncasecmp(v->val.str, "SETVAL", 6) == 0) + return 1; + } + } + } + } + + return 0; +} + +/* + * returns non 0 if SQL is transaction starting command (START + * TRANSACTION or BEGIN) + */ +int is_start_transaction_query(Node *node) +{ + TransactionStmt *stmt; + + if (node == NULL || !IsA(node, TransactionStmt)) + return 0; + + stmt = (TransactionStmt *)node; + return stmt->kind == TRANS_STMT_START || stmt->kind == TRANS_STMT_BEGIN; +} + +/* + * returns non 0 if SQL is transaction commit or abort command (END + * TRANSACTION or ROLLBACK or ABORT) + */ +int is_commit_query(Node *node) +{ + TransactionStmt *stmt; + + if (node == NULL || !IsA(node, TransactionStmt)) + return 0; + + stmt = (TransactionStmt *)node; + return stmt->kind == TRANS_STMT_COMMIT || stmt->kind == TRANS_STMT_ROLLBACK; +} + +/* + * start load balance mode + */ +void start_load_balance(POOL_CONNECTION_POOL *backend) +{ +#ifdef NOT_USED + double total_weight,r; + int i; + + /* save backend connection slots */ + for (i=0;islots[0] = slots[selected_slot]; +#endif + LOAD_BALANCE_STATUS(backend->info->load_balancing_node) = LOAD_SELECTED; + selected_slot = backend->info->load_balancing_node; + + /* start load balancing */ + in_load_balance = 1; +} + +/* + * finish load balance mode + */ +void end_load_balance(POOL_CONNECTION_POOL *backend) +{ + in_load_balance = 0; + LOAD_BALANCE_STATUS(selected_slot) = LOAD_UNSELECTED; + +#ifdef NOT_USED + /* restore backend connection slots */ + + for (i=0;ifd); + + if (protoMajor == PROTO_MAJOR_V2) + { + pool_write(frontend, "E", 1); + pool_write_and_flush(frontend, message, strlen(message)+1); + } + else if (protoMajor == PROTO_MAJOR_V3) + { + char data[MAXDATA]; + char msgbuf[MAXMSGBUF]; + int len; + int thislen; + int sendlen; + + len = 0; + + pool_write(frontend, "E", 1); + + /* error level */ + thislen = snprintf(msgbuf, MAXMSGBUF, "SERROR"); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + + /* code */ + thislen = snprintf(msgbuf, MAXMSGBUF, "C%s", code); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + + /* message */ + thislen = snprintf(msgbuf, MAXMSGBUF, "M%s", message); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + + /* detail */ + if (*detail != '\0') + { + thislen = snprintf(msgbuf, MAXMSGBUF, "D%s", detail); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + } + + /* hint */ + if (*hint != '\0') + { + thislen = snprintf(msgbuf, MAXMSGBUF, "H%s", hint); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + } + + /* file */ + thislen = snprintf(msgbuf, MAXMSGBUF, "F%s", file); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + + /* line */ + thislen = snprintf(msgbuf, MAXMSGBUF, "L%d", line); + thislen = Min(thislen, MAXMSGBUF); + memcpy(data +len, msgbuf, thislen+1); + len += thislen + 1; + + /* stop null */ + len++; + *(data + len - 1) = '\0'; + + sendlen = len; + len = htonl(len + 4); + pool_write(frontend, &len, sizeof(len)); + pool_write_and_flush(frontend, data, sendlen); + } + else + pool_error("send_error_message: unknown protocol major %d", protoMajor); + + pool_unset_nonblock(frontend->fd); +} + +void pool_send_readyforquery(POOL_CONNECTION *frontend) +{ + int len; + pool_write(frontend, "Z", 1); + len = 5; + len = htonl(len); + pool_write(frontend, &len, sizeof(len)); + pool_write(frontend, "I", 1); + pool_flush(frontend); +} + +/* + * Send a query to a backend in sync manner. + * This function sends a query and waits for CommandComplete/ReadyForQuery. + * If an error occured, it returns with POOL_ERROR. + * This function does NOT handle SELECT/SHOW queries. + * If no_ready_for_query is non 0, returns without reading the packet + * length for ReadyForQuery. This mode is necessary when called from ReadyForQuery(). + */ +static POOL_STATUS do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, + char *query, int protoMajor, int pid, int key, int no_ready_for_query) +{ + int len; + int status; + char kind; + char *string; + int deadlock_detected = 0; + + pool_debug("do_command: Query: %s", query); + + /* send the query to the backend */ + if (send_simplequery_message(backend, strlen(query)+1, query, protoMajor) != POOL_CONTINUE) + return POOL_END; + + /* + * Wait for response from badckend while polling frontend connection is ok. + * If not, cancel the transaction. + */ + if (wait_for_query_response(frontend, backend, query, protoMajor) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = pid; + cancel_packet.key= key; + cancel_request(&cancel_packet); + return POOL_END; + } + + /* + * We must check deadlock error here. If a deadlock error is + * detected by a backend, other backend might not be noticed the + * error. In this case caller should send an error query to the + * backend to abort the transaction. Otherwise the transaction + * state might vary among backends(idle in transaction vs. abort). + */ + deadlock_detected = detect_deadlock_error(backend, protoMajor); + if (deadlock_detected < 0) + return POOL_END; + + /* + * Continue to read packets until we get ReadForQuery (Z). + * Until that we may recieve one of: + * + * N: Notice response + * E: Error response + * C: Comand complete + * + * XXX: we ignore Notice and Error here. Even notice/error + * messages are not sent to the frontend. May be it's ok since the + * error was caused by our internal use of SQL command (otherwise users + * will be confused). + */ + for(;;) + { + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_command: error while reading message kind"); + return POOL_END; + } + + pool_debug("do_command: kind: %c", kind); + + if (kind == 'Z') /* Ready for Query? */ + break; /* get out the loop without reading message lenghth */ + + if (protoMajor == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len)) < 0) + { + pool_error("do_command: error while reading message length"); + return POOL_END; + } + len = ntohl(len) - 4; + + if (kind != 'N' && kind != 'E' && kind != 'C') + { + pool_error("do_command: error, kind is not N, E or C(%02x)", kind); + return POOL_END; + } + string = pool_read2(backend, len); + if (string == NULL) + { + pool_error("do_command: error while reading rest of message"); + return POOL_END; + } + } + else + { + string = pool_read_string(backend, &len, 0); + if (string == NULL) + { + pool_error("do_command: error while reading rest of message"); + return POOL_END; + } + } + } + +/* + * until 2008/11/12 we believed that we never had packets other than + * 'Z' after receiving 'C'. However a counter example was presented by + * a poor customer. So we replaced the whole thing with codes + * above. In a side effect we were be able to get ride of nasty + * "goto". Congratulations. + */ +#ifdef NOT_USED + /* + * Expecting CompleteCommand + */ +retry_read_packet: + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_command: error while reading message kind"); + return POOL_END; + } + + if (kind == 'E') + { + pool_log("do_command: backend does not successfully complete command %s status %c", query, kind); + } + + /* + * read command tag of CommandComplete response + */ + if (protoMajor == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len)) < 0) + return POOL_END; + len = ntohl(len) - 4; + string = pool_read2(backend, len); + if (string == NULL) + return POOL_END; + pool_debug("command tag: %s", string); + } + else + { + string = pool_read_string(backend, &len, 0); + if (string == NULL) + return POOL_END; + } + + if (kind == 'N') /* warning? */ + goto retry_read_packet; + + /* + * Expecting ReadyForQuery + */ + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_command: error while reading message kind"); + return POOL_END; + } + + if (kind != 'Z') + { + pool_error("do_command: backend returns %c while expecting ReadyForQuery", kind); + return POOL_END; + } +#endif + + if (no_ready_for_query) + return POOL_CONTINUE; + + if (protoMajor == PROTO_MAJOR_V3) + { + /* read packet lenghth for ready for query */ + if (pool_read(backend, &len, sizeof(len)) < 0) + { + pool_error("do_command: error while reading message length"); + return POOL_END; + } + + /* read transaction state */ + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_command: error while reading transaction status"); + return POOL_END; + } + + /* set transaction state */ + pool_debug("do_command: transaction state: %c", kind); + backend->tstate = kind; + } + + return deadlock_detected ? POOL_DEADLOCK : POOL_CONTINUE; +} + +/* + * Send a syntax error query to abort transaction and receive response + * from backend and discard it until we get Error response. + * + * We need to sync transaction status in transaction block. + * SELECT query is sent to master only. + * If SELECT is error, we must abort transaction on other nodes. + */ +POOL_STATUS do_error_command(POOL_CONNECTION *backend, int major) +{ + char *error_query = POOL_ERROR_QUERY; + int status, len; + char kind; + char *string; + + if (send_simplequery_message(backend, strlen(error_query) + 1, error_query, major) != POOL_CONTINUE) + { + return POOL_END; + } + + /* + * Continue to read packets until we get Error response (E). + * Until that we may recieve one of: + * + * N: Notice response + * C: Comand complete + * + * XXX: we ignore Notice here. Even notice messages are not sent + * to the frontend. May be it's ok since the error was caused by + * our internal use of SQL command (otherwise users will be + * confused). + */ + do + { + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_error_command: error while reading message kind"); + return POOL_END; + } + + pool_debug("do_error_command: kind: %c", kind); + + if (major == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len)) < 0) + { + pool_error("do_error_command: error while reading message length"); + return POOL_END; + } + len = ntohl(len) - 4; + string = pool_read2(backend, len); + if (string == NULL) + { + pool_error("do_error_command: error while reading rest of message"); + return POOL_END; + } + } + else + { + string = pool_read_string(backend, &len, 0); + if (string == NULL) + { + pool_error("do_error_command: error while reading rest of message"); + return POOL_END; + } + } + } while (kind != 'E'); + +#ifdef NOT_USED + /* + * Expecting ErrorResponse + */ + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_command: error while reading message kind"); + return POOL_END; + } + + /* + * read command tag of CommandComplete response + */ + if (major == PROTO_MAJOR_V3) + { + if (pool_read(backend, &len, sizeof(len)) < 0) + return POOL_END; + len = ntohl(len) - 4; + string = pool_read2(backend, len); + if (string == NULL) + return POOL_END; + pool_debug("command tag: %s", string); + } + else + { + string = pool_read_string(backend, &len, 0); + if (string == NULL) + return POOL_END; + } +#endif + return POOL_CONTINUE; +} + +/* + * Send invalid portal execution to abort transaction. + * We need to sync transaction status in transaction block. + * SELECT query is sent to master only. + * If SELECT is error, we must abort transaction on other nodes. + */ +static POOL_STATUS do_error_execute_command(POOL_CONNECTION_POOL *backend, int node_id, int major) +{ + int status; + char kind; + char *string; + char msg[1024] = "pgpoool_error_portal"; /* large enough */ + int len = strlen(msg); + + memset(msg + len, 0, sizeof(int)); + if (send_execute_message(backend, node_id, len + 5, msg)) + { + return POOL_END; + } + + /* + * Expecting ErrorResponse + */ + status = pool_read(CONNECTION(backend, node_id), &kind, sizeof(kind)); + if (status < 0) + { + pool_error("do_error_execute_command: error while reading message kind"); + return POOL_END; + } + + /* + * read command tag of CommandComplete response + */ + if (major == PROTO_MAJOR_V3) + { + if (pool_read(CONNECTION(backend, node_id), &len, sizeof(len)) < 0) + return POOL_END; + len = ntohl(len) - 4; + string = pool_read2(CONNECTION(backend, node_id), len); + if (string == NULL) + return POOL_END; + pool_debug("command tag: %s", string); + } + else + { + string = pool_read_string(CONNECTION(backend, node_id), &len, 0); + if (string == NULL) + return POOL_END; + } + + return POOL_CONTINUE; +} + +/* + * Transmit an arbitrary Query to a specific node. + * This function is only used in parallel mode + */ +POOL_STATUS OneNode_do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *query, char *database) +{ + int len,sendlen; + int status; + char kind; + bool notice = false; + + pool_debug("OneNode_do_command: Query: %s", query); + + /* send the query to the backend */ + pool_write(backend, "Q", 1); + len = strlen(query)+1; + + sendlen = htonl(len + 4); + pool_write(backend, &sendlen, sizeof(sendlen)); + + if (pool_write_and_flush(backend, query, len) < 0) + { + return POOL_END; + } + + for(;;) + { + status = pool_read(backend, &kind, sizeof(kind)); + if (status < 0) + { + pool_error("OneNode_do_command: error while reading message kind"); + return POOL_END; + } + + if (kind == 'N' && strstr(query,"dblink")) { + notice = true; + status = ParallelForwardToFrontend(kind, frontend, backend, database, false); + } else { + if(notice) + status = ParallelForwardToFrontend(kind, frontend, backend, database, false); + else + status = ParallelForwardToFrontend(kind, frontend, backend, database, true); + } + if (kind == 'C' || kind =='E') + { + break; + } + } + /* + * Expecting ReadyForQuery + * + */ + status = pool_read(backend, &kind, sizeof(kind)); + + if(notice) + pool_send_error_message(frontend, 3, "XX000", + "pgpool2 sql restriction(notice from dblink)",query,"", + __FILE__,__LINE__); + + if (status < 0) + { + pool_error("OneNode_do_command: error while reading message kind"); + return POOL_END; + } + + if (kind != 'Z') + { + pool_error("OneNode_do_command: backend does not return ReadyForQuery"); + return POOL_END; + } + + + status = ParallelForwardToFrontend(kind, frontend, backend, database, true); + pool_flush(frontend); + + return status; +} + +/* + * Free POOL_SELECT_RESULT object + */ +static void free_select_result(POOL_SELECT_RESULT *result) +{ + int i; + + if (result->nullflags) + free(result->nullflags); + + if (result->data) + { + for(i=0;inumrows;i++) + { + if (result->data[i]) + free(result->data[i]); + } + free(result->data); + } + + if (result->rowdesc) + { + if (result->rowdesc->attrinfo) + { + for(i=0;irowdesc->num_attrs;i++) + { + if (result->rowdesc->attrinfo[i].attrname) + free(result->rowdesc->attrinfo[i].attrname); + } + free(result->rowdesc->attrinfo); + } + free(result->rowdesc); + } +} + +/* + * Send a SELECT to one DB node. This function works for V3 only. + */ +POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result) +{ +#define DO_QUERY_ALLOC_NUM 1024 /* memory allocation unit for POOL_SELECT_RESULT */ + + int i; + int len; + char kind; + char *packet; + char *p; + short num_fields; + int num_data; + int intval; + short shortval; + + POOL_SELECT_RESULT *res; + RowDesc *rowdesc; + AttrInfo *attrinfo; + + res = malloc(sizeof(*res)); + if (!res) + { + pool_error("pool_query: malloc failed"); + return POOL_ERROR; + } + rowdesc = malloc(sizeof(*rowdesc)); + if (!rowdesc) + { + pool_error("pool_query: malloc failed"); + return POOL_ERROR; + } + memset(res, 0, sizeof(*res)); + memset(rowdesc, 0, sizeof(*rowdesc)); + *result = res; + + res->rowdesc = rowdesc; + + num_data = 0; + + res->nullflags = malloc(DO_QUERY_ALLOC_NUM*sizeof(int)); + if (!res->nullflags) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + res->data = malloc(DO_QUERY_ALLOC_NUM*sizeof(char *)); + if (!res->data) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + + /* send a query to the backend */ + if (send_simplequery_message(backend, strlen(query) + 1, query, PROTO_MAJOR_V3) != POOL_CONTINUE) + { + return POOL_END; + } + + /* + * Continue to read packets until we get Ready for command('Z') + * + * XXX: we ignore other than Z here. Even notice messages are not sent + * to the frontend. May be it's ok since the error was caused by + * our internal use of SQL command (otherwise users will be + * confused). + */ + for(;;) + { + if (pool_read(backend, &kind, sizeof(kind)) < 0) + { + pool_error("do_query: error while reading message kind"); + return POOL_END; + } + + pool_debug("do_query: kind: %c", kind); + + if (pool_read(backend, &len, sizeof(len)) < 0) + { + pool_error("do_query: error while reading message length"); + return POOL_END; + } + len = ntohl(len) - 4; + packet = pool_read2(backend, len); + if (packet == NULL) + { + pool_error("do_query: error while reading rest of message"); + return POOL_END; + } + + switch (kind) + { + case 'Z': /* Ready for query */ + return POOL_CONTINUE; + break; + + case 'T': /* Row Description */ + p = packet; + memcpy(&shortval, p, sizeof(short)); + num_fields = ntohs(shortval); /* number of fields */ + pool_debug("num_fileds: %d", num_fields); + + if (num_fields > 0) + { + rowdesc->num_attrs = num_fields; + attrinfo = malloc(sizeof(*attrinfo)*num_fields); + if (!attrinfo) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + rowdesc->attrinfo = attrinfo; + + p += sizeof(num_fields); + + /* extract attribute info */ + for (i = 0;iattrname = malloc(len); + if (!attrinfo->attrname) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + memcpy(attrinfo->attrname, p, len); + p += len; + memcpy(&intval, p, sizeof(int)); + attrinfo->oid = htonl(intval); + p += sizeof(int); + memcpy(&shortval, p, sizeof(short)); + attrinfo->attrnumber = htons(shortval); + p += sizeof(short); + memcpy(&intval, p, sizeof(int)); + attrinfo->typeoid = htonl(intval); + p += sizeof(int); + memcpy(&shortval, p, sizeof(short)); + attrinfo->size = htons(shortval); + p += sizeof(short); + memcpy(&intval, p, sizeof(int)); + attrinfo->mod = htonl(intval); + p += sizeof(int); + p += sizeof(short); /* skip format code since we use "text" anyway */ + + attrinfo++; + } + } + break; + + case 'D': /* data row */ + p = packet; + + memcpy(&shortval, p, sizeof(short)); + num_fields = htons(shortval); + p += sizeof(short); + + if (num_fields > 0) + { + res->numrows++; + + for (i=0;inullflags[num_data] = len; + + if (len > 0) /* NOT NULL? */ + { + res->data[num_data] = malloc(len + 1); + if (!res->data[num_data]) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + memcpy(res->data[num_data], p, len); + *(res->data[num_data] + 1) = '\0'; + + p += len; + } + + num_data++; + + if (num_data % DO_QUERY_ALLOC_NUM == 0) + { + res->nullflags = realloc(res->nullflags, + (num_data/DO_QUERY_ALLOC_NUM +1)*DO_QUERY_ALLOC_NUM*sizeof(int)); + if (!res->nullflags) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + res->data = realloc(res->data, + (num_data/DO_QUERY_ALLOC_NUM +1)*DO_QUERY_ALLOC_NUM*sizeof(char *)); + if (!res->data) + { + pool_error("do_query: malloc failed"); + return POOL_ERROR; + } + } + } + } + break; + + default: + break; + } + + } + return POOL_CONTINUE; +} + + +/* + * judge if we need to lock the table + * to keep SERIAL consistency among servers + */ +int need_insert_lock(POOL_CONNECTION_POOL *backend, char *query, Node *node) +{ +/* + * Query to know if the target table has SERIAL column or not. + * This query is valid through PostgreSQL 7.3 to 8.3. + */ +#define NEXTVALQUERY "SELECT count(*) FROM pg_catalog.pg_attrdef AS d, pg_catalog.pg_class AS c WHERE d.adrelid = c.oid AND d.adsrc ~ 'nextval' AND c.relname = '%s'" + +#define INSERT_STATEMENT_MAX_CACHE 16 +#define MAX_ITEM_LENGTH 1024 + + /* table lookup cache structure */ + typedef struct { + char dbname[MAX_ITEM_LENGTH]; /* database name */ + char relname[MAX_ITEM_LENGTH]; /* table name */ + int use_serial; /* 1: use SERIAL data type */ + int refcnt; /* reference count */ + } MyRelCache; + + static MyRelCache relcache[INSERT_STATEMENT_MAX_CACHE]; + + int i; + char *str; + char *rel; + int use_serial = 0; + char *dbname; + + /* + * for version 2 protocol, we cannot check if it's actually uses + * SERIAL data types or not since the underlying infrastructure + * (do_query) does not support the protocol. So we just return + * false. + */ + if (MAJOR(backend) == PROTO_MAJOR_V2) + return 0; + + /* INSERT statement? */ + if (!IsA(node, InsertStmt)) + return 0; + + /* need to ignore leading white spaces? */ + if (pool_config->ignore_leading_white_space) + { + /* ignore leading white spaces */ + while (*query && isspace(*query)) + query++; + } + + /* is there "NO_LOCK" comment? */ + if (strncasecmp(query, NO_LOCK_COMMENT, NO_LOCK_COMMENT_SZ) == 0) + return 0; + + /* is there "LOCK" comment? */ + if (strncasecmp(query, LOCK_COMMENT, LOCK_COMMENT_SZ) == 0) + return 1; + + if (pool_config->insert_lock == 0) /* insert_lock is specified? */ + return 0; + + /* + * if insert_lock is true, then check if the table actually uses + * SERIAL data type + */ + + /* obtain table name */ + str = get_insert_command_table_name((InsertStmt *)node); + if (str == NULL) + { + pool_error("need_insert_lock: get_insert_command_table_name failed"); + return 0; + } + + /* eliminate double quotes */ + rel = malloc(strlen(str)+1); + if (!rel) + { + pool_error("need_insert_lock: malloc failed"); + return 0; + } + for(i=0;*str;str++) + { + if (*str != '"') + rel[i++] = *str; + } + rel[i] = '\0'; + + /* obtain database name */ + dbname = MASTER_CONNECTION(backend)->sp->database; + + /* look for cache first */ + for (i=0;inumrows >= 1 && strcmp(res->data[0], "0")) + use_serial = 1; + + free_select_result(res); + + for (i=0;ipid, + MASTER_CONNECTION(backend)->key, 0); + if (status == POOL_END) + { + internal_transaction_started = 0; + return POOL_END; + } + else if (status == POOL_DEADLOCK) + deadlock_detected = 1; + + for (i=0;ipid, MASTER_CONNECTION(backend)->key, 0); + else + status = do_command(frontend, CONNECTION(backend, i), qbuf, PROTO_MAJOR_V3, + MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0); + + if (status != POOL_CONTINUE) + { + internal_transaction_started = 0; + return POOL_END; + } + } + } + + return POOL_CONTINUE; +} + +bool is_partition_table(POOL_CONNECTION_POOL *backend, Node *node) +{ + DistDefInfo *info = NULL; + RangeVar *var = NULL;; + + if (IsA(node, UpdateStmt)) + { + UpdateStmt *update = (UpdateStmt*) node; + + if(!IsA(update->relation,RangeVar)) + return false; + + var = (RangeVar *) update->relation; + } + else if (IsA(node, DeleteStmt)) + { + DeleteStmt *delete = (DeleteStmt*) node; + + if(!IsA(delete->relation,RangeVar)) + return false; + + var = (RangeVar *) delete->relation; + } else + return false; + + info = pool_get_dist_def_info(MASTER_CONNECTION(backend)->sp->database, + var->schemaname, + var->relname); + if(info) + return true; + else + return false; +} + +/* + * obtain table name in INSERT statement + */ +static char *get_insert_command_table_name(InsertStmt *node) +{ + char *table = nodeToString(node->relation); + + pool_debug("get_insert_command_table_name: extracted table name: %s", table); + return table; +} + +/* judge if this is a DROP DATABASE command */ +int is_drop_database(Node *node) +{ + return (IsA(node, DropdbStmt)) ? 1 : 0; +} + +/* + * check if any pending data remains. Also if there's some pending data in + * frontend AND no processing any Query, then returns 0. + * XXX: is this correct thing? +*/ +static int is_cache_empty(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + int i; + + if (frontend->len > 0 && !in_progress) + return 0; + + for (i=0;ilen > 0) + return 0; + } + + return 1; +} + +/* + * check if query is needed to wait completion + */ +int is_strict_query(Node *node) +{ + switch (node->type) + { + case T_SelectStmt: + { + SelectStmt *stmt = (SelectStmt *)node; + return (stmt->intoClause || stmt->lockingClause) ? 1 : 0; + } + + case T_UpdateStmt: + case T_InsertStmt: + case T_DeleteStmt: + case T_LockStmt: + return 1; + + default: + return 0; + } + + return 0; +} + +int check_copy_from_stdin(Node *node) +{ + if (copy_schema) + free(copy_schema); + if (copy_table) + free(copy_table); + if (copy_null) + free(copy_null); + + copy_schema = copy_table = copy_null = NULL; + + if (IsA(node, CopyStmt)) + { + CopyStmt *stmt = (CopyStmt *)node; + if (stmt->is_from == TRUE && stmt->filename == NULL) + { + RangeVar *relation = (RangeVar *)stmt->relation; + ListCell *lc; + + /* query is COPY FROM STDIN */ + if (relation->schemaname) + copy_schema = strdup(relation->schemaname); + else + copy_schema = strdup("public"); + copy_table = strdup(relation->relname); + + copy_delimiter = '\t'; /* default delimiter */ + copy_null = strdup("\\N"); /* default null string */ + + /* look up delimiter and null string. */ + foreach (lc, stmt->options) + { + DefElem *elem = lfirst(lc); + Value *v; + + if (strcmp(elem->defname, "delimiter") == 0) + { + v = (Value *)elem->arg; + copy_delimiter = v->val.str[0]; + } + else if (strcmp(elem->defname, "null") == 0) + { + if (copy_null) + free(copy_null); + v = (Value *)elem->arg; + copy_null = strdup(v->val.str); + } + } + } + return 1; + } + + return 0; +} + +/* + * read kind from one backend + */ +POOL_STATUS read_kind_from_one_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *kind, int node) +{ + if (VALID_BACKEND(node)) + { + char k; + if (pool_read(CONNECTION(backend, node), &k, 1) < 0) + { + pool_error("read_kind_from_one_backend: failed to read kind from %d th backend", node); + return POOL_ERROR; + } + + pool_debug("read_kind_from_one_backend: read kind from %d th backend %c", node, k); + + *kind = k; + return POOL_CONTINUE; + } + else + { + pool_error("read_kind_from_one_backend: %d th backend is not valid", node); + return POOL_ERROR; + } +} + +/* + * read_kind_from_backend: read kind from backends. + * the "frontend" parameter is used to send "kind mismatch" error message to the frontend. + * the out parameter "decided_kind" is the packet kind decided by this function. + * this function uses "decide by majority" method if kinds from all backends do not agree. + */ +POOL_STATUS read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *decided_kind) +{ + int i; + unsigned char kind_list[MAX_NUM_BACKENDS]; /* records each backend's kind */ + unsigned char kind_map[256]; /* records which kind gets majority. + * 256 is the number of distinct values expressed by unsigned char + */ + unsigned char kind; + int trust_kind; /* decided kind */ + int max_kind = 0; + double max_count = 0; + int degenerate_node_num = 0; /* number of backends degeneration requested */ + int degenerate_node[MAX_NUM_BACKENDS]; /* degeneration requested backend list */ + + memset(kind_map, 0, sizeof(kind_map)); + + for (i=0;i max_count) + { + max_kind = kind_list[i]; + max_count = kind_map[kind]; + } + } + else + kind_list[i] = 0; + } + +#ifdef NOT_USED + /* register kind map */ + for (i = 0; i < NUM_BACKENDS; i++) + { + /* initialize degenerate record */ + degenerate_node[i] = 0; + + /* kind is signed char. + * We must check negative number. + */ + int id = kind_list[i] + 128; + + if (kind_list[i] == -1) + continue; + + kind_map[id]++; + if (kind_map[id] > max_count) + { + max_kind = kind_list[i]; + max_count = kind_map[id]; + } + } +#endif + + if (max_count != NUM_BACKENDS) + { + /* + * not all backends agree with kind. We need to do "decide by majority" + */ + + if (max_count <= NUM_BACKENDS / 2.0) + { + /* no one gets majority. We trust master node's kind */ + trust_kind = kind_list[MASTER_NODE_ID]; + } + else /* max_count > NUM_BACKENDS / 2.0 */ + { + /* trust majority's kind */ + trust_kind = max_kind; + } + + for (i = 0; i < NUM_BACKENDS; i++) + { + if (kind_list[i] != 0 && trust_kind != kind_list[i]) + { + /* degenerate */ + pool_error("read_kind_from_backend: %d th kind %c does not match with master or majority connection kind %c", + i, kind_list[i], trust_kind); + degenerate_node[degenerate_node_num++] = i; + } + } + } + else + trust_kind = kind_list[MASTER_NODE_ID]; + + *decided_kind = trust_kind; + + if (degenerate_node_num) + { + String *msg = init_string("kind mismatch among backends. "); + + string_append_char(msg, "Possible last query was: \""); + string_append_char(msg, query_string_buffer); + string_append_char(msg, "\" kind details are:"); + + for (i=0;idata, "", + "check data consistency among db nodes", + __FILE__, __LINE__); + pool_error(msg->data); + + free_string(msg); + + if (pool_config->replication_stop_on_mismatch) + { + degenerate_backend_set(degenerate_node, degenerate_node_num); + child_exit(1); + } + else + return POOL_ERROR; + } + + return POOL_CONTINUE; +} + +/* + * Create portal object + * Return object is allocated from heap memory. + */ +Portal *create_portal(void) +{ + Portal *p; + + if ((p = malloc(sizeof(Portal))) == NULL) + return NULL; + + p->prepare_ctxt = pool_memory_create(PREPARE_BLOCK_SIZE); + if (p->prepare_ctxt == NULL) + { + free(p); + return NULL; + } + return p; +} + +void init_prepared_list(void) +{ + prepared_list.cnt = 0; + prepared_list.size = INIT_STATEMENT_LIST_SIZE; + prepared_list.portal_list = malloc(sizeof(Portal *) * prepared_list.size); + if (prepared_list.portal_list == NULL) + { + pool_error("init_prepared_list: malloc failed: %s", strerror(errno)); + exit(1); + } +} + +void add_prepared_list(PreparedStatementList *p, Portal *portal) +{ + if (p->cnt == p->size) + { + p->size *= 2; + p->portal_list = realloc(p->portal_list, sizeof(Portal *) * p->size); + if (p->portal_list == NULL) + { + pool_error("add_prepared_list: realloc failed: %s", strerror(errno)); + exit(1); + } + } + p->portal_list[p->cnt++] = portal; +} + +void add_unnamed_portal(PreparedStatementList *p, Portal *portal) +{ + if (unnamed_statement) + { + pool_memory_delete(unnamed_statement->prepare_ctxt, 0); + free(unnamed_statement); + } + + unnamed_portal = NULL; + unnamed_statement = portal; +} + +void del_prepared_list(PreparedStatementList *p, Portal *portal) +{ + int i; + DeallocateStmt *s = (DeallocateStmt *)portal->stmt; + + /* DEALLOCATE ALL? */ + if (s->name == NULL) + { + reset_prepared_list(p); + } + else + { + for (i = 0; i < p->cnt; i++) + { + PrepareStmt *p_stmt = (PrepareStmt *)p->portal_list[i]->stmt; + if (strcmp(p_stmt->name, s->name) == 0) + break; + } + + if (i == p->cnt) + return; + + pool_memory_delete(p->portal_list[i]->prepare_ctxt, 0); + free(p->portal_list[i]->portal_name); + free(p->portal_list[i]); + if (i != p->cnt - 1) + { + memmove(&p->portal_list[i], &p->portal_list[i+1], + sizeof(Portal *) * (p->cnt - i - 1)); + } + p->cnt--; + } +} + +void delete_all_prepared_list(PreparedStatementList *p, Portal *portal) +{ + reset_prepared_list(p); +} + +static void reset_prepared_list(PreparedStatementList *p) +{ + int i; + + if (p) + { + for (i = 0; i < p->cnt; i++) + { + pool_memory_delete(p->portal_list[i]->prepare_ctxt, 0); + free(p->portal_list[i]->portal_name); + free(p->portal_list[i]); + } + if (unnamed_statement) + { + pool_memory_delete(unnamed_statement->prepare_ctxt, 0); + free(unnamed_statement); + } + unnamed_portal = NULL; + unnamed_statement = NULL; + p->cnt = 0; + } +} + +Portal *lookup_prepared_statement_by_statement(PreparedStatementList *p, const char *name) +{ + int i; + + /* unnamed portal? */ + if (name == NULL || name[0] == '\0' || (name[0] == '\"' && name[1] == '\"')) + return unnamed_statement; + + for (i = 0; i < p->cnt; i++) + { + PrepareStmt *p_stmt = (PrepareStmt *)p->portal_list[i]->stmt; + if (strcmp(p_stmt->name, name) == 0) + return p->portal_list[i]; + } + + return NULL; +} + +Portal *lookup_prepared_statement_by_portal(PreparedStatementList *p, const char *name) +{ + int i; + + /* unnamed portal? */ + if (name == NULL || name[0] == '\0' || (name[0] == '\"' && name[1] == '\"')) + return unnamed_portal; + + for (i = 0; i < p->cnt; i++) + { + if (p->portal_list[i]->portal_name && + strcmp(p->portal_list[i]->portal_name, name) == 0) + return p->portal_list[i]; + } + + return NULL; +} + +static int send_deallocate(POOL_CONNECTION_POOL *backend, PreparedStatementList *p, + int n) +{ + char *query; + int len; + PrepareStmt *p_stmt; + + if (p->cnt <= n) + return 1; + + p_stmt = (PrepareStmt *)p->portal_list[n]->stmt; + len = strlen(p_stmt->name) + 14; /* "DEALLOCATE \"" + "\"" + '\0' */ + query = malloc(len); + if (query == NULL) + { + pool_error("send_deallocate: malloc failed: %s", strerror(errno)); + exit(1); + } + sprintf(query, "DEALLOCATE \"%s\"", p_stmt->name); + + if (SimpleQuery(NULL, backend, query) != POOL_CONTINUE) + { + free(query); + return 1; + } + free(query); + + return 0; +} + +/* + * parse_copy_data() + * Parses CopyDataRow string. + * Returns divide key value. If cannot parse data, returns NULL. + */ +char * +parse_copy_data(char *buf, int len, char delimiter, int col_id) +{ + int i, j, field = 0; + char *str, *p = NULL; + + str = malloc(len + 1); + + /* buf is terminated by '\n'. */ + /* skip '\n' in for loop. */ + for (i = 0, j = 0; i < len - 1; i++) + { + if (buf[i] == '\\' && i != len - 2) /* escape */ + { + if (buf[i+1] == delimiter) + { + i++; + str[j++] = buf[i]; + } + else + { + str[j++] = buf[i]; + } + } + else if (buf[i] == delimiter) /* delimiter */ + { + if (field == col_id) + { + break; + } + else + { + field++; + j = 0; + } + } + else + { + str[j++] = buf[i]; + } + } + + if (field == col_id) + { + str[j] = '\0'; + p = malloc(j); + if (p == NULL) + { + pool_error("parse_copy_data: malloc failed: %s", strerror(errno)); + return NULL; + } + strcpy(p, str); + p[j] = '\0'; + pool_debug("parse_copy_data: divide key value is %s", p); + } + + free(str); + return p; +} + +static void +query_cache_register(char kind, POOL_CONNECTION *frontend, char *database, char *data, int data_len) +{ + static int inside_T; /* flag to see the result data sequence */ + int result; + + if (is_select_pgcatalog || is_select_for_update) + return; + + if (kind == 'T' && parsed_query) + { + result = pool_query_cache_register(kind, frontend, database, data, data_len, parsed_query); + if (result < 0) + { + pool_error("pool_query_cache_register: query cache registration failed"); + inside_T = 0; + } + else + { + inside_T = 1; + } + } + else if ((kind == 'D' || kind == 'C' || kind == 'E') && inside_T) + { + result = pool_query_cache_register(kind, frontend, database, data, data_len, NULL); + if (kind == 'C' || kind == 'E' || result < 0) + { + if (result < 0) + pool_error("pool_query_cache_register: query cache registration failed"); + else + pool_debug("pool_query_cache_register: query cache saved"); + + inside_T = 0; + free(parsed_query); + parsed_query = NULL; + } + } +} + +void query_ps_status(char *query, POOL_CONNECTION_POOL *backend) +{ + StartupPacket *sp; + char psbuf[1024]; + int i; + + if (*query == '\0') + return; + + sp = MASTER_CONNECTION(backend)->sp; + i = snprintf(psbuf, sizeof(psbuf), "%s %s %s ", + sp->user, sp->database, remote_ps_data); + + /* skip spaces */ + while (*query && isspace(*query)) + query++; + + for (; i< sizeof(psbuf); i++) + { + if (!*query || isspace(*query)) + break; + + psbuf[i] = toupper(*query++); + } + psbuf[i] = '\0'; + + set_ps_display(psbuf, false); +} + +/* compare function for bsearch() */ +static int compare(const void *p1, const void *p2) +{ + int v1, v2; + + v1 = *(NodeTag *) p1; + v2 = *(NodeTag *) p2; + return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1); +} + +/* return true if needed to start a transaction for the nodetag */ +static bool is_internal_transaction_needed(Node *node) +{ + static NodeTag nodemap[] = { + T_InsertStmt, + T_DeleteStmt, + T_UpdateStmt, + T_SelectStmt, + T_AlterTableStmt, + T_AlterDomainStmt, + T_GrantStmt, + T_GrantRoleStmt, + T_ClosePortalStmt, + T_ClusterStmt, + T_CopyStmt, + T_CreateStmt, /* CREAE TABLE */ + T_DefineStmt, /* CREATE AGGREGATE, OPERATOR, TYPE */ + T_DropStmt, /* DROP TABLE etc. */ + T_TruncateStmt, + T_CommentStmt, + T_FetchStmt, + T_IndexStmt, /* CREATE INDEX */ + T_CreateFunctionStmt, + T_AlterFunctionStmt, + T_RemoveFuncStmt, + T_RenameStmt, /* ALTER AGGREGATE etc. */ + T_RuleStmt, /* CREATE RULE */ + T_NotifyStmt, + T_ListenStmt, + T_UnlistenStmt, + T_ViewStmt, /* CREATE VIEW */ + T_LoadStmt, + T_CreateDomainStmt, + /* + T_CreatedbStmt, CREATE DATABASE/DROP DATABASE cannot execute inside a transaction block + T_DropdbStmt, + */ + T_CreateSeqStmt, + T_AlterSeqStmt, + T_VariableSetStmt, /* SET */ + T_CreateTrigStmt, + T_DropPropertyStmt, + T_CreatePLangStmt, + T_DropPLangStmt, + T_CreateRoleStmt, + T_AlterRoleStmt, + T_DropRoleStmt, + T_LockStmt, + T_ConstraintsSetStmt, + T_ReindexStmt, + T_CreateSchemaStmt, + T_AlterDatabaseStmt, + T_AlterDatabaseSetStmt, + T_AlterRoleSetStmt, + T_CreateConversionStmt, + T_CreateCastStmt, + T_DropCastStmt, + T_CreateOpClassStmt, + T_CreateOpFamilyStmt, + T_AlterOpFamilyStmt, + T_RemoveOpClassStmt, + T_RemoveOpFamilyStmt, + T_PrepareStmt, + T_ExecuteStmt, + T_DeallocateStmt, + T_DeclareCursorStmt, + T_CreateTableSpaceStmt, + T_DropTableSpaceStmt, + T_AlterObjectSchemaStmt, + T_AlterOwnerStmt, + T_DropOwnedStmt, + T_ReassignOwnedStmt, + T_CompositeTypeStmt, /* CREATE TYPE */ + T_CreateEnumStmt, + T_AlterTSDictionaryStmt, + T_AlterTSConfigurationStmt + }; + + if (bsearch(&nodeTag(node), nodemap, sizeof(nodemap)/sizeof(nodemap[0]), sizeof(NodeTag), compare) != NULL) + { + /* + * Check CREATE INDEX CONCURRENTLY. If so, do not start transaction + */ + if (IsA(node, IndexStmt)) + { + if (((IndexStmt *)node)->concurrent) + return false; + } + + /* + * Check CLUSTER with no option. If so, do not start transaction + */ + else if (IsA(node, ClusterStmt)) + { + if (((ClusterStmt *)node)->relation == NULL) + return false; + } + + return true; + + } + return false; +} + +POOL_STATUS start_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, Node *node) +{ + int i; + + if (TSTATE(backend) != 'I') + return POOL_CONTINUE; + + /* if we are not in a transaction block, + * start a new transaction + */ + if (is_internal_transaction_needed(node)) + { + for (i=0;ipid, MASTER_CONNECTION(backend)->key, 0) != POOL_CONTINUE) + return POOL_END; + } + } + + /* mark that we started new transaction */ + internal_transaction_started = 1; + } + return POOL_CONTINUE; +} + + +POOL_STATUS end_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend) +{ + int i; +#ifdef HAVE_SIGPROCMASK + sigset_t oldmask; +#else + int oldmask; +#endif + + /* + * We must block all signals. If pgpool SIGTERM, SIGINT or SIGQUIT + * is delivered, it could cause data inconsistency. + */ + POOL_SETMASK2(&BlockSig, &oldmask); + + /* We need to commit from secondary to master. */ + for (i=0;ipid, MASTER_CONNECTION(backend)->key, 1) != POOL_CONTINUE) + { + internal_transaction_started = 0; + POOL_SETMASK(&oldmask); + return POOL_END; + } + } + } + + /* commit on master */ + if (do_command(frontend, MASTER(backend), "COMMIT", MAJOR(backend), + MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 1) != POOL_CONTINUE) + { + internal_transaction_started = 0; + POOL_SETMASK(&oldmask); + return POOL_END; + } + + internal_transaction_started = 0; + POOL_SETMASK(&oldmask); + return POOL_CONTINUE; +} + +/* + * Extract the number of tuples from CommandComplete message + */ +static int extract_ntuples(char *message) +{ + char *rows; + + if ((rows = strstr(message, "UPDATE")) || (rows = strstr(message, "DELETE"))) + rows +=7; + else if ((rows = strstr(message, "INSERT"))) + { + rows += 7; + while (*rows && *rows != ' ') rows++; + } + else + return 0; + + return atoi(rows); +} + +static int detect_postmaster_down_error(POOL_CONNECTION *backend, int major) +{ + int r = detect_error(backend, ADMIN_SHUTDOWN_ERROR_CODE, major, 'E', false); + if (r == SPECIFIED_ERROR) + { + pool_debug("detect_stop_postmaster_error: receive admin shutdown error from a node."); + return r; + } + + r = detect_error(backend, CRASH_SHUTDOWN_ERROR_CODE, major, 'N', false); + if (r == SPECIFIED_ERROR) + { + pool_debug("detect_stop_postmaster_error: receive crash shutdown error from a node."); + } + return r; +} + +int detect_active_sql_transaction_error(POOL_CONNECTION *backend, int major) +{ + int r = detect_error(backend, ACTIVE_SQL_TRANSACTION_ERROR_CODE, major, 'E', true); + if (r == SPECIFIED_ERROR) + { + pool_debug("detect_active_sql_transaction_error: receive SET TRANSACTION ISOLATION LEVEL must be called before any query error from a node."); + } + return r; +} + +int detect_deadlock_error(POOL_CONNECTION *backend, int major) +{ + int r = detect_error(backend, DEADLOCK_ERROR_CODE, major, 'E', true); + if (r == SPECIFIED_ERROR) + pool_debug("detect_deadlock_error: received deadlock error message from backend"); + return r; +} + +int detect_serialization_error(POOL_CONNECTION *backend, int major) +{ + int r = detect_error(backend, SERIALIZATION_FAIL_ERROR_CODE, major, 'E', true); + if (r == SPECIFIED_ERROR) + pool_debug("detect_serialization_error: received serialization failure message from backend"); + return r; +} + +int detect_query_cancel_error(POOL_CONNECTION *backend, int major) +{ + int r = detect_error(backend, QUERY_CANCEL_ERROR_CODE, major, 'E', true); + if (r == SPECIFIED_ERROR) + pool_debug("detect_query_cancel_error: received query cancel error message from backend"); + return r; +} + +/* + * detect_error: Detect specified error from error code. + */ +static int detect_error(POOL_CONNECTION *backend, char *error_code, int major, char class, bool unread) +{ + int is_error = 0; + char kind; + int readlen = 0, len; + static char buf[8192]; /* memory space is large enough */ + char *p, *str; + + if (pool_read(backend, &kind, sizeof(kind))) + return POOL_END; + readlen += sizeof(kind); + p = buf; + memcpy(p, &kind, sizeof(kind)); + p += sizeof(kind); + + pool_debug("detect_error: kind: %c", kind); + + /* Specified class? */ + if (kind == class) + { + /* read actual message */ + if (major == PROTO_MAJOR_V3) + { + char *e; + + if (pool_read(backend, &len, sizeof(len)) < 0) + return POOL_END; + readlen += sizeof(len); + memcpy(p, &len, sizeof(len)); + p += sizeof(len); + + len = ntohl(len) - 4; + str = malloc(len); + pool_read(backend, str, len); + readlen += len; + memcpy(p, str, len); + + /* + * Checks error code which is formatted 'Cxxxxxx' + * (xxxxxx is error code). + */ + e = str; + while (*e) + { + if (*e == 'C') + {/* specified error? */ + is_error = (strcmp(e+1, error_code) == 0) ? SPECIFIED_ERROR : 0; + break; + } + else + e = e + strlen(e) + 1; + } + free(str); + } + else + { + str = pool_read_string(backend, &len, 0); + readlen += len; + memcpy(p, str, len); + } + } + if (unread || !is_error) + { + /* put a message to read buffer */ + if (pool_unread(backend, buf, readlen) != 0) + is_error = -1; + } + + return is_error; +} + +/* + * read message length and rest of the packet then discard it + */ +POOL_STATUS pool_discard_packet(POOL_CONNECTION_POOL *cp) +{ + int status, len, i; + char kind; + char *string; + POOL_CONNECTION *backend; + + for (i=0;i + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + + +#include +#include +#include +#include +#include + +#include "pool.h" +#include "pool_signal.h" +#include "pool_proto_modules.h" +#include "parser/pool_string.h" + +int force_replication; +int replication_was_enabled; /* replication mode was enabled */ +int master_slave_was_enabled; /* master/slave mode was enabled */ +int internal_transaction_started; /* to issue table lock command a transaction + has been started internally */ +int in_progress = 0; /* indicates while doing something after receiving Query */ +int mismatch_ntuples; /* number of updated tuples */ +char *copy_table = NULL; /* copy table name */ +char *copy_schema = NULL; /* copy table name */ +char copy_delimiter; /* copy delimiter char */ +char *copy_null = NULL; /* copy null string */ +void (*pending_function)(PreparedStatementList *p, Portal *portal) = NULL; +Portal *pending_prepared_portal = NULL; +Portal *unnamed_statement = NULL; +Portal *unnamed_portal = NULL; +int select_in_transaction = 0; /* non 0 if select query is in transaction */ +int execute_select = 0; /* non 0 if select query is in transaction */ + +/* non 0 if "BEGIN" query with extended query protocol received */ +int receive_extended_begin = 0; + +/* + * Non 0 if allow to close internal transaction. This variable was + * introduced on 2008/4/3 not to close an internal transaction when + * Sync message is received after receiving Parse message. This hack + * is for PHP-PDO. + */ +static int allow_close_transaction = 1; + +PreparedStatementList prepared_list; /* prepared statement name list */ + +int is_select_pgcatalog = 0; +int is_select_for_update = 0; /* 1 if SELECT INTO or SELECT FOR UPDATE */ +bool is_parallel_table = false; + +/* + * last query string sent to simpleQuery() + */ +char query_string_buffer[QUERY_STRING_BUFFER_LEN]; + +/* + * query string produced by nodeToString() in simpleQuery(). + * this variable only usefull when enable_query_cache is true. + */ +char *parsed_query = NULL; + +static int check_errors(POOL_CONNECTION_POOL *backend, int backend_id); +static void generate_error_message(char *prefix, int specific_error, char *query); + +POOL_STATUS NotificationResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend) +{ + int pid, pid1; + char *condition, *condition1 = NULL; + int len, len1 = 0; + int i; + POOL_STATUS status; + + pool_write(frontend, "A", 1); + + for (i=0;ilog_statement) + { + pool_log("statement: %s", string); + } + else + { + pool_debug("statement2: %s", string); + } + + /* parse SQL string */ + parse_tree_list = raw_parser(string); + + if (parse_tree_list != NIL) + { + node = (Node *) lfirst(list_head(parse_tree_list)); + + if (PARALLEL_MODE) + is_parallel_table = is_partition_table(backend,node); + + if (pool_config->enable_query_cache && + SYSDB_STATUS == CON_UP && + IsA(node, SelectStmt) && + !(is_select_pgcatalog = IsSelectpgcatalog(node, backend))) + { + SelectStmt *select = (SelectStmt *)node; + + if (! (select->intoClause || select->lockingClause)) + { + parsed_query = strdup(nodeToString(node)); + if (parsed_query == NULL) + { + pool_error("pool_process_query: malloc failed"); + return POOL_ERROR; + } + + if (parsed_query) + { + if (pool_query_cache_lookup(frontend, parsed_query, backend->info->database, TSTATE(backend)) == POOL_CONTINUE) + { + free(parsed_query); + parsed_query = NULL; + free_parser(); + return POOL_CONTINUE; + } + } + is_select_for_update = 0; + } + else + { + is_select_for_update = 1; + } + } + + if (pool_config->parallel_mode) + { + /* The Query is analyzed first in a parallel mode(in_parallel_query), + * and, next, the Query is rewritten(rewrite_query_stmt). + */ + + /* analyze the query */ + RewriteQuery *r_query = is_parallel_query(node,backend); + + if(r_query->is_loadbalance) + { + /* Usual processing of pgpool is done by using the rewritten Query + * if judged a possible load-balancing as a result of analyzing + * the Query. + * Of course, the load is distributed only for load_balance_mode=true. + */ + if(r_query->r_code == SEND_LOADBALANCE_ENGINE) + { + /* use rewritten query */ + string = r_query->rewrite_query; + /* change query length */ + len = strlen(string)+1; + } + pool_debug("SimpleQuery: loadbalance_query =%s",string); + } + else if (r_query->is_parallel) + { + /* + * For the Query that the parallel processing is possible. + * Call parallel exe engine and return status to the upper layer. + */ + POOL_STATUS stats = pool_parallel_exec(frontend,backend,r_query->rewrite_query, node,true); + free_parser(); + in_progress = 0; + return stats; + } + else if(!r_query->is_pg_catalog) + { + /* rewrite query and execute */ + r_query = rewrite_query_stmt(node,frontend,backend,r_query); + if(r_query->type == T_InsertStmt) + { + free_parser(); + + if(r_query->r_code != INSERT_DIST_NO_RULE) { + in_progress = 0; + return r_query->status; + } + } + else if(r_query->type == T_SelectStmt) + { + free_parser(); + in_progress = 0; + return r_query->status; + } + } + /* + * The same processing as usual pgpool is done to other Query type. + */ + } + + /* check COPY FROM STDIN + * if true, set copy_* variable + */ + check_copy_from_stdin(node); + + /* + * if this is DROP DATABASE command, send USR1 signal to parent and + * ask it to close all idle connections. + * XXX This is overkill. It would be better to close the idle + * connection for the database which DROP DATABASE command tries + * to drop. This is impossible at this point, since we have no way + * to pass such info to other processes. + */ + if (is_drop_database(node)) + { + int stime = 5; /* XXX give arbitrary time to allow closing idle connections */ + + pool_debug("Query: sending SIGUSR1 signal to parent"); + + Req_info->kind = CLOSE_IDLE_REQUEST; + kill(getppid(), SIGUSR1); /* send USR1 signal to parent */ + + /* we need to loop over here since we will get USR1 signal while sleeping */ + while (stime > 0) + { + stime = sleep(stime); + } + } + + /* process status reporting? */ + if (IsA(node, VariableShowStmt) && strncasecmp(sq, string, strlen(sq)) == 0) + { + StartupPacket *sp; + char psbuf[1024]; + + pool_debug("process reporting"); + process_reporting(frontend, backend); + in_progress = 0; + + /* show ps status */ + sp = MASTER_CONNECTION(backend)->sp; + snprintf(psbuf, sizeof(psbuf), "%s %s %s idle", + sp->user, sp->database, remote_ps_data); + set_ps_display(psbuf, false); + + free_parser(); + return POOL_CONTINUE; + } + + if (IsA(node, PrepareStmt) || IsA(node, DeallocateStmt) || + IsA(node, VariableSetStmt) || IsA(node, DiscardStmt)) + { + /* + * PREPARE, DEALLOCATE and SET statements must be replicated. + */ + if (MASTER_SLAVE && TSTATE(backend) != 'E') + force_replication = 1; + + /* + * Before we did followings only when frontend != NULL, + * which was wrong since if, for example, reset_query_list + * contains "DISCARD ALL", then it does not register + * pending function and it causes trying to DEALLOCATE non + * existing prepared statment(2009/4/3 Tatsuo). + */ + if (IsA(node, PrepareStmt)) + { + pending_function = add_prepared_list; + portal = create_portal(); + if (portal == NULL) + { + pool_error("SimpleQuery: create_portal() failed"); + return POOL_END; + } + + /* switch memory context */ + old_context = pool_memory; + pool_memory = portal->prepare_ctxt; + + portal->portal_name = NULL; + portal->stmt = copyObject(node); + portal->sql_string = NULL; + pending_prepared_portal = portal; + } + else if (IsA(node, DeallocateStmt)) + { + pending_function = del_prepared_list; + portal = create_portal(); + if (portal == NULL) + { + pool_error("SimpleQuery: create_portal() failed"); + return POOL_END; + } + + /* switch memory context */ + old_context = pool_memory; + pool_memory = portal->prepare_ctxt; + + portal->portal_name = NULL; + portal->stmt = copyObject(node); + portal->sql_string = NULL; + pending_prepared_portal = portal; + } + else if (IsA(node, DiscardStmt)) + { + DiscardStmt *stmt = (DiscardStmt *)node; + if (stmt->target == DISCARD_ALL || stmt->target == DISCARD_PLANS) + { + pending_function = delete_all_prepared_list; + pending_prepared_portal = NULL; + } + } + + /* switch old memory context */ + if (old_context) + pool_memory = old_context; + + /* end of wrong if (see 2009/4/3 comment above) */ + } + + if (frontend && IsA(node, ExecuteStmt)) + { + Portal *portal; + PrepareStmt *p_stmt; + ExecuteStmt *e_stmt = (ExecuteStmt *)node; + + portal = lookup_prepared_statement_by_statement(&prepared_list, + e_stmt->name); + if (!portal) + { + string1 = string; + node1 = node; + } + else + { + p_stmt = (PrepareStmt *)portal->stmt; + string1 = nodeToString(p_stmt->query); + node1 = (Node *)p_stmt->query; + } + } + else + { + string1 = string; + node1 = node; + } + + /* load balance trick */ + if (load_balance_enabled(backend, node1, string1)) + start_load_balance(backend); + else if (MASTER_SLAVE) + { + pool_debug("SimpleQuery: set master_slave_dml query: %s", string); + master_slave_was_enabled = 1; + MASTER_SLAVE = 0; + master_slave_dml = 1; + if (force_replication) + { + replication_was_enabled = 0; + REPLICATION = 1; + } + } + else if (REPLICATION && + !pool_config->replicate_select && + is_select_query(node1, string1) && + !is_sequence_query(node1)) + { + selected_slot = MASTER_NODE_ID; + replication_was_enabled = 1; + REPLICATION = 0; + LOAD_BALANCE_STATUS(MASTER_NODE_ID) = LOAD_SELECTED; + in_load_balance = 1; + select_in_transaction = 1; + } + + + /* + * determine if we need to lock the table + * to keep SERIAL data consistency among servers + * conditions: + * - replication is enabled + * - protocol is V3 + * - statement is INSERT + * - either "INSERT LOCK" comment exists or insert_lock directive specified + */ + if (REPLICATION) + { + /* start a transaction if needed */ + if (start_internal_transaction(frontend, backend, (Node *)node) != POOL_CONTINUE) + return POOL_END; + + /* check if need lock */ + if (need_insert_lock(backend, string, node)) + { + /* if so, issue lock command */ + status = insert_lock(frontend, backend, string, (InsertStmt *)node); + if (status != POOL_CONTINUE) + { + free_parser(); + return status; + } + } + } + else if (REPLICATION && query == NULL && start_internal_transaction(frontend, backend, node)) + { + free_parser(); + return POOL_ERROR; + } + } + else + { /* syntax error */ + if (MASTER_SLAVE) + { + pool_debug("SimpleQuery: set master_slave_dml query: %s", string); + master_slave_was_enabled = 1; + MASTER_SLAVE = 0; + master_slave_dml = 1; + } + } + + if (MAJOR(backend) == PROTO_MAJOR_V2 && is_start_transaction_query(node)) + { + TSTATE(backend) = 'T'; + } + + if (REPLICATION || PARALLEL_MODE) + { + /* check if query is "COMMIT" or "ROLLBACK" */ + commit = is_commit_query(node); + free_parser(); + + /* + * Query is not commit/rollback + */ + if (!commit) + { + /* Send the query to master node */ + + if (send_simplequery_message(MASTER(backend), len, string, MAJOR(backend)) != POOL_CONTINUE) + return POOL_END; + + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + + /* Check specific errors */ + specific_error = check_errors(backend, MASTER_NODE_ID); + if (specific_error) + { + /* log error message */ + generate_error_message("SimpleQuery: ", specific_error, string); + + /* Set error query to abort transactions on other nodes */ + string = POOL_ERROR_QUERY; + len = strlen(string) + 1; + } + } + + /* send query to other than master nodes */ + for (i=0;ipid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + } + + /* send "COMMIT" or "ROLLBACK" to only master node if query is "COMMIT" or "ROLLBACK" */ + if (commit) + { + if (send_simplequery_message(MASTER(backend), len, string, MAJOR(backend)) != POOL_CONTINUE) + return POOL_END; + + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + + + TSTATE(backend) = 'I'; + } + } + else + { + free_parser(); + if (send_simplequery_message(MASTER(backend), len, string, MAJOR(backend)) != POOL_CONTINUE) + return POOL_END; + + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + } + + return POOL_CONTINUE; +} + +/* + * process EXECUTE (V3 only) + */ +POOL_STATUS Execute(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend) +{ + char *string; /* portal name + null terminate + max_tobe_returned_rows */ + int len; + int i; + char kind; + int status, commit = 0; + Portal *portal; + char *string1; + PrepareStmt *p_stmt; + POOL_STATUS ret; + int specific_error = 0; + + /* read Execute packet */ + if (pool_read(frontend, &len, sizeof(len)) < 0) + return POOL_END; + + len = ntohl(len) - 4; + string = pool_read2(frontend, len); + + pool_debug("Execute: portal name <%s>", string); + + portal = lookup_prepared_statement_by_portal(&prepared_list, + string); + + /* load balance trick */ + if (portal) + { + Node *node; + + p_stmt = (PrepareStmt *)portal->stmt; + + string1 = portal->sql_string; + pool_debug("Execute: query: %s", string1); + node = (Node *)p_stmt->query; + strncpy(query_string_buffer, string1, sizeof(query_string_buffer)); + + if ((IsA(node, PrepareStmt) || IsA(node, DeallocateStmt) || + IsA(node, VariableSetStmt)) && + MASTER_SLAVE && TSTATE(backend) != 'E') + { + /* + * PREPARE, DEALLOCATE, SET, DISCARD + * should be executed on all nodes. So we set + * force_replication. + */ + force_replication = 1; + } + /* + * JDBC driver sends "BEGIN" query internally if + * setAutoCommit(false). But it does not send Sync message + * after "BEGIN" query. In extended query protocol, + * PostgreSQL returns ReadyForQuery when a client sends Sync + * message. Problem is, pgpool can't know the transaction + * state without receiving ReadyForQuery. So we remember that + * we need to send Sync message internally afterward, whenever + * we receive BEGIN in extended protocol. + */ + else if (IsA(node, TransactionStmt) && MASTER_SLAVE) + { + TransactionStmt *stmt = (TransactionStmt *) node; + + if (stmt->kind == TRANS_STMT_BEGIN || + stmt->kind == TRANS_STMT_START) + /* Remember we need to send sync later in extended protocol */ + receive_extended_begin = 1; + } + + if (load_balance_enabled(backend, node, string1)) + start_load_balance(backend); + else if (REPLICATION && + !pool_config->replicate_select && + is_select_query((Node *)p_stmt->query, string1) && + !is_sequence_query((Node *)p_stmt->query)) + { + selected_slot = MASTER_NODE_ID; + replication_was_enabled = 1; + REPLICATION = 0; + LOAD_BALANCE_STATUS(MASTER_NODE_ID) = LOAD_SELECTED; + in_load_balance = 1; + select_in_transaction = 1; + execute_select = 1; + } +/* + else if (REPLICATION && start_internal_transaction(backend, (Node *)p_stmt->query)) + { + return POOL_END; + } +*/ + /* check if query is "COMMIT" or "ROLLBACK" */ + commit = is_commit_query((Node *)p_stmt->query); + } + + if (MASTER_SLAVE) + { + master_slave_was_enabled = 1; + MASTER_SLAVE = 0; + master_slave_dml = 1; + if (force_replication) + { + replication_was_enabled = 0; + REPLICATION = 1; + } + } + + if (REPLICATION || PARALLEL_MODE) + { + /* + * Query is not commit/rollback + */ + if (!commit) + { + /* Send the query to master node */ + + if (send_execute_message(backend, MASTER_NODE_ID, len, string) != POOL_CONTINUE) + return POOL_END; + + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + + + /* Check specific errors */ + specific_error = check_errors(backend, MASTER_NODE_ID); + if (specific_error) + { + /* log error message */ + generate_error_message("Execute: ", specific_error, string); + } + } + + /* send query to other nodes */ + for (i=0;ipid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + } + + /* send "COMMIT" or "ROLLBACK" to only master node if query is "COMMIT" or "ROLLBACK" */ + if (commit) + { + if (send_execute_message(backend, MASTER_NODE_ID, len, string) != POOL_CONTINUE) + return POOL_END; + + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + } + } + else + { + if (send_execute_message(backend, MASTER_NODE_ID, len, string) != POOL_CONTINUE) + return POOL_END; + + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + + return POOL_END; + } + } + + while ((ret = read_kind_from_backend(frontend, backend, &kind)) == POOL_CONTINUE) + { + /* + * forward message until receiving CommandComplete, + * ErrorResponse, EmptyQueryResponse or PortalSuspend. + */ + if (kind == 'C' || kind == 'E' || kind == 'I' || kind == 's') + break; + + status = SimpleForwardToFrontend(kind, frontend, backend); + if (status != POOL_CONTINUE) + return status; + } + if (ret != POOL_CONTINUE) + return ret; + + status = SimpleForwardToFrontend(kind, frontend, backend); + if (status != POOL_CONTINUE) + return status; + + return POOL_CONTINUE; +} + +/* + * process Parse (V3 only) + */ +POOL_STATUS Parse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend) +{ + char kind; + int len; + char *string; + int i; + Portal *portal; + POOL_MEMORY_POOL *old_context; + PrepareStmt *p_stmt; + char *name, *stmt; + List *parse_tree_list; + Node *node = NULL; + int deadlock_detected = 0; + int insert_stmt_with_lock = 0; + POOL_STATUS status; + + /* read Parse packet */ + if (pool_read(frontend, &len, sizeof(len)) < 0) + return POOL_END; + + len = ntohl(len) - 4; + string = pool_read2(frontend, len); + + pool_debug("Parse: portal name <%s>", string); + + name = string; + stmt = string + strlen(string) + 1; + + parse_tree_list = raw_parser(stmt); + if (parse_tree_list == NIL) + { + free_parser(); + } + else + { + /* Save last query string for logging purpose */ + snprintf(query_string_buffer, sizeof(query_string_buffer), "Parse: %s", stmt); + + node = (Node *) lfirst(list_head(parse_tree_list)); + + insert_stmt_with_lock = need_insert_lock(backend, stmt, node); + + portal = create_portal(); + if (portal == NULL) + { + pool_error("Parse: create_portal() failed"); + return POOL_END; + } + + /* switch memory context */ + old_context = pool_memory; + pool_memory = portal->prepare_ctxt; + + /* translate Parse message to PrepareStmt */ + p_stmt = palloc(sizeof(PrepareStmt)); + p_stmt->type = T_PrepareStmt; + p_stmt->name = pstrdup(name); + p_stmt->query = copyObject(node); + portal->stmt = (Node *)p_stmt; + portal->portal_name = NULL; + portal->sql_string = pstrdup(stmt); + + if (*name) + { + pending_function = add_prepared_list; + pending_prepared_portal = portal; + } + else /* unnamed statement */ + { + pending_function = add_unnamed_portal; + pfree(p_stmt->name); + p_stmt->name = NULL; + pending_prepared_portal = portal; + } + + /* switch old memory context */ + pool_memory = old_context; + + if (REPLICATION) + { + char kind; + + if (TSTATE(backend) != 'T') + { + /* synchronize transaction state */ + for (i = 0; i < NUM_BACKENDS; i++) + { + if (!VALID_BACKEND(i)) + continue; + + /* send sync message */ + send_extended_protocol_message(backend, i, "S", 0, ""); + } + + kind = pool_read_kind(backend); + if (kind != 'Z') + return POOL_END; + if (ReadyForQuery(frontend, backend, 0) != POOL_CONTINUE) + return POOL_END; + } + + if (is_strict_query(node)) + start_internal_transaction(frontend, backend, node); + + if (insert_stmt_with_lock) + { + /* start a transaction if needed and lock the table */ + status = insert_lock(frontend, backend, stmt, (InsertStmt *)node); + if (status != POOL_CONTINUE) + { + return status; + } + } + } + free_parser(); + } + + /* send to master node */ + if (send_extended_protocol_message(backend, MASTER_NODE_ID, + "P", len, string)) + return POOL_END; + + if (REPLICATION || PARALLEL_MODE || MASTER_SLAVE) + { + /* + * We must synchronize because Parse message acquires table + * locks. + */ + pool_debug("Parse: waiting for master completing the query"); + if (wait_for_query_response(frontend, MASTER(backend), string, MAJOR(backend)) != POOL_CONTINUE) + { + /* Cancel current transaction */ + CancelPacket cancel_packet; + + cancel_packet.protoVersion = htonl(PROTO_CANCEL); + cancel_packet.pid = MASTER_CONNECTION(backend)->pid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + return POOL_END; + } + + /* + * We must check deadlock error because a aborted transaction + * by detecting deadlock isn't same on all nodes. + * If a transaction is aborted on master node, pgpool send a + * error query to another nodes. + */ + deadlock_detected = detect_deadlock_error(MASTER(backend), MAJOR(backend)); + if (deadlock_detected < 0) + return POOL_END; + + for (i=0;ipid; + cancel_packet.key= MASTER_CONNECTION(backend)->key; + cancel_request(&cancel_packet); + return POOL_END; + } + } + } + + for (;;) + { + POOL_STATUS ret; + ret = read_kind_from_backend(frontend, backend, &kind); + + if (ret != POOL_CONTINUE) + return ret; + + SimpleForwardToFrontend(kind, frontend, backend); + if (pool_flush(frontend) < 0) + return POOL_ERROR; + + /* Ignore warning messages */ + if (kind != 'N') + break; + } + return POOL_CONTINUE; +} + +/* + * Process ReadyForQuery('Z') message. + * + * - if the global error status "mismatch_ntuples" is set, send an error query + * to all DB nodes to abort transaction. + * - internal transaction is closed + */ +POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int send_ready) +{ + StartupPacket *sp; + char psbuf[1024]; + int i; + int len; + signed char state; + + /* + * If the numbers of update tuples are differ, we need to abort transaction + * by using do_error_command. This only works with PROTO_MAJOR_V3. + */ + if (mismatch_ntuples && MAJOR(backend) == PROTO_MAJOR_V3) + { + int i; + signed char state; + char kind; + + /* + * XXX: discard rest of ReadyForQuery packet + */ + if (pool_read_message_length(backend) < 0) + return POOL_END; + + state = pool_read_kind(backend); + if (state < 0) + return POOL_END; + + pool_debug("ReadyForQuery: transaction state: %c", state); + + for (i = 0; i < NUM_BACKENDS; i++) + { + if (VALID_BACKEND(i)) + { + /* abort transaction on all nodes. */ + do_error_command(CONNECTION(backend, i), PROTO_MAJOR_V3); + } + } + + /* loop through until we get ReadyForQuery */ + for(;;) + { + kind = pool_read_kind(backend); + if (kind < 0) + return POOL_END; + + if (kind == 'Z') + break; + + /* put the message back to read buffer */ + for (i=0;itstate = state; + } + } + + if (send_ready) + { + pool_write(frontend, "Z", 1); + + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + len = htonl(len); + pool_write(frontend, &len, sizeof(len)); + pool_write(frontend, &state, 1); + } + + if (pool_flush(frontend)) + return POOL_END; + } + + in_progress = 0; + + /* end load balance mode */ + if (in_load_balance) + end_load_balance(backend); + + if (master_slave_dml) + { + MASTER_SLAVE = 1; + master_slave_was_enabled = 0; + master_slave_dml = 0; + if (force_replication) + { + force_replication = 0; + REPLICATION = 0; + replication_was_enabled = 0; + } + } + +#ifdef NOT_USED + return ProcessFrontendResponse(frontend, backend); +#endif + + sp = MASTER_CONNECTION(backend)->sp; + if (MASTER(backend)->tstate == 'T') + snprintf(psbuf, sizeof(psbuf), "%s %s %s idle in transaction", + sp->user, sp->database, remote_ps_data); + else + snprintf(psbuf, sizeof(psbuf), "%s %s %s idle", + sp->user, sp->database, remote_ps_data); + set_ps_display(psbuf, false); + + return POOL_CONTINUE; +} + + +POOL_STATUS FunctionCall(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend) +{ + char dummy[2]; + int oid; + int argn; + int i; + + for (i=0;ilen <= 0 && frontend->no_forward != 0) + return POOL_CONTINUE; + + if (pool_read(frontend, &fkind, 1) < 0) + { + pool_log("ProcessFrontendResponse: failed to read kind from frontend. frontend abnormally exited"); + return POOL_END; + } + + pool_debug("read kind from frontend %c(%02x)", fkind, fkind); + + /* + * If we have received BEGIN in extended protocol before, we need + * to send a sync message to know the transaction stare. + */ + if (receive_extended_begin) + { + receive_extended_begin = 0; + + /* send sync message */ + send_extended_protocol_message(backend, MASTER_NODE_ID, "S", 0, ""); + + kind = pool_read_kind(backend); + if (kind != 'Z') + return POOL_END; + if (ReadyForQuery(frontend, backend, 0) != POOL_CONTINUE) + return POOL_END; + } + + switch (fkind) + { + + case 'X': /* Terminate message*/ + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + int len; + pool_read(frontend, &len, sizeof(len)); + } + return POOL_END; + + case 'Q': /* Query message*/ + in_progress = 1; + allow_close_transaction = 1; + status = SimpleQuery(frontend, backend, NULL); + break; + + case 'E': /* Execute message */ + allow_close_transaction = 1; + status = Execute(frontend, backend); + break; + + case 'P': /* Parse message */ + allow_close_transaction = 0; + status = Parse(frontend, backend); + break; + + case 'S': /* Sync message */ + receive_extended_begin = 0; + /* fall through */ + + default: + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + if (MASTER_SLAVE && + (TSTATE(backend) != 'I' || receive_extended_begin)) + { + pool_debug("kind: %c master_slave_dml enabled", fkind); + master_slave_was_enabled = 1; + MASTER_SLAVE = 0; + master_slave_dml = 1; + } + + status = SimpleForwardToBackend(fkind, frontend, backend); + for (i=0;i 0 */ + if (size1 > 0) + { + sendbuf = pool_read2(MASTER(backend), size1); + if (sendbuf == NULL) + return POOL_END; + } + + /* forward to frontend */ + pool_write(frontend, &size, sizeof(int)); + pool_write(frontend, sendbuf, size1); + snprintf(msgbuf, Min(sizeof(msgbuf), size1+1), "%s", sendbuf); + pool_debug("AsciiRow: len: %d data: %s", size1, msgbuf); + + for (j=0;j 0 */ + if (size > 0) + { + buf = pool_read2(CONNECTION(backend, j), size); + if (buf == NULL) + return POOL_END; + } + } + } + } + + mask >>= 1; + } + + if (pool_flush(frontend)) + return POOL_END; + + return POOL_CONTINUE; +} + +POOL_STATUS BinaryRow(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + short num_fields) +{ + static char nullmap[8192], nullmap1[8192]; + int nbytes; + int i, j; + unsigned char mask; + int size, size1 = 0; + char *buf = NULL; + + pool_write(frontend, "B", 1); + + nbytes = (num_fields + 7)/8; + + if (nbytes <= 0) + return POOL_CONTINUE; + + /* NULL map */ + pool_read(MASTER(backend), nullmap, nbytes); + if (pool_write(frontend, nullmap, nbytes) < 0) + return POOL_END; + memcpy(nullmap1, nullmap, nbytes); + for (i=0;i 0 */ + if (size > 0) + { + buf = pool_read2(CONNECTION(backend, j), size); + if (buf == NULL) + return POOL_END; + + if (IS_MASTER_NODE_ID(j)) + { + pool_write(frontend, buf, size); + } + } + } + + mask >>= 1; + } + } + + if (pool_flush(frontend)) + return POOL_END; + + return POOL_CONTINUE; +} + +POOL_STATUS CursorResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend) +{ + char *string = NULL; + char *string1 = NULL; + int len, len1 = 0; + int i; + + /* read cursor name */ + string = pool_read_string(MASTER(backend), &len, 0); + if (string == NULL) + return POOL_END; + len1 = len; + string1 = strdup(string); + + for (i=0;iparallel_mode == TRUE) + { + info = pool_get_dist_def_info(MASTER_CONNECTION(backend)->sp->database, + copy_schema, + copy_table); + } + + for (;;) + { + if (copyin) + { + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + char kind; + int sendlen; + char *p, *p1; + + if (pool_read(frontend, &kind, 1) < 0) + return POOL_END; + + if (info && kind == 'd') + { + int id; + if (pool_read(frontend, &sendlen, sizeof(sendlen))) + { + return POOL_END; + } + + len = ntohl(sendlen) - 4; + + if (len <= 0) + return POOL_CONTINUE; + + p = pool_read2(frontend, len); + if (p == NULL) + return POOL_END; + + /* copy end ? */ + if (len == 3 && memcmp(p, "\\.\n", 3) == 0) + { + for (i=0;idist_key_col_id); + + if (!p1) + { + pool_error("CopyDataRow: cannot parse data"); + return POOL_END; + } + else if (strcmp(p1, copy_null) == 0) + { + pool_error("CopyDataRow: key parameter is NULL"); + free(p1); + return POOL_END; + } + + id = pool_get_id(info, p1); + pool_debug("CopyDataRow: copying id: %d", id); + free(p1); + if (!VALID_BACKEND(id)) + { + exit(1); + } + if (pool_write(CONNECTION(backend, id), &kind, 1)) + { + return POOL_END; + } + if (pool_write(CONNECTION(backend, id), &sendlen, sizeof(sendlen))) + { + return POOL_END; + } + if (pool_write_and_flush(CONNECTION(backend, id), p, len)) + { + return POOL_END; + } + } + } + else + { + SimpleForwardToBackend(kind, frontend, backend); + } + + /* CopyData? */ + if (kind == 'd') + continue; + else + { + pool_debug("CopyDataRows: copyin kind other than d (%c)", kind); + break; + } + } + else + string = pool_read_string(frontend, &len, 1); + } + else + { + /* CopyOut */ + if (MAJOR(backend) == PROTO_MAJOR_V3) + { + signed char kind; + + if ((kind = pool_read_kind(backend)) < 0) + return POOL_END; + + SimpleForwardToFrontend(kind, frontend, backend); + + /* CopyData? */ + if (kind == 'd') + continue; + else + break; + } + else + { + for (i=0;i sizeof(error_messages)/sizeof(char *)) + { + pool_error("generate_error_message: invalid specific_error: %d", specific_error); + return; + } + + specific_error--; + + msg = init_string(prefix); + string_append_char(msg, error_messages[specific_error]); + pool_error(msg->data, query); + free_string(msg); +} diff --git a/pool_proto_modules.h b/pool_proto_modules.h new file mode 100644 index 0000000..f086465 --- /dev/null +++ b/pool_proto_modules.h @@ -0,0 +1,187 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.h,v 1.1.2.5 2009/10/03 11:55:50 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_proto_modules.h.: header file for pool_proto_modules.c and pool_process_qeury.c + * + */ + +#ifndef POOL_PROTO_MODULES_H +#define POOL_PROTO_MODULES_H + +#include "parser/parser.h" +#include "parser/pool_memory.h" +#include "parser/pg_list.h" +#include "parser/parsenodes.h" +#include "pool_rewrite_query.h" + +#define SPECIFIED_ERROR 1 +#define POOL_ERROR_QUERY "send invalid query from pgpool to abort transaction" + + +/* Prepared statement information */ +typedef struct { + char *portal_name; /* portal name*/ + Node *stmt; /* parse tree for prepared statement */ + char *sql_string; /* original SQL statement */ + POOL_MEMORY_POOL *prepare_ctxt; /* memory context for parse tree */ +} Portal; + +/* + * prepared statement list + */ +typedef struct { + int size; + int cnt; + Portal **portal_list; +} PreparedStatementList; + +extern int force_replication; +extern int replication_was_enabled; /* replication mode was enabled */ +extern int master_slave_was_enabled; /* master/slave mode was enabled */ +extern int internal_transaction_started; /* to issue table lock command a transaction + has been started internally */ +extern int in_progress; /* indicates while doing something after receiving Query */ +extern int mismatch_ntuples; /* number of updated tuples */ +extern char *copy_table; /* copy table name */ +extern char *copy_schema; /* copy table name */ +extern char copy_delimiter; /* copy delimiter char */ +extern char *copy_null; /* copy null string */ +extern void (*pending_function)(PreparedStatementList *p, Portal *portal); +extern Portal *pending_prepared_portal; +extern Portal *unnamed_statement; +extern Portal *unnamed_portal; +extern int select_in_transaction; /* non 0 if select query is in transaction */ +extern int execute_select; /* non 0 if select query is in transaction */ + +/* non 0 if "BEGIN" query with extended query protocol received */ +extern int receive_extended_begin; + +extern int is_select_pgcatalog; +extern int is_select_for_update; /* also for SELECT ... INTO */ +extern bool is_parallel_table; +extern char *parsed_query; + +extern PreparedStatementList prepared_list; /* prepared statement name list */ + +/* + * modules defined in pool_proto_modules.c + */ +extern POOL_STATUS NotificationResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, char *query); + +extern POOL_STATUS Execute(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS Parse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int send_ready); + +extern POOL_STATUS CompleteCommandResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS CopyInResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS CopyOutResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS CopyDataRows(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, int copyin); + +extern POOL_STATUS CursorResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS EmptyQueryResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern int RowDescription(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + short *result); + +extern POOL_STATUS AsciiRow(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + short num_fields); + +extern POOL_STATUS BinaryRow(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend, + short num_fields); + +extern POOL_STATUS FunctionCall(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS FunctionResultResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + +extern POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend, + POOL_CONNECTION_POOL *backend); + + +extern POOL_STATUS wait_for_query_response(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, char *string, int protoVersion); +extern int is_select_query(Node *node, char *sql); +extern int is_sequence_query(Node *node); +extern int is_start_transaction_query(Node *node); +extern int is_commit_query(Node *node); +extern int is_strict_query(Node *node); /* returns non 0 if this is strict query */ +extern int load_balance_enabled(POOL_CONNECTION_POOL *backend, Node* node, char *sql); +extern void start_load_balance(POOL_CONNECTION_POOL *backend); +extern void end_load_balance(POOL_CONNECTION_POOL *backend); +extern int need_insert_lock(POOL_CONNECTION_POOL *backend, char *query, Node *node); +extern POOL_STATUS insert_lock(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *query, InsertStmt *node); +extern void add_prepared_list(PreparedStatementList *p, Portal *portal); +extern void add_unnamed_portal(PreparedStatementList *p, Portal *portal); +extern void delete_all_prepared_list(PreparedStatementList *p, Portal *portal); +extern char *parse_copy_data(char *buf, int len, char delimiter, int col_id); +extern Portal *lookup_prepared_statement_by_portal(PreparedStatementList *p, const char *name);extern Portal *lookup_prepared_statement_by_statement(PreparedStatementList *p, const char *name); +extern int check_copy_from_stdin(Node *node); /* returns non 0 if this is a COPY FROM STDIN */ +extern void query_ps_status(char *query, POOL_CONNECTION_POOL *backend); /* show ps status */ +extern POOL_STATUS start_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, Node *node); +extern POOL_STATUS end_internal_transaction(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern int detect_deadlock_error(POOL_CONNECTION *master, int major); +extern int detect_serialization_error(POOL_CONNECTION *master, int major); +extern int detect_active_sql_transaction_error(POOL_CONNECTION *backend, int major); +extern int detect_query_cancel_error(POOL_CONNECTION *backend, int major); +extern bool is_partition_table(POOL_CONNECTION_POOL *backend, Node *node); +extern POOL_STATUS pool_discard_packet(POOL_CONNECTION_POOL *cp); + +extern int is_drop_database(Node *node); /* returns non 0 if this is a DROP DATABASE command */ +extern void process_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); +extern Portal *create_portal(void); +extern void del_prepared_list(PreparedStatementList *p, Portal *portal); + +extern POOL_STATUS send_simplequery_message(POOL_CONNECTION *backend, int len, char *string, int major); +extern POOL_STATUS send_extended_protocol_message(POOL_CONNECTION_POOL *backend, + int node_id, char *kind, + int len, char *string); + +extern POOL_STATUS send_execute_message(POOL_CONNECTION_POOL *backend, + int node_id, int len, char *string); + +extern int synchronize(POOL_CONNECTION *cp); +extern POOL_STATUS read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *decided_kind); +extern POOL_STATUS read_kind_from_one_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, char *kind, int node); +extern POOL_STATUS do_error_command(POOL_CONNECTION *backend, int major); + +#endif diff --git a/pool_query_cache.c b/pool_query_cache.c new file mode 100644 index 0000000..7191a88 --- /dev/null +++ b/pool_query_cache.c @@ -0,0 +1,983 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_query_cache.c,v 1.9.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_query_cache.c: query cache + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#include "pool.h" +#include "md5.h" + +#define QUERY_CACHE_TABLE_NAME "query_cache" +#define CACHE_REGISTER_PREPARED_STMT "register_prepared_stmt" +#define DEFAULT_CACHE_SIZE 8192 + +#define SYSDB_CON (SYSDB_CONNECTION->con) +#define SYSDB_MAJOR (SYSDB_CONNECTION->sp->major) +#define CACHE_TABLE_INFO (SYSDB_INFO->query_cache_table_info) + +/* data structure to store RowDescription and DataRow cache */ +typedef struct +{ + char *md5_query; /* query in md5 hushed format*/ + char *query; /* query string */ + char *cache; /* cached data */ + int cache_size; /* cached data size */ + int cache_offset; /* points the end of cache */ + char *db_name; /* database name */ + char *create_time; /* cache create timestamp in ISO format */ +} QueryCacheInfo; + +typedef enum +{ + CACHE_FOUND, CACHE_NOT_FOUND, CACHE_ERROR +} CACHE_STATUS; + +static QueryCacheInfo *query_cache_info; + +static CACHE_STATUS search_system_db_for_cache(POOL_CONNECTION *frontend, char *sql, int sql_len, struct timeval *t, char tstate); +static int ForwardCacheToFrontend(POOL_CONNECTION *frontend, char *cache, char tstate); +static int init_query_cache_info(POOL_CONNECTION *pc, char *database, char *query); +static void free_query_cache_info(void); +static int malloc_failed(void *p); +static int write_cache(void *buf, int len); +static char *pq_time_to_str(time_t t); +static int system_db_connection_exists(void); +static void define_prepared_statements(void); + +/* -------------------------------- + * pool_clear_cache - clears cache data from the SystemDB + * + * return 0 on success, -1 otherwise + * -------------------------------- + */ +int +pool_clear_cache_by_time(Interval *interval, int size) +{ + PGresult *pg_result = NULL; + long interval_in_days = 0; + long interval_in_seconds = 0; + time_t query_delete_timepoint; + char *query_delete_timepoint_in_str = NULL; + int sql_len; + char *sql = NULL; + int i; + + if (! system_db_connection_exists()) + return -1; + + for (i = 0; i < size; i++) + { + int q = interval[i].quantity; + + switch (interval[i].unit) + { + case millennium: + case millenniums: + q *= 10; + + case century: + case centuries: + q *= 10; + + case decade: + case decades: + q *= 10; + + case year: + case years: + q *= 12; + + case month: + case months: + q *= 31; /* should I change this according to the month? */ + interval_in_days += q; + break; + + case week: + case weeks: + q *= 7; + + case day: + case days: + q *= 24; + + case hour: + case hours: + q *= 60; + + case minute: + case minutes: + q *= 60; + + case second: + case seconds: + interval_in_seconds += q; + break; + } + } + + interval_in_seconds = (interval_in_days * 86400) + interval_in_seconds; + query_delete_timepoint = time(NULL) - interval_in_seconds; + + query_delete_timepoint_in_str = pq_time_to_str(query_delete_timepoint); + if (malloc_failed(query_delete_timepoint_in_str)) + return -1; + + sql_len = + strlen(pool_config->system_db_schema) + + strlen(QUERY_CACHE_TABLE_NAME) + + strlen(query_delete_timepoint_in_str) + + 64; + + sql = (char *)malloc(sql_len); + if (malloc_failed(sql)) + { + free(query_delete_timepoint_in_str); + return -1; + } + + snprintf(sql, sql_len, + "DELETE FROM %s.%s WHERE create_time <= '%s'", + pool_config->system_db_schema, + QUERY_CACHE_TABLE_NAME, + query_delete_timepoint_in_str); + + pool_debug("pool_clear_cache: delete all query cache created before '%s'", query_delete_timepoint_in_str); + + pg_result = PQexec(system_db_info->pgconn, sql); + if (!pg_result || PQresultStatus(pg_result) != PGRES_COMMAND_OK) + { + pool_error("pool_clear_cache: PQexec() failed. reason: %s", + PQerrorMessage(system_db_info->pgconn)); + + PQclear(pg_result); + free(query_delete_timepoint_in_str); + free(sql); + return -1; + } + + PQclear(pg_result); + free(query_delete_timepoint_in_str); + free(sql); + + return 0; +} + +/* -------------------------------- + * pool_query_cache_table_exists - checks if query_cache table exists in the SystemDB + * + * This function is called once and only once from the pgpool parent process. + * return 1 if query_cache table exists, 0 otherwise. + * -------------------------------- + */ +int +pool_query_cache_table_exists(void) +{ + PGresult *pg_result = NULL; + char *sql = NULL; + int sql_len = strlen(pool_config->system_db_schema) + strlen(QUERY_CACHE_TABLE_NAME) + 64; + + if (! system_db_connection_exists()) + return 0; + + sql = (char *)malloc(sql_len); + if (malloc_failed(sql)) + return 0; + + snprintf(sql, sql_len, + "SELECT hash, query, value, dbname, create_time FROM %s.%s LIMIT 1", + pool_config->system_db_schema, + QUERY_CACHE_TABLE_NAME); + + pg_result = PQexec(system_db_info->pgconn, sql); + if (!pg_result || PQresultStatus(pg_result) != PGRES_TUPLES_OK) + { + pool_error("pool_query_cache_table_exists: PQexec() failed. reason: %s", + PQerrorMessage(system_db_info->pgconn)); + + PQclear(pg_result); + free(sql); + return 0; + } + + PQclear(pg_result); + pool_close_libpq_connection(); + free(sql); + + return 1; +} + +/* -------------------------------- + * pool_query_cache_lookup - retrieve query cache from the SystemDB + * + * creates a SQL query string for searching a cache from the SystemDB. + * + * returns POOL_CONTINUE if cache is found. returns POOL_END if cache was + * not found. returns POOL_ERROR if an error has been encountered while + * searching. + * + * Note that POOL_END and POOL_ERROR are treated the same by the caller + * (pool_process_query.c). + * POOL_END and POOL_ERROR both indicates to the caller that the search + * query must be forwarded to the backends in order to retrieve data and + * the result be cached. + * Only difference is that POOL_ERROR indicates that some fatal error has + * occured; query cache function, however, should be seemless to the user + * whether cache was not found or error has occured during cache retrieve. + * -------------------------------- + */ +POOL_STATUS +pool_query_cache_lookup(POOL_CONNECTION *frontend, char *query, char *database, char tstate) +{ + char *sql = NULL; + int sql_len; + char md5_query[33]; + struct timeval timeout; + int status; + + if (! system_db_connection_exists()) + return POOL_ERROR; /* same as POOL_END ... at least for now */ + + sql_len = + strlen(pool_config->system_db_schema) + + strlen(QUERY_CACHE_TABLE_NAME) + + sizeof(md5_query) + + strlen(database) + + 64; + sql = (char *)malloc(sql_len); + if (malloc_failed(sql)) + return POOL_ERROR; /* should I exit here rather than returning an error? */ + + /* cached data lookup */ + pool_md5_hash(query, strlen(query), md5_query); + snprintf(sql, sql_len, "SELECT value FROM %s.%s WHERE hash = '%s' AND dbname = '%s'", + pool_config->system_db_schema, + QUERY_CACHE_TABLE_NAME, + md5_query, + database); + + /* set timeout value for select */ + timeout.tv_sec = pool_config->child_life_time; + timeout.tv_usec = 0; + + pool_debug("pool_query_cache_lookup: searching cache for query: \"%s\"", query); + status = search_system_db_for_cache(frontend, sql, strlen(sql)+1, &timeout, tstate); + + /* make sure that the remaining data is discarded */ + SYSDB_CON->po = 0; + SYSDB_CON->len = 0; + + free(sql); + + /* cache found, and no backend communication needed */ + if (status == CACHE_FOUND) + { + return POOL_CONTINUE; + } + + /* cache not found */ + + if (status == CACHE_ERROR) + { + pool_error("pool_query_cache_lookup: query cache lookup failed"); + /* reset the SystemDB connection */ + if (system_db_info->pgconn) + pool_close_libpq_connection(); + return POOL_ERROR; /* same as POOL_END ... at least for now */ + } + + pool_debug("pool_query_cache_lookup: query cache not found"); + return POOL_END; +} + +/* -------------------------------- + * search_system_db_for_cache - search for query cache in libpq protocol level + * + * sends a cache searching query string using libpq protocol to the SystemDB. + * if the SystemDB returns cache, forward the data to the frontend, and return + * CACHE_FOUND. if cache was not found, silently discards the remaining data + * returned by the SystemDB, and return CACHE_NOT_FOUND. returns CACHE_ERROR + * if an error was encountered. + * -------------------------------- + */ +static CACHE_STATUS +search_system_db_for_cache(POOL_CONNECTION *frontend, char *sql, int sql_len, struct timeval *t, char tstate) +{ + fd_set readmask; + int fds; + int num_fds; + struct timeval *timeout = NULL; + char kind; + int readlen; + char *data = NULL; + CACHE_STATUS return_value = CACHE_ERROR; + int cache_found = 0; + + pool_debug("pool_query_cache_lookup: executing query: \"%s\"", sql); + + pool_write(SYSDB_CON, "Q", 1); + if (SYSDB_MAJOR == PROTO_MAJOR_V3) + { + int sendlen = htonl(sql_len + 4); + pool_write(SYSDB_CON, &sendlen, sizeof(sendlen)); + } + if (pool_write_and_flush(SYSDB_CON, sql, sql_len) < 0) + { + pool_error("pool_query_cache_lookup: error while sending data to the SystemDB"); + return CACHE_ERROR; + } + + if ((t->tv_sec + t->tv_usec) == 0) + timeout = NULL; + else + timeout = t; + + /* don't really need select() or for(;;) here, but we may need it someday... or not */ + for (;;) + { + FD_ZERO(&readmask); + num_fds = 0; + + num_fds = SYSDB_CON->fd + 1; + FD_SET(SYSDB_CON->fd, &readmask); + fds = select(num_fds, &readmask, NULL, NULL, timeout); + if (fds == -1) + { + if (errno == EINTR) + continue; + + pool_error("pool_query_cache_lookup: select() failed. reason: %s", strerror(errno)); + return CACHE_ERROR; + } + + /* select() timeout */ + if (fds == 0) + return CACHE_ERROR; + + for (;;) + { + if (! FD_ISSET(SYSDB_CON->fd, &readmask)) + { + pool_error("pool_query_cache_lookup: select() failed"); + return CACHE_ERROR; + } + + /* read kind */ + if (pool_read(SYSDB_CON, &kind, sizeof(kind)) < 0) + { + pool_error("pool_query_cache_lookup: error while reading message kind"); + return CACHE_ERROR; + } + pool_debug("pool_query_cache_lookup: received %c from systemdb", kind); + + /* just do the routine work of reading data in. data won't be used */ + if (kind == 'T') + { + if (SYSDB_MAJOR == PROTO_MAJOR_V3) + { + if (pool_read(SYSDB_CON, &readlen, sizeof(int)) < 0) + { + pool_error("pool_query_cache_lookup: error while reading message length"); + return CACHE_ERROR; + } + readlen = ntohl(readlen) - sizeof(int); + data = pool_read2(SYSDB_CON, readlen); + } + else + { + data = pool_read_string(SYSDB_CON, &readlen, 0); + } + } + else if (kind == 'D') /* cache found! forward it to the frontend */ + { + char *cache; + int status; + + cache_found = 1; + + if (SYSDB_MAJOR == PROTO_MAJOR_V3) + { + if (pool_read(SYSDB_CON, &readlen, sizeof(readlen)) < 0) + { + pool_error("pool_query_cache_lookup: error while reading message length"); + return CACHE_ERROR; + } + readlen = ntohl(readlen) - sizeof(int); + cache = pool_read2(SYSDB_CON, readlen); + } + else + { + cache = pool_read_string(SYSDB_CON, &readlen, 0); + } + + if (cache == NULL) + { + pool_error("pool_query_cache_lookup: error while reading message body"); + return CACHE_ERROR; + } + + cache[readlen] = '\0'; + + cache += sizeof(short); /* number of columns in 'D' (we know it's always going to be 1, so skip) */ + cache += sizeof(int); /* length of escaped bytea cache in string format. don't need the length */ + + status = ForwardCacheToFrontend(frontend, cache, tstate); + if (status < 0) + { + /* fatal error has occured while forwarding cache */ + pool_error("pool_query_cache_lookup: query cache forwarding failed"); + return_value = CACHE_ERROR; + } + } + else if (kind == 'C') /* see if 'D' was received */ + { + if (cache_found) + return_value = CACHE_FOUND; + else + return_value = CACHE_NOT_FOUND; + + /* must discard the remaining data */ + if (SYSDB_MAJOR == PROTO_MAJOR_V3) + { + if (pool_read(SYSDB_CON, &readlen, sizeof(int)) < 0) + { + pool_error("pool_query_cache_lookup: error while reading message length"); + return CACHE_ERROR; + } + readlen = ntohl(readlen) - sizeof(int); + data = pool_read2(SYSDB_CON, readlen); + } + else + { + data = pool_read_string(SYSDB_CON, &readlen, 0); + } + } + else if (kind == 'Z') + { + /* must discard the remaining data */ + if (SYSDB_MAJOR == PROTO_MAJOR_V3) + { + if (pool_read(SYSDB_CON, &readlen, sizeof(int)) < 0) + { + pool_error("pool_query_cache_lookup: error while reading message length"); + return CACHE_ERROR; + } + readlen = ntohl(readlen) - sizeof(int); + data = pool_read2(SYSDB_CON, readlen); + } + else + { + data = pool_read_string(SYSDB_CON, &readlen, 0); + } + + break; + } + else if (kind == 'E') + { + /* must discard the remaining data */ + if (SYSDB_MAJOR == PROTO_MAJOR_V3) + { + if (pool_read(SYSDB_CON, &readlen, sizeof(int)) < 0) + { + pool_error("pool_query_cache_lookup: error while reading message length"); + return CACHE_ERROR; + } + readlen = ntohl(readlen) - sizeof(int); + data = pool_read2(SYSDB_CON, readlen); + } + else + { + data = pool_read_string(SYSDB_CON, &readlen, 0); + } + + return_value = CACHE_ERROR; + } + else + { + /* shouldn't get here, but just in case */ + return CACHE_ERROR; + } + } + + break; + } + + return return_value; +} + +/* -------------------------------- + * ForwardCacheToFrontend - simply forwards cached data to the frontend + * + * since the cached data passed from the caller is in escaped binary string + * format, unescape it and send it to the frontend appending 'Z' at the end. + * returns 0 on success, -1 otherwise. + * -------------------------------- + */ +static int ForwardCacheToFrontend(POOL_CONNECTION *frontend, char *cache, char tstate) +{ + int sendlen; + size_t sz; + char *binary_cache = NULL; + + binary_cache = (char *)PQunescapeBytea((unsigned char *)cache, &sz); + sendlen = (int) sz; + if (malloc_failed(binary_cache)) + return -1; + + pool_debug("ForwardCacheToFrontend: query cache found (%d bytes)", sendlen); + + /* forward cache to the frontend */ + pool_write(frontend, binary_cache, sendlen); + + /* send ReadyForQuery to the frontend*/ + pool_write(frontend, "Z", 1); + sendlen = htonl(5); + pool_write(frontend, &sendlen, sizeof(int)); + if (pool_write_and_flush(frontend, &tstate, 1) < 0) + { + pool_error("pool_query_cache_lookup: error while writing data to the frontend"); + PQfreemem(binary_cache); + return -1; + } + + PQfreemem(binary_cache); + return 0; +} + +/* -------------------------------- + * pool_query_cache_register() - register query cache to the SystemDB + * + * returns 0 on sucess, -1 otherwise + * -------------------------------- + */ +int +pool_query_cache_register(char kind, + POOL_CONNECTION *frontend, + char *database, + char *data, + int data_len, + char *query) +{ + int ret; + int send_len; + + if (! system_db_connection_exists()) + return -1; + if (! CACHE_TABLE_INFO.has_prepared_statement) + define_prepared_statements(); + + switch (kind) + { + case 'T': /* RowDescription */ + { + /* for all SELECT result data from the backend, 'T' must come first */ + if (query_cache_info != NULL) + { + pool_error("pool_query_cache_register: received RowDescription in the wrong order"); + free_query_cache_info(); + return -1; + } + + pool_debug("pool_query_cache_register: saving cache for query: \"%s\"", query); + + /* initialize query_cache_info and save the query */ + ret = init_query_cache_info(frontend, database, query); + if (ret) + return ret; + + /* store data into the cache */ + write_cache(&kind, 1); + send_len = htonl(data_len + sizeof(int)); + write_cache(&send_len, sizeof(int)); + write_cache(data, data_len); + + break; + } + + case 'D': /* DataRow */ + { + /* for all SELECT result data from the backend, 'T' must come first */ + if (query_cache_info == NULL) + { + pool_error("pool_query_cache_register: received DataRow in the wrong order"); + return -1; + } + + write_cache(&kind, 1); + send_len = htonl(data_len + sizeof(int)); + write_cache(&send_len, sizeof(int)); + write_cache(data, data_len); + + break; + } + + case 'C': /* CommandComplete */ + { + PGresult *pg_result = NULL; + char *escaped_query = NULL; + size_t escaped_query_len; + time_t now = time(NULL); + char *values[5]; + int values_len[5]; + int values_format[5]; + int i; + + /* for all SELECT result data from the backend, 'T' must come first */ + if (query_cache_info == NULL) + { + pool_error("pool_query_cache_register: received CommandComplete in the wrong order"); + return -1; + } + + /* pack CommandComplete data into the cache */ + write_cache(&kind, 1); + send_len = htonl(data_len + sizeof(int)); + write_cache(&send_len, sizeof(int)); + write_cache(data, data_len); + + query_cache_info->create_time = pq_time_to_str(now); + if (malloc_failed(query_cache_info->create_time)) + { + free_query_cache_info(); + return -1; + } + + escaped_query = (char *)malloc(strlen(query_cache_info->query) * 2 + 1); + if (malloc_failed(escaped_query)) + { + free_query_cache_info(); + return -1; + } + +/* escaped_query_len = PQescapeStringConn(system_db_info->pgconn, */ +/* escaped_query, */ +/* query_cache_info->query, */ +/* strlen(query_cache_info->query))); */ + escaped_query_len = PQescapeString(escaped_query, query_cache_info->query, strlen(query_cache_info->query)); + + /* all the result data have been received. store into the SystemDB */ + values[0] = strdup(query_cache_info->md5_query); + values[1] = strdup(escaped_query); + values[2] = (char *)malloc(query_cache_info->cache_offset); + memcpy(values[2], query_cache_info->cache, query_cache_info->cache_offset); + values[3] = strdup(query_cache_info->db_name); + values[4] = strdup(query_cache_info->create_time); + for (i = 0; i < 5; i++) + { + if (malloc_failed(values[i])) + { + pool_error("pool_query_cache_register: malloc() failed"); + free_query_cache_info(); + { + int j; + for (j = 0; j < i; j++) + free(values[j]); + } + return -1; + } + + values_len[i] = strlen(values[i]); + } + values_format[0] = values_format[1] = values_format[3] = values_format[4] = 0; + values_format[2] = 1; + values_len[2] = query_cache_info->cache_offset; + + pg_result = PQexecPrepared(system_db_info->pgconn, + CACHE_TABLE_INFO.register_prepared_statement, + 5, + (const char * const *)values, + values_len, + values_format, + 0); + if (!pg_result || PQresultStatus(pg_result) != PGRES_COMMAND_OK) + { + pool_error("pool_query_cache_register: PQexecPrepared() failed. reason: %s", + PQerrorMessage(system_db_info->pgconn)); + + PQclear(pg_result); + PQfreemem(escaped_query); + free_query_cache_info(); + for (i = 0; i < 5; i++) + free(values[i]); + return -1; + } + + PQclear(pg_result); + PQfreemem(escaped_query); + for (i = 0; i < 5; i++) + free(values[i]); + free_query_cache_info(); + + break; + } + + case 'E': + { + pool_debug("pool_query_cache_register: received 'E': free query cache buffer"); + + pool_close_libpq_connection(); + free_query_cache_info(); + + break; + } + } + + return 0; +} + +/* -------------------------------- + * init_query_cache_info() - allocate memory for query_cache_info and stores query + * + * returns 0 on success, -1 otherwise +`* -------------------------------- + */ +static int +init_query_cache_info(POOL_CONNECTION *pc, char *database, char *query) +{ + int query_len; /* length of the SELECT query to be cached */ + + query_cache_info = (QueryCacheInfo *)malloc(sizeof(QueryCacheInfo)); + if (malloc_failed(query_cache_info)) + return -1; + + /* query */ + query_len = strlen(query); + query_cache_info->query = (char *)malloc(query_len + 1); + if (malloc_failed(query_cache_info->query)) + return -1; + memcpy(query_cache_info->query, query, query_len + 1); + + /* md5_query */ + query_cache_info->md5_query = (char *)malloc(33); /* md5sum is always 33 bytes (including the '\0') */ + if (malloc_failed(query_cache_info->md5_query)) + return -1; + pool_md5_hash(query_cache_info->query, query_len, query_cache_info->md5_query); + + /* malloc DEFAULT_CACHE_SIZE for query_cache_info->cache */ + query_cache_info->cache = (char *)malloc(DEFAULT_CACHE_SIZE); + if (malloc_failed(query_cache_info->cache)) + return -1; + query_cache_info->cache_size = DEFAULT_CACHE_SIZE; + query_cache_info->cache_offset = 0; + + /* save database name */ + query_cache_info->db_name = (char *)malloc(strlen(database)+1); + if (malloc_failed(query_cache_info->db_name)) + return -1; + strcpy(query_cache_info->db_name, database); + + return 0; +} + +/* -------------------------------- + * free_query_cache_info() - free query_cache_info and its members + * -------------------------------- + */ +static void +free_query_cache_info(void) +{ + if (query_cache_info == NULL) + return; + + free(query_cache_info->md5_query); + free(query_cache_info->query); + free(query_cache_info->cache); + free(query_cache_info->db_name); + free(query_cache_info->create_time); + free(query_cache_info); + query_cache_info = NULL; +} + +/* -------------------------------- + * malloc_failed() - checks if the caller's most recent malloc() has succeeded + * + * returns 0 if malloc() was a success, -1 otherwise +`* -------------------------------- + */ +static int +malloc_failed(void *p) +{ + if (p != NULL) + return 0; + + pool_error("pool_query_cache: malloc() failed"); + free_query_cache_info(); + + return -1; +} + +/* -------------------------------- + * write_cache() - append result data to buffer + * + * returns 0 on success, -1 otherwise + * -------------------------------- + */ +static int +write_cache(void *buf, int len) +{ + int required_len; + + if (len < 0) + return -1; + + required_len = query_cache_info->cache_offset + len; + if (required_len > query_cache_info->cache_size) + { + char *ptr; + + required_len = query_cache_info->cache_size * 2; + ptr = (char *)realloc(query_cache_info->cache, required_len); + if (malloc_failed(ptr)) + return -1; + + query_cache_info->cache = ptr; + query_cache_info->cache_size = required_len; + + pool_debug("pool_query_cache: extended cache buffer size to %d", query_cache_info->cache_size); + } + + memcpy(query_cache_info->cache + query_cache_info->cache_offset, buf, len); + query_cache_info->cache_offset += len; + + return 0; +} + +/* -------------------------------- + * pq_time_to_str() - convert time_t to ISO standard time output string + * + * returns a pointer to newly allocated string, NULL if malloc fails + * -------------------------------- + */ +static char * +pq_time_to_str(time_t t) +{ + char *time_p; + char iso_time[32]; + struct tm *tm; + + tm = localtime(&t); + strftime(iso_time, sizeof(iso_time), "%Y-%m-%d %H:%M:%S%z", tm); + + time_p = strdup(iso_time); + + return time_p; +} + + +/* -------------------------------- + * system_db_connection_exists() - checks and if a connection to the SystemDB exists + * + * if not connected, it makes an attempt to connect to the SystemDB. If a connection + * exists, returns 1, returns 0 otherwise. + * -------------------------------- + */ +static int +system_db_connection_exists(void) +{ + if (!system_db_info->pgconn || + (PQstatus(system_db_info->pgconn) != CONNECTION_OK)) + { + if (system_db_connect()) + return 0; + } + + return 1; +} + + +/* -------------------------------- + * define_prepared_statements() - defines prepared statements for the current session + * -------------------------------- + */ +static void +define_prepared_statements(void) +{ + PGresult *pg_result; + char *sql = NULL; + int sql_len; + + sql_len = + strlen(pool_config->system_db_schema) + + strlen(QUERY_CACHE_TABLE_NAME) + + 1024; + + sql = (char *)malloc(sql_len); + if (malloc_failed(sql)) + { + pool_error("pool_query_cache: malloc() failed"); + return; + } + + free(CACHE_TABLE_INFO.register_prepared_statement); + CACHE_TABLE_INFO.register_prepared_statement + = strdup(CACHE_REGISTER_PREPARED_STMT); + if (malloc_failed(CACHE_TABLE_INFO.register_prepared_statement)) + { + pool_error("pool_query_cache: malloc() failed"); + free(sql); + return; + } + +#ifdef HAVE_PQPREPARE + snprintf(sql, sql_len, + "INSERT INTO %s.%s VALUES ( $1, $2, $3, $4, $5 )", + pool_config->system_db_schema, + QUERY_CACHE_TABLE_NAME); + pg_result = PQprepare(system_db_info->pgconn, + CACHE_TABLE_INFO.register_prepared_statement, + sql, + 5, + NULL); +#else + snprintf(sql, sql_len, + "PREPARE %s (TEXT, TEXT, BYTEA, TEXT, TIMESTAMP WITH TIME ZONE) AS INSERT INTO %s.%s VALUES ( $1, $2, $3, $4, $5 )", + CACHE_TABLE_INFO.register_prepared_statement, + pool_config->system_db_schema, + QUERY_CACHE_TABLE_NAME); + pg_result = PQexec(system_db_info->pgconn, sql); +#endif + if (!pg_result || PQresultStatus(pg_result) != PGRES_COMMAND_OK) + { + pool_error("pool_query_cache: PQprepare() failed: %s", PQerrorMessage(system_db_info->pgconn)); + free(CACHE_TABLE_INFO.register_prepared_statement); + free(sql); + return; + } + + pool_debug("pool_query_cache: prepared statements created"); + CACHE_TABLE_INFO.has_prepared_statement = 1; + + free(sql); + PQclear(pg_result); +} diff --git a/pool_rewrite_outfuncs.c b/pool_rewrite_outfuncs.c new file mode 100644 index 0000000..4cb30f4 --- /dev/null +++ b/pool_rewrite_outfuncs.c @@ -0,0 +1,8928 @@ +/*------------------------------------------------------------------------- + * + * outfuncs.c + * Output functions for Postgres tree nodes. + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/dblink/nodes/outfuncs.c,v 1.261.2.1 2005/11/14 23:54:34 tgl Exp $ + * + * NOTES + * Every node type that can appear in stored rules' parsetrees *must* + * have an output function defined here (as well as an input function + * in readfuncs.c). For use in debugging, we also provide output + * functions for nodes that appear in raw parsetrees, path, and plan trees. + * These nodes however need not have input functions. + * + *------------------------------------------------------------------------- + */ +#include +#include + +#include "pool.h" +#include "parser/parser.h" +#include "parser/pool_string.h" +#include "parser/pg_list.h" +#include "parser/parsenodes.h" +#include "pool_rewrite_query.h" + +#define booltostr(x) ((x) ? "true" : "false") + + +extern void _outNode(String *str, void *obj); +static void _rewriteNode(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, void *obj); +static void _rewriteList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *node); +static void _rewriteIdList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *node); +static void _rewriteAlias(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Alias *node); +static void _rewriteRangeVar(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeVar *node); +static void _rewriteVar(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Var *node); +static void _rewriteConst(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Const *node); +static void _rewriteParam(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Param *node); +static void _rewriteAggref(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Aggref *node); +static void _rewriteArrayRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ArrayRef *node); +static void _rewriteFuncExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncExpr *node); +static void _rewriteOpExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, OpExpr *node); +static void _rewriteDistinctExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DistinctExpr *node); +static void _rewriteScalarArrayOpExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ScalarArrayOpExpr *node); +static void _rewriteBoolExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, BoolExpr *node); +static void _rewriteSubLink(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SubLink *node); +static void _rewriteSubPlan(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SubPlan *node); +static void _rewriteFieldSelect(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FieldSelect *node); +static void _rewriteFieldStore(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FieldStore *node); +static void _rewriteRelabelType(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RelabelType *node); +static void _rewriteConvertRowtypeExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ConvertRowtypeExpr *node); +static void _rewriteCaseExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CaseExpr *node); +static void _rewriteCaseWhen(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CaseWhen *node); +static void _rewriteCaseTestExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CaseTestExpr *node); +static void _rewriteArrayExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ArrayExpr *node); +static void _rewriteRowExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RowExpr *node); +static void _rewriteCoalesceExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CoalesceExpr *node); +static void _rewriteMinMaxExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, MinMaxExpr *node); +static void _rewriteNullIfExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, NullIfExpr *node); +static void _rewriteNullTest(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, NullTest *node); +static void _rewriteBooleanTest(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, BooleanTest *node); +static void _rewriteCoerceToDomain(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CoerceToDomain *node); +static void _rewriteCoerceToDomainValue(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CoerceToDomainValue *node); +static void _rewriteSetToDefault(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SetToDefault *node); +static void _rewriteTargetEntry(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TargetEntry *node); +static void _rewriteRangeTblRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeTblRef *node); +static void _rewriteJoinExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, JoinExpr *node); +static void _rewriteFromExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FromExpr *node); +static void _rewriteCreateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateStmt *node); +static void _rewriteIndexStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, IndexStmt *node); +static void _rewriteNotifyStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, NotifyStmt *node); +static void _rewriteDeclareCursorStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DeclareCursorStmt *node); +static void _rewriteSelectStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SelectStmt *node); +static void _rewriteFuncCall(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncCall *node); +static void _rewriteDefElem(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DefElem *node); +static void _rewriteLockingClause(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, LockingClause *node); +static void _rewriteColumnDef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ColumnDef *node); +static void _rewriteTypeName(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TypeName *node); +static void _rewriteTypeCast(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TypeCast *node); +static void _rewriteIndexElem(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, IndexElem *node); +static void _rewriteSortClause(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SortClause *node); +static void _rewriteGroupClause(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, GroupClause *node); +static void _rewriteSetOperationStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SetOperationStmt *node); +static void _rewriteAExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Expr *node); +static void _rewriteValue(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Value *value); +static void _rewriteColumnRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ColumnRef *node); +static void _rewriteParamRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ParamRef *node); +static void _rewriteAConst(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Const *node); +static void _rewriteA_Indices(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Indices *node); +static void _rewriteA_Indirection(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Indirection *node); +static void _rewriteResTarget(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ResTarget *node); +static void _rewriteConstraint(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Constraint *node); +static void _rewriteFkConstraint(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FkConstraint *node); + +static void _rewriteSortBy(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SortBy *node); +static void _rewriteInsertStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, InsertStmt *node); +static void _rewriteUpdateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, UpdateStmt *node); +static void _rewriteDeleteStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DeleteStmt *node); +static void _rewriteTransactionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TransactionStmt *node); +static void _rewriteTruncateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TruncateStmt *node); +static void _rewriteVacuumStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VacuumStmt *node); +static void _rewriteExplainStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ExplainStmt *node); +static void _rewriteClusterStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ClusterStmt *node); +static void _rewriteCheckPointStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CheckPointStmt *node); +static void _rewriteClosePortalStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ClosePortalStmt *node); +static void _rewriteListenStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ListenStmt *node); +static void _rewriteUnlistenStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, UnlistenStmt *node); +static void _rewriteLoadStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, LoadStmt *node); +static void _rewriteCopyStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CopyStmt *node); +static void _rewriteDeallocateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DeallocateStmt *node); +static void _rewriteRenameStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RenameStmt *node); +static void _rewriteCreateRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateRoleStmt *node); +static void _rewriteAlterRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterRoleStmt *node); +static void _rewriteDropRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropRoleStmt *node); +static void _rewriteCreateSchemaStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateSchemaStmt *node); +static void _rewriteVariableSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VariableSetStmt *node); +static void _rewriteVariableShowStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VariableShowStmt *node); +static void _rewriteConstraintsSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ConstraintsSetStmt *node); +static void _rewriteAlterTableStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterTableStmt *node); +static void _rewriteCreateSeqStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateSeqStmt *node); +static void _rewriteAlterSeqStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterSeqStmt *node); +static void _rewriteCreatePLangStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreatePLangStmt *node); +static void _rewriteDropPLangStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropPLangStmt *node); +static void _rewriteCreateTableSpaceStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateTableSpaceStmt *node); +static void _rewriteDropTableSpaceStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropTableSpaceStmt *node); +static void _rewriteCreateTrigStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateTrigStmt *node); +static void _rewriteDropPropertyStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropPropertyStmt *node); +static void _rewriteDefineStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DefineStmt *node); +static void _rewriteCreateOpClassStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateOpClassStmt *node); +static void _rewriteRemoveOpClassStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RemoveOpClassStmt *node); +static void _rewriteDropStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropStmt *node); +static void _rewriteFetchStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FetchStmt *node); +static void _rewriteGrantStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, GrantStmt *node); +static void _rewriteGrantRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, GrantRoleStmt *node); +static void _rewriteCreateFunctionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateFunctionStmt *node); +static void _rewriteAlterFunctionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterFunctionStmt *node); +static void _rewriteRemoveFuncStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RemoveFuncStmt *node); +static void _rewriteCreateCastStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateCastStmt *node); +static void _rewriteDropCastStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropCastStmt *node); +static void _rewriteReindexStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ReindexStmt *node); +static void _rewriteRuleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RuleStmt *node); +static void _rewriteViewStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ViewStmt *node); +static void _rewriteCreatedbStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreatedbStmt *node); +static void _rewriteAlterDatabaseStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterDatabaseStmt *node); +static void _rewriteAlterDatabaseSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterDatabaseSetStmt *node); +static void _rewriteDropdbStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropdbStmt *node); +static void _rewriteCreateDomainStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateDomainStmt *node); +static void _rewriteAlterDomainStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterDomainStmt *node); +static void _rewriteCreateConversionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateConversionStmt *node); +static void _rewritePrepareStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, PrepareStmt *node); +static void _rewriteExecuteStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ExecuteStmt *node); +static void _rewriteLockStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, LockStmt *node); +static void _rewriteCommentStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CommentStmt *node); + +static void _rewriteFuncName(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *func_name); +static void _rewriteSetRest(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VariableSetStmt *node); +static void _rewriteSetTransactionModeList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list); +static void _rewriteAlterTableCmd(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterTableCmd *node); +static void _rewriteOptSeqList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *options); +static void _rewritePrivGrantee(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, PrivGrantee *node); +static void _rewritePrivTarget(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, PrivTarget *node); +static void _rewriteFuncWithArgs(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncWithArgs *node); +static void _rewriteFunctionParameter(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FunctionParameter *node); +static void _rewritePrivilegeList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list); +static void _rewriteFuncOptList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list); +static void _rewriteCreatedbOptList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *options); +static void _rewriteOperatorArgTypes(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *args); +static void _rewriteRangeFunction(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeFunction *node); +static void _rewriteWithDefinition(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *def_list); + +/* analyze */ +static void KeepRewriteQueryCode(RewriteQuery *message, int current_select); +static void KeepMessages(RewriteQuery *message,int current_select,int part); +static int CheckWhereCaluse(Node *BaseSelect,RewriteQuery *message,ConInfoTodblink *dblink,String *str,int true_count); +static int _writewhereClause(A_Expr *expr,RewriteQuery *message,ConInfoTodblink *dblink, String *str,int true_count); +static char *escape_string(char *str); +static void delay_string_append_char(RewriteQuery *message,String *str, char *parts); +static void build_range_info(RewriteQuery *message,DistDefInfo *info,RepliDefInfo *info2,SelectDefInfo *info3,char *alias,int select_num,int i_num); +static void AnalyzeReturnRecord(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list); +static void build_virtual_table(RewriteQuery *message,void *obj, int next); +static char *search_type_from_virtual(VirtualTable *virtual,char *table,char *col); +static int _checkVirtualColumn(ColumnRef *col,RewriteQuery *message); +static void SeekColumnName(Aggexpr *agg,ColumnRef *node,int state); +/* rewirte */ +static void writeSelectHeader(RewriteQuery *message,ConInfoTodblink *dblink, String *str,int parallel,int state); +static void writeSelectFooter(RewriteQuery *message,String *str,AnalyzeSelect *analyze,int state); +static void KeepRewriteQueryReturnCode(RewriteQuery *message, int r_code); +static void writeRangeHeader(RewriteQuery *message,ConInfoTodblink *dblink, String *str,DistDefInfo *info, RepliDefInfo *info2,char *alias); +static void writeRangeFooter(RewriteQuery *message,ConInfoTodblink *dblink, String *str,DistDefInfo *info, RepliDefInfo *info2,char *alias); +static bool CheckAggOpt(RewriteQuery *message); +static char *GetNameFromColumnRef(ColumnRef *node,bool state); +static void AvgFuncCall(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncCall *node); + +/* under define is used in _rewritejoinExpr */ +#define JDEFAULT 0 +#define JNORMAL 1 +#define JNATURAL_INNER 2 +#define JNATURAL_LEFT 3 +#define JNATURAL_RIGHT 4 +#define JNATURAL_FULL 5 +#define JINNER 6 +#define JLEFT 7 +#define JRIGHT 8 +#define JFULL 9 +#define JUSING 10 + +#define LOADBALANCE false +#define PARALLEL true + +#define SELECT_START -1 +#define SELECT_FROMCLAUSE 0 +#define SELECT_TARGETLIST 1 +#define SELECT_WHERECLAUSE 2 +#define SELECT_GROUPBYCLAUSE 3 +#define SELECT_HAVINGCLAUSE 4 +#define SELECT_SORTCLAUSE 5 +#define SELECT_OFFSETCLAUSE 6 +#define SELECT_LIMITCLAUSE 7 +#define SELECT_OTHER 8 + +static char *escape_string(char *str) +{ + int len = strlen(str), i, j; + char *es = palloc0(len * 2 + 1); + + if (es == NULL) + { + return NULL; + } + + for (i = 0, j = 0; i < len; i++, j++) + { + if (str[i] == '\'') + { + es[j++] = '\''; + } + else if (str[i] == '\\') + { + es[j++] = '\\'; + } + es[j] = str[i]; + } + + return es; +} + +static void +delay_string_append_char(RewriteQuery *message,String *str, char *parts) +{ + if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == -1) + { + if(parts) + { + string_append_char( str, parts); +#ifdef DEBUG + pool_debug("debug Rewrite Query %s", str->data); +#endif + } + else + message->r_code = SELECT_RELATION_ERROR; + } +} + + +/* + * Is this column member of table (message->table_relname) ? + * return 1 -- member + * return 0 or -1 -- not mmeber + */ +static int +_checkVirtualColumn(ColumnRef *col,RewriteQuery *message) +{ + ListCell *c; + List *list; + VirtualTable *virtual = NULL; + AnalyzeSelect *analyze = NULL; + char first = 0; + char *tmp_table = NULL; + char *colname = NULL; + char *table = NULL; + int check_col = 0; + int no = message->current_select; + int v_colnum; + int i; + + list = col->fields; + analyze = message->analyze[no]; + + if(list->length > 2 || list->length == 0) + { + /* send error message */ + return -1; + } + + foreach (c, col->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + Value *v = (Value *) lfirst(c); + if(list->length == 2 && first == 0) + { + first = 1; + tmp_table = v->val.str; + } + else + colname = v->val.str; + } + } + + if(analyze->partstate[SELECT_FROMCLAUSE] == 'S') + { + if (message->table_relname) + { + if(tmp_table && strcmp(message->table_relname,tmp_table) != 0) + { + return check_col; + } + table = message->table_relname; + } + else + { + return check_col; + } + + virtual = analyze->virtual; + v_colnum = virtual->col_num; + + for(i = 0; i < v_colnum; i++) + { + if(!strcmp(virtual->table_list[i],table) && + !strcmp(virtual->col_list[i],colname)) + { + check_col = 1; + break; + } + } + } else { + virtual = analyze->virtual; + v_colnum = virtual->col_num; + + for(i = 0; i < v_colnum; i++) + { + if(tmp_table) + { + if(!strcmp(virtual->table_list[i],tmp_table) && + !strcmp(virtual->col_list[i],colname)) + { + check_col = 1; + break; + } + } + else + { + if(!strcmp(virtual->col_list[i],colname)) + { + check_col = 1; + break; + } + } + } + } + return check_col; +} + +static void KeepMessages(RewriteQuery *message,int current_select,int part) +{ + message->current_select = current_select; + message->part = part; +} + +static void KeepRewriteQueryCode(RewriteQuery *message, int current_select) +{ + message->current_select = current_select; +} + +static void KeepRewriteQueryReturnCode(RewriteQuery *message, int r_code) +{ + if((message->r_code != SELECT_RELATION_ERROR) + && (message->r_code != SELECT_PGCATALOG)) + message->r_code = r_code; +} + +/* + * A_Expr check + * if A_Expr-tree use subquery,function,or other table member + * rewrite expression as "TRUE" + * + * return value is counter of rewriting query. + */ +static int +_writewhereClause(A_Expr *expr,RewriteQuery *message,ConInfoTodblink *dblink, String *str,int true_count) +{ + int message_r_code = message->r_code; + + switch (expr->kind) + { + case AEXPR_OP: + if (list_length(expr->name) == 1) + { + KeepRewriteQueryReturnCode(message, SELECT_AEXPR); + _rewriteNode(NULL, message, dblink, str, expr->lexpr); + if(message->r_code == SELECT_AEXPR) + { + _rewriteNode(NULL, message, dblink, str, expr->rexpr); + if(message->r_code == SELECT_AEXPR) + { + Value *op = (Value *) lfirst(list_head(expr->name)); + KeepRewriteQueryReturnCode(message, message_r_code); + _rewriteNode(NULL, message, dblink, str, expr->lexpr); + delay_string_append_char(message, str, op->val.str); + _rewriteNode(NULL, message, dblink, str, expr->rexpr); + KeepRewriteQueryReturnCode(message, message_r_code); + } else { + KeepRewriteQueryReturnCode(message, message_r_code); + delay_string_append_char(message, str,"TRUE"); + true_count++; + break; + } + } else { + KeepRewriteQueryReturnCode(message, message_r_code); + delay_string_append_char(message, str,"TRUE"); + true_count++; + } + break; + } + else + { + delay_string_append_char(message, str,"TRUE"); + true_count++; + } + break; + + case AEXPR_AND: + delay_string_append_char(message, str, " ("); + true_count = true_count + CheckWhereCaluse(expr->lexpr,message,dblink,str,true_count); + delay_string_append_char(message, str, " AND "); + true_count = true_count + CheckWhereCaluse(expr->rexpr,message,dblink,str,true_count); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_OR: + delay_string_append_char(message, str, " ("); + true_count = true_count + CheckWhereCaluse(expr->lexpr,message,dblink,str,true_count); + delay_string_append_char(message, str, " OR "); + true_count = true_count + CheckWhereCaluse(expr->rexpr,message,dblink,str,true_count); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_OP_ANY: + /* not implemented yet */ + break; + + case AEXPR_OP_ALL: + /* not implemented yet */ + break; +#if 0 + + case AEXPR_NOT: + delay_string_append_char(message, str, " (NOT "); + CheckWhereCaluse(expr->rexpr,str,tablename,dbname, schemaname,aliasname); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_DISTINCT: + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, " IS DISTINCT FROM "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_NULLIF: + delay_string_append_char(message, str, " NULLIF("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, ", "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_OF: + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + if (*(char *)lfirst(list_head(node->name)) == '!') + delay_string_append_char(message, str, " IS NOT OF ("); + else + delay_string_append_char(message, str, " IS OF ("); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; +#endif + default: + delay_string_append_char(message, str,"TRUE"); + true_count++; + break; + } + return true_count; +} + +/* + * Start whereClasue check + * call _writewherelause(); + * + * if messgae->r_code is SELECT DEFAULT, + * write down whereClause + * else + * check whereClause + * + * return value is counter of rewriting query + * if return value is zero, all whereclause can insert dblink function. + */ +static int +CheckWhereCaluse(Node *BaseSelect,RewriteQuery *message,ConInfoTodblink *dblink,String *str,int true_count) +{ + A_Expr *expr = NULL; + + if(!IsA(BaseSelect, A_Expr)) + { + delay_string_append_char(message, str, "TRUE"); + true_count++; + return true_count; + } + + expr = (A_Expr *) BaseSelect; + + if(expr->kind == AEXPR_NOT) + { + delay_string_append_char(message, str, "TRUE"); + true_count++; + return true_count; + } + true_count = _writewhereClause(expr,message,dblink,str,true_count); + return true_count; +} + +static void _rewriteIdList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *node) +{ + ListCell *lc; + char first = 0; + + foreach(lc, node) + { + Value *v = lfirst(lc); + + if (first == 0) + first = 1; + else + delay_string_append_char(message, str, ", "); + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "\""); + } +} + +static void _rewriteList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *node) +{ + ListCell *lc; + char first = 0; + char state = (char)0; + int loop = 0; + bool from; + int current_select = message->current_select; + int next = -1; + bool lock = false; + AnalyzeSelect *analyze; + + analyze = message->analyze[current_select]; + + if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == -1 && + analyze->part == SELECT_TARGETLIST) + { + if(analyze->retlock == false) + { + lock = true; + analyze->retlock = true; + } + } + + foreach(lc, node) + { + next = message->analyze_num; + if (first == 0) + { + first = 1; + } + else + { + if(lfirst(lc) && !IsA(lfirst(lc),A_Indices)) + delay_string_append_char(message, str, ","); + } + + /* init JoinTable */ + if(message->r_code == SELECT_ANALYZE && message->fromClause) + { + if(lfirst(lc) && IsA(lfirst(lc),JoinExpr)) + { + if(!analyze->join) + { + analyze->join = (JoinTable *) palloc(sizeof(JoinTable)); + } + analyze->join->col_num = 0; + analyze->join->col_list = NULL; + analyze->join->type_list = NULL; + analyze->join->table_list = NULL; + analyze->join->using_list = NULL; + analyze->join->using_length = 0; + analyze->join->state = (char)0; + } + } + + from = message->fromClause; + _rewriteNode(BaseSelect, message, dblink, str, lfirst(lc)); + message->current_select = current_select; + message->fromClause = from; + + if(message->r_code == SELECT_ANALYZE && message->fromClause) + { + /* + if(lfirst(lc)) + { + if(IsA(lfirst(lc),JoinExpr)) + { + JoinExpr *join = lfirst(lc); + if (join->quals) + { + _rewriteNode(BaseSelect, message, dblink, str, join->quals); + } + } + } + */ + + if(loop == 0) + { + state = message->table_state; + } + else + { + if(state =='L' && message->table_state == 'L') + { + message->table_state = 'L'; + } + else if (state == 'L' && message->table_state == 'P') + { + message->table_state = 'P'; + } + else if (state == 'P' && message->table_state == 'L') + { + message->table_state = 'P'; + } + else + { + state = 'S'; + message->table_state = 'S'; + } + } + } + loop++; + + if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == -1 && + analyze->part == SELECT_TARGETLIST) + { + pool_debug("_rewriteList select=%d,count=%d", current_select,message->analyze[current_select]->ret_count); + if(lock) + message->analyze[current_select]->ret_count++; + } + } + + if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == -1 && + analyze->part == SELECT_TARGETLIST) + { + if(analyze->retlock && lock) + { + analyze->retlock = false; + } + } +} + + +/***************************************************************************** + * + * Stuff from primnodes.h. + * + *****************************************************************************/ + +static void +_rewriteAlias(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Alias *node) +{ + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, node->aliasname); + delay_string_append_char(message, str, " "); + + if (node->colnames) + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->colnames); + delay_string_append_char(message, str, ")"); + } +} + +static void +append_all_virtual(AnalyzeSelect *analyze,char *table) +{ + VirtualTable *virtual; + SelectDefInfo *select_ret; + int num; + int test_num; + int base; + int i; + int counter = 0; + + virtual = analyze->virtual; + test_num = virtual->col_num; + select_ret = analyze->select_ret; + base = select_ret->col_num; + + if(!table) + { + num = test_num; + } + else + { + num = 0; + for(i = 0; i< test_num; i++) + { + if(!strcmp(virtual->table_list[i],table)) + num++; + } + } + + if(base == 0) + { + select_ret->col_list = (char **) palloc(num * sizeof(char *)); + select_ret->type_list = (char **) palloc(num * sizeof(char *)); + select_ret->return_list = (int *) palloc(num * sizeof(int)); + } + else + { + select_ret->col_list = (char **) repalloc(select_ret->col_list,(base + num) * sizeof(char *)); + select_ret->type_list = (char **) repalloc(select_ret->type_list,(base + num) * sizeof(char *)); + select_ret->return_list = (int *) repalloc(select_ret->return_list,(base + num) * sizeof(int)); + } + + for(i = 0; i< test_num;i++) + { + if(table && strcmp(virtual->table_list[i],table)) + { + continue; + } + select_ret->col_list[base + counter] = virtual->col_list[i]; + select_ret->type_list[base + counter] = virtual->type_list[i]; + select_ret->return_list[base + counter] = -1; + pool_debug("append_all_virtual: analyze[%d] col=%s,type=%s", analyze->now_select, + select_ret->col_list[base + counter],select_ret->type_list[base + counter]); + counter++; + } + select_ret->col_num = base + num; +} + +static void +append_select_def_info(SelectDefInfo *select_ret,char *col,char *type) +{ + int base; + + base = select_ret->col_num; + pool_debug("append_select_def_info: base=%d",base); + + if(!type) + { + type = (char *)palloc(sizeof(char) * strlen("text") + 1); + strcpy(type,"text"); + } + + if(base == 0) + { + select_ret->col_list = (char **) palloc(sizeof(char *)); + select_ret->type_list = (char **) palloc(sizeof(char *)); + select_ret->return_list = (int *) palloc(sizeof(int)); + } + else + { + select_ret->col_list = (char **) repalloc(select_ret->col_list,(base + 1) * sizeof(char *)); + select_ret->type_list = (char **) repalloc(select_ret->type_list,(base + 1) * sizeof(char *)); + select_ret->return_list = (int *) repalloc(select_ret->return_list,(base + 1) * sizeof(int)); + } + + select_ret->col_list[base] = col; + select_ret->type_list[base] = type; + select_ret->return_list[base] = -1; + + select_ret->col_num++; + pool_debug("append_select_def_info: col=%s,type=%s base=%d", + select_ret->col_list[base],select_ret->type_list[base],select_ret->col_num); +} + +static char *search_type_from_virtual(VirtualTable *virtual,char *table,char *col) +{ + int num = virtual->col_num; + int i; + + for(i = 0; i < num; i++) + { + if(table) + { + if(!strcmp(virtual->table_list[i],table) + && !strcmp(virtual->col_list[i],col)) + return virtual->type_list[i]; + } + else + { + if(!strcmp(virtual->col_list[i],col)) + return virtual->type_list[i]; + } + } + return NULL; +} + + +static void +AnalyzeReturnRecord(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list) +{ + int select_num; + int range_num; + AnalyzeSelect *analyze; + RangeInfo **range; + VirtualTable *virtual; + ListCell *lc; + int n_sublink = 0; + int c_sublink = 0; + + select_num = message->current_select; + + analyze=message->analyze[select_num]; + + virtual = analyze->virtual; + + /* get range table info */ + range_num = analyze->rangeinfo_num; + + /* "range = 0" means that this select stmt have no table */ + range = analyze->range; + + analyze->select_ret = (SelectDefInfo *) palloc(sizeof(SelectDefInfo)); + + analyze->select_ret->valid = false; + analyze->select_ret->col_num = 0; + + pool_debug("AnalyzeReturnRecord: current_select=%d",select_num); + + foreach(lc, list) + { + ResTarget *target = NULL; + Node *n = lfirst(lc); + void *obj; + char *alias = NULL; + char *typecast = NULL; + char *colname = NULL; + char *table_name = NULL; + char *gettype = NULL; + + target = (ResTarget *) n; + + /* alias name */ + if(target->name) + alias = target->name; + + /* type name */ + if(IsA(target->val, TypeCast)) + { + TypeCast *type = (TypeCast *) target->val; + TypeName *typename = (TypeName *)type->typename; + obj = type->arg; + typecast = strVal(lfirst(list_head(typename->names))); + } else { + obj = target->val; + } + if(typecast && alias) + { + append_select_def_info(analyze->select_ret,alias,typecast); + continue; + } + + /* column name */ + if (obj && (IsA(obj, ColumnRef))) + { + int first = 0; + ListCell *c; + ColumnRef *col = NULL; + + col = (ColumnRef *) obj; + foreach (c, col->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + Value *v = (Value *) lfirst(c); + if(col->fields->length == 2 && first == 0) + { + first = 1; + table_name = v->val.str; + } + else + colname = v->val.str; + } + } + } + else if(obj && (IsA(obj, A_Expr))) + { + if(alias) + append_select_def_info(analyze->select_ret,alias,typecast); + else + { + char *colname; + colname = (char *)palloc(sizeof(char) * strlen("\"?column?\"") + 1); + strcpy(colname,"\"?column?\""); + append_select_def_info(analyze->select_ret,colname,typecast); + } + continue; + } + else if(obj && (IsA(obj, FuncCall))) + { + if(alias) + { + append_select_def_info(analyze->select_ret,alias,typecast); + } + else + { + FuncCall *func = NULL; + char *funcname; + func = (FuncCall *) obj; + funcname = strVal(lfirst(list_head(func->funcname))); + append_select_def_info(analyze->select_ret,funcname,typecast); + } + continue; + } + else if (obj && (IsA(obj,SubLink))) + { + int i; + int max = message->analyze_num; + AnalyzeSelect *sublink = NULL; + + for(i = select_num + 1; i < max;i++) + { + sublink = message->analyze[i]; + + if(sublink->last_select == select_num + && sublink->part == 1 && c_sublink == n_sublink) + break; + } + + n_sublink++; + if(sublink && (sublink->select_ret->col_num == 1)) + { + if(alias) + { + append_select_def_info(analyze->select_ret,alias,sublink->select_ret->type_list[0]); + continue; + } + else + { + char *column; + column = (char *)palloc(sizeof(char) * strlen("\"?column?\"") + 1); + strcpy(column,"\"?column?\""); + append_select_def_info(analyze->select_ret,column,sublink->select_ret->type_list[0]); + continue; + } + } + } + else if(obj && (IsA(obj,A_Const))) + { + A_Const *cst = (A_Const *) obj; + char *column = NULL; + + if(!typecast && cst->typename) + { + Value *v = linitial(cst->typename->names); + typecast = v->val.str; + } + + if(!alias) + { + column = (char *)palloc(sizeof(char) * strlen("\"?column?\"") + 1); + strcpy(column,"\"?column?\""); + alias = column; + } + + append_select_def_info(analyze->select_ret,alias,typecast); + continue; + } + + if(colname && !strcmp(colname,"*")) + { + append_all_virtual(analyze,table_name); + continue; + } + + if(colname) + gettype = search_type_from_virtual(virtual,table_name,colname); + else + { + char *column = NULL; + column = (char *)palloc(sizeof(char) * strlen("\"?column?\"") + 1); + strcpy(column,"\"?column?\""); + append_select_def_info(analyze->select_ret,column,NULL); + continue; + } + + if(gettype) + { + char *t_n; + char *t_t; + + if(alias) + t_n = alias; + else + t_n = colname; + + if(typecast) + t_t = typecast; + else + t_t = gettype; + append_select_def_info(analyze->select_ret,t_n,t_t); + } + } +} + +static void +append_virtual_table(RewriteQuery *message,VirtualTable *virtual,char **col_list,char **type_list,int col_num,char *table_name,char state,int next) +{ + int base; + int i; + + if(virtual->col_num == 0) + { + base = 0; + virtual->col_list = (char**) palloc(sizeof(char*) * col_num); + virtual->type_list = (char**) palloc(sizeof(char*) * col_num); + virtual->table_list = (char**) palloc(sizeof(char*) * col_num); + virtual->state_list = (char*) palloc(sizeof(char) * col_num); + virtual->column_no = (int*) palloc(sizeof(int) * col_num); + virtual->valid = (int*) palloc(sizeof(int) * col_num); + } + else + { + base = virtual->col_num; + virtual->col_list = (char**) repalloc(virtual->col_list,sizeof(char*) * (base + col_num)); + virtual->type_list = (char**) repalloc(virtual->type_list,sizeof(char*) * (base + col_num)); + virtual->table_list = (char**) repalloc(virtual->table_list,sizeof(char*)* (base + col_num)); + virtual->state_list = (char*) repalloc(virtual->state_list,sizeof(char) * (base + col_num)); + virtual->column_no = (int*) repalloc(virtual->column_no,sizeof(int) * (base + col_num)); + virtual->valid = (int*) repalloc(virtual->valid,sizeof(int) * (base + col_num)); + } + + for(i = 0; i< col_num; i++) + { + int j = base + i; + + virtual->col_list[j] = col_list[i]; + virtual->type_list[j] = type_list[i]; + virtual->table_list[j] = table_name; + virtual->state_list[j] = state; + + /* (next > 0) means this function call from RangeSubselect */ + if(next > 0) + { + AnalyzeSelect *analyze = message->analyze[next]; + SelectDefInfo *select_ret; + select_ret = analyze->select_ret; + select_ret->return_list[i] = message->column; + pool_debug("append_virtual_table return_list[%d]=%d,analyze[%d]",i,message->column,next); + } + virtual->column_no[j] = message->column; + message->column++; + virtual->valid[j] = -1; + pool_debug("append_virtual_table select=%d, no=%d,col=%s,type=%s,table=%s,state=%c,valid=%d", + message->current_select, + virtual->column_no[j],virtual->col_list[j],virtual->type_list[j] + ,virtual->table_list[j],virtual->state_list[j],virtual->valid[j]); + } + virtual->col_num = base + col_num; +} + + +static void append_join_using(AnalyzeSelect *analyze,char **col_list,char **type_list,int col_num,char *table_name) +{ + int num,i,j,k; + int same[analyze->join->col_num]; + int lvalid[analyze->join->col_num]; + int rvalid[col_num]; + char **using; + int lc = 0; + int rc = 0; + int sc = 0; + int total; + JoinTable *join = analyze->join; + JoinTable *new = (JoinTable *) palloc(sizeof(JoinTable)); + + using = join->using_list; + num = join->using_length; + + for(i = 0; i < join->col_num; i++) + { + char *colname = join->col_list[i]; + for(j = 0; j < num; j++) + { + if(!strcmp(colname, using[j])) + { + same[sc] = i; + sc++; + } else { + lvalid[lc] = i; + lc++; + } + } + } + + + for(i = 0; i < col_num; i++) + { + char *colname = col_list[i]; + for(j = 0; j < num; j++) + { + if(strcmp(colname, using[j])) + { + rvalid[rc] = i; + rc++; + } + } + } + + total= sc + lc + rc; + new->col_num = total; + new->col_list = (char**) palloc(sizeof(char*) * (total)); + new->type_list = (char**) palloc(sizeof(char*) * (total)); + new->table_list = (char**) palloc(sizeof(char*) * (total)); + + for(k = 0; k < sc; k++) + { + new->col_list[k] = join->col_list[same[k]]; + new->type_list[k] = join->type_list[same[k]]; + new->table_list[k] = join->table_list[same[k]]; + } + + for(k = sc; k < sc + lc; k++) + { + new->col_list[k] = join->col_list[lvalid[k - sc]]; + new->type_list[k] = join->type_list[lvalid[k - sc]]; + new->table_list[k] = join->table_list[lvalid[k - sc]]; + } + for(k = sc + lc; k < sc + lc + rc; k++) + { + new->col_list[k] = col_list[rvalid[k - lc - sc]]; + new->type_list[k] = type_list[rvalid[k - lc - sc]]; + if(table_name) + { + new->table_list[k] = table_name; + } + else + new->table_list[k] = NULL; + } + + analyze->join = new; + + for(i = 0; i< analyze->join->col_num; i++) + { + pool_debug("append_join_using no = %d ,col=%s,type=%s,table=%s", + i,new->col_list[i],new->type_list[i],new->table_list[i]); + } +} + +static void append_join_natural(AnalyzeSelect *analyze,char **col_list,char **type_list,int base,int col_num,char *table_name) +{ + int same[base + 1]; + int rvalid[base + 1]; + int linvalid[col_num + 1]; + int lvalid[col_num +1]; + int i,j,k; + int sc = 0; + int vc = 0; + int ic = 0; + int total = 0; + int count; + JoinTable *join = analyze->join; + JoinTable *new = (JoinTable *) palloc(sizeof(JoinTable)); + + for(i = 0; i < base; i++) + { + char *colname = join->col_list[i]; + int match = 0; + int array = -1; + for(j = 0; j < col_num; j++) + { + if(!strcmp(colname, col_list[j])) + { + match++; + array = j; + } + } + + if(match == 0) + { + rvalid[vc] = i; + vc++; + } + else if(match == 1) + { + same[sc] = i; + linvalid[ic] = array; + sc++; + ic++; + } + else + { + /* XXX */ + } + } + + total=sc + vc + (col_num - ic); + new->col_num = total; + new->col_list = (char**) palloc(sizeof(char*) * (total)); + new->type_list = (char**) palloc(sizeof(char*) * (total)); + new->table_list = (char**) palloc(sizeof(char*) * (total)); + + for(k = 0; k < sc; k++) + { + new->col_list[k] = join->col_list[same[k]]; + new->type_list[k] = join->type_list[same[k]]; + if(table_name) + { + new->table_list[k] = table_name; + } + else + new->table_list[k] = join->table_list[same[k]]; + } + + for(k = sc; k < sc + vc; k++) + { + new->col_list[k] = join->col_list[rvalid[k - sc]]; + new->type_list[k] = join->type_list[rvalid[k - sc]]; + if(table_name) + { + new->table_list[k] = table_name; + } + else + new->table_list[k] = join->table_list[rvalid[k - sc]]; + } + + count = 0; + for(k = 0; k col_list[k] = col_list[lvalid[k - sc - vc]]; + new->type_list[k] = type_list[lvalid[k - sc - vc]]; + if(table_name) + { + new->table_list[k] = table_name; + } + else + new->table_list[k] = NULL; + } + analyze->join = new; + + for(i = 0; i< analyze->join->col_num; i++) + { + pool_debug("append_join_natural no = %d ,col=%s,type=%s,table=%s", + i,new->col_list[i],new->type_list[i],new->table_list[i]); + } +} + +static void append_join_simple(JoinTable *join,char **col_list,char **type_list,int col_num,char *table_name) +{ + int base; + int i; + pool_debug("append_join_table start"); + + if(join->col_num == 0) + { + base = 0; + join->col_list = (char**) palloc(sizeof(char*) * col_num); + join->type_list = (char**) palloc(sizeof(char*) * col_num); + join->table_list = (char**) palloc(sizeof(char*) * col_num); + } + else + { + base = join->col_num; + join->col_list = (char**) repalloc(join->col_list,sizeof(char*) * (base + col_num)); + join->type_list = (char**) repalloc(join->type_list,sizeof(char*) * (base + col_num)); + join->table_list = (char**) repalloc(join->table_list,sizeof(char*) * (base + col_num)); + } + + for(i = 0; i< col_num; i++) + { + join->col_list[base + i] = col_list[i]; + join->type_list[base + i] = type_list[i]; + join->table_list[base + i] = table_name; + pool_debug("append_join_table no = %d ,col=%s,type=%s,table=%s", + base + i,join->col_list[base + i],join->type_list[base + i],join->table_list[base + i]); + } + join->col_num = base + col_num; +} + +static void build_join_table(RewriteQuery *message,char *alias, int type) +{ + char *table_name = NULL; + char state; + char lstate; + int left_num,right_num,range_num,select_num; + DistDefInfo *distinfo = NULL; + RepliDefInfo *repliinfo = NULL; + SelectDefInfo *selectinfo = NULL; + JoinTable *join; + RangeInfo *range; + AnalyzeSelect *analyze; + + select_num = message->current_select; + analyze=message->analyze[select_num]; + join = analyze->join; + left_num = join->col_num; + range_num = analyze->rangeinfo_num; + range = analyze->range[range_num - 1]; + state = range->state; + lstate = join->state; + right_num = 0; + + distinfo = range->distinfo; + repliinfo = range->repliinfo; + selectinfo = range->selectinfo; + + if(alias) + table_name = alias; + else if(!alias && range->alias) + table_name = range->alias; + + if(distinfo && !repliinfo && !selectinfo) + { + right_num = distinfo->col_num; + if(!table_name) + table_name = distinfo->table_name; + pool_debug("inside build_join_info dist state=%c %s",range->state,table_name); + + if(type == JNATURAL_INNER || type == JNATURAL_RIGHT + || type == JNATURAL_LEFT || type == JNATURAL_FULL) + append_join_natural(analyze,distinfo->col_list,distinfo->type_list,join->col_num,distinfo->col_num,table_name); + else + append_join_simple(join,distinfo->col_list,distinfo->type_list,distinfo->col_num,table_name); + } + else if (repliinfo && !distinfo && !selectinfo) + { + right_num = repliinfo->col_num; + if(!table_name) + table_name = repliinfo->table_name; + + pool_debug("inside build_join_info repli state=%c %s",range->state,table_name); + + if(type == JNATURAL_INNER || type == JNATURAL_RIGHT + || type == JNATURAL_LEFT || type == JNATURAL_FULL) + append_join_natural(analyze,repliinfo->col_list,repliinfo->type_list,join->col_num,repliinfo->col_num,table_name); + else if(join->using_length != 0) + append_join_using(analyze,repliinfo->col_list,repliinfo->type_list,repliinfo->col_num,table_name); + else + append_join_simple(join,repliinfo->col_list,repliinfo->type_list,repliinfo->col_num,table_name); + } + else if (selectinfo && !repliinfo && !distinfo) + { + pool_debug("inside build_join_info select state=%c %s",range->state,table_name); + right_num = selectinfo->col_num; + + if(type == JNATURAL_INNER || type == JNATURAL_RIGHT + || type == JNATURAL_LEFT || type == JNATURAL_FULL) + append_join_natural(analyze,selectinfo->col_list,selectinfo->type_list,join->col_num,selectinfo->col_num,table_name); + else if(join->using_length != 0) + append_join_using(analyze,selectinfo->col_list,selectinfo->type_list,selectinfo->col_num,table_name); + else + append_join_simple(join,selectinfo->col_list,selectinfo->type_list,selectinfo->col_num,table_name); + } + + if(type == JDEFAULT) + { + join->state = state; + return; + } + + join =analyze->join; + + if(lstate =='E' || state == 'E') + { + join->state = 'E'; + return; + } + if(lstate =='L' && state =='L') + { + join->state = 'L'; + return; + } + if(lstate =='L' && state =='P') + { + int total = left_num + right_num; + if(type == JRIGHT || type == JNORMAL || type == JINNER || type == JNATURAL_INNER) + join->state = 'P'; + else if((join->col_num <= total) && (type == JNATURAL_RIGHT)) + join->state = 'P'; + else if((join->col_num == total) && (type == JNATURAL_LEFT)) + join->state = 'P'; + else + join->state = 'S'; + } + else if(lstate =='P' && state == 'L') + { + int total = left_num + right_num; + if(type == JLEFT || type == JNORMAL || type == JINNER || type == JNATURAL_INNER) + join->state ='P'; + else if((join->col_num <= total) && (type == JNATURAL_LEFT)) + join->state = 'P'; + else if((join->col_num == total) && (type == JNATURAL_RIGHT)) + join->state = 'P'; + else + join->state ='S'; + } + else + join->state = 'S'; +} + +static void change_analyze_state(AnalyzeSelect *analyze,char state) +{ + if(state == 'E' || analyze->state == 'E') + return; + + if(!analyze->state) + { + analyze->state = state; + } + else if(analyze->state == 'P' && state =='L') + { + analyze->state = 'P'; + } + else if(analyze->state == 'L' && state =='P') + { + analyze->state = 'P'; + } + else if(analyze->state == 'L' && state =='L') + { + return; + } + else + analyze->state = 'S'; +} + +static void build_virtual_table(RewriteQuery *message,void *obj,int next) +{ + int select_num; + int range_num; + char *alias = NULL; + char *table_name = NULL; + char state; + AnalyzeSelect *analyze; + VirtualTable *virtual; + RangeInfo *range; + DistDefInfo *distinfo; + RepliDefInfo *repliinfo; + SelectDefInfo *selectinfo; + + select_num = message->current_select; + analyze=message->analyze[select_num]; + virtual = analyze->virtual; + + /* last range */ + range_num = analyze->rangeinfo_num; + range = analyze->range[range_num - 1]; + distinfo = range->distinfo; + repliinfo = range->repliinfo; + selectinfo = range->selectinfo; + + if(range->alias) + alias = range->alias; + + state = range->state; + + if(distinfo && !repliinfo && !selectinfo) + { + if(alias) + table_name =alias; + else + table_name = distinfo->table_name; + + pool_debug("inside build_virtual_info dist state=%c %s",range->state,table_name); + append_virtual_table(message,virtual,distinfo->col_list,distinfo->type_list,distinfo->col_num,table_name,state,-2); + change_analyze_state(analyze,state); + return; + } + else if (repliinfo && !distinfo && !selectinfo) + { + if(alias) + table_name =alias; + else + table_name = repliinfo->table_name; + pool_debug("inside build_virtual_info repli state=%c %s",range->state,table_name); + append_virtual_table(message,virtual,repliinfo->col_list,repliinfo->type_list,repliinfo->col_num,table_name,state,-3); + change_analyze_state(analyze,state); + return; + } + else if (selectinfo && !repliinfo && !distinfo) + { + table_name = alias; + pool_debug("inside build_virtual_info select state=%c %s",range->state,table_name); + append_virtual_table(message,virtual,selectinfo->col_list,selectinfo->type_list,selectinfo->col_num,table_name,state,next); + change_analyze_state(analyze,state); + return; + } + else if (!selectinfo && !repliinfo && !distinfo) + { + pool_debug("inside build_virtual_info no dist state=%c %s",range->state,alias); + change_analyze_state(analyze,'E'); + } +} + +static void +build_range_info(RewriteQuery *message,DistDefInfo *info,RepliDefInfo *info2,SelectDefInfo *info3,char *alias, int select_num,int i_num) +{ + int num; + AnalyzeSelect *analyze; + + analyze=message->analyze[select_num]; + + if(analyze->range) + { + ++analyze->rangeinfo_num; + num = analyze->rangeinfo_num; + analyze->range = + (RangeInfo **) repalloc(analyze->range,sizeof(RangeInfo *) * num); + + analyze->range[num-1] = (RangeInfo *) palloc(sizeof(RangeInfo)); + pool_debug("inside build_range_info num= %d current_select=%d",num,select_num); + } + else + { + num = 1; + analyze->range = (RangeInfo **) palloc(sizeof(RangeInfo *)); + analyze->range[0] = (RangeInfo *) palloc(sizeof(RangeInfo)); + analyze->rangeinfo_num = 1; + pool_debug("inside build_range_info num= %d current_select=%d",num,select_num); + } + + analyze->range[num -1]->ret_num = num - 1; + analyze->range[num -1]->selectinfo = NULL; + /* set dist_def_info */ + if(info && !info2 && !info3) + { + message->is_loadbalance = false; + analyze->range[num -1]->distinfo = info; + analyze->range[num -1]->repliinfo = NULL; + analyze->select_ret = NULL; + analyze->range[num -1]->alias = alias; + analyze->range[num -1]->state = 'P'; + pool_debug("inside build_range_info dist %d",select_num); + } + + /* set repli_def_info */ + if(info2 && !info && !info3) + { + analyze->range[num -1]->distinfo = NULL; + analyze->range[num -1]->repliinfo = info2; + analyze->select_ret = NULL; + analyze->range[num -1]->alias = alias; + analyze->range[num -1]->state = 'L'; + pool_debug("inside build_range_info repli %d",select_num); + return; + } + + /* CALL FROM _rertiteRangeSubselect */ + if(info3 && !info && !info2) + { + char state = (char)0; + analyze->range[num -1]->distinfo = NULL; + analyze->range[num -1]->repliinfo = NULL; + analyze->range[num -1]->selectinfo = info3; + analyze->range[num -1]->alias = alias; + state = message->analyze[i_num]->state; + analyze->range[num -1]->state = state; + pool_debug("inside build_range_info select %d, state = %c (%c)",select_num,state,analyze->state); + return; + } + + if(info && info2) + { + /*TODO: error*/ + analyze->select_ret = NULL; + pool_debug("inside build_range_info error %d",select_num); + return; + } + + if(!info && !info2 && !info3) + { + /*TODO: error*/ + message->is_loadbalance = true; + analyze->range[num -1]->distinfo = NULL; + analyze->range[num -1]->repliinfo = NULL; + analyze->range[num -1]->state = 'E'; + analyze->select_ret = NULL; + analyze->range[num -1]->alias = alias; + pool_debug("inside build_range_info const or func %d",select_num); + } +} + +static void +_rewriteRangeVar(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeVar *node) +{ + DistDefInfo *info = NULL; + RepliDefInfo *info2 = NULL; + + if(message->r_code == SELECT_ANALYZE) + { + info = pool_get_dist_def_info(dblink->dbname, node->schemaname, node->relname); + info2 = pool_get_repli_def_info(dblink->dbname, node->schemaname, node->relname); + } + + if(!(message->r_code == SELECT_DEFAULT && message->rewritelock == -1 && message->ignore_rewrite == -1)) + { + if (node->catalogname) + { + delay_string_append_char(message, str, node->catalogname); + delay_string_append_char(message, str, "."); + } + + if (node->schemaname) + { + delay_string_append_char(message, str, node->schemaname); + delay_string_append_char(message, str, "."); + + if(strcmp(node->schemaname,"pg_catalog") == 0) + { + message->is_pg_catalog = true; + } + } + + delay_string_append_char(message, str, node->relname); + + if (node->alias) + { + Alias *alias = node->alias; + _rewriteNode(BaseSelect, message, dblink, str, node->alias); + if(message->r_code == SELECT_ANALYZE) + build_range_info(message,info,info2,NULL,alias->aliasname,message->current_select,-1); + } + else + { + if(message->r_code == SELECT_ANALYZE) + build_range_info(message,info,info2,NULL,node->relname,message->current_select,-1); + } + + if (node->inhOpt == INH_YES) + { + delay_string_append_char(message, str, " * "); + } + + } + else + { + /* rewrite query using dblink connection */ + char *alias_name = NULL; + SelectStmt *select = (SelectStmt *)BaseSelect; + + if(node->alias) + { + alias_name = node->alias->aliasname; + } + /* + * iff schemaname is pg_catalog, send query to + * one node not system db. + */ + if(node->schemaname && + (strcmp(node->schemaname,"pg_catalog") == 0)) + { + message->is_pg_catalog =true; + return; + } + + info = pool_get_dist_def_info(dblink->dbname, node->schemaname, node->relname); + info2 = pool_get_repli_def_info(dblink->dbname, node->schemaname, node->relname); + + writeRangeHeader(message,dblink,str,info,info2,alias_name); + + if (node->catalogname) + { + delay_string_append_char(message, str, node->catalogname); + delay_string_append_char(message, str, "."); + } + + if (node->schemaname) + { + delay_string_append_char(message, str, node->schemaname); + delay_string_append_char(message, str, "."); + message->schemaname = node->schemaname; + + if(strcmp(node->schemaname,"pg_catalog") == 0) + { + message->is_pg_catalog = true; + } + + } + else + message->schemaname = NULL; + + delay_string_append_char(message, str, node->relname); + + if (alias_name) + { + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, alias_name); + } + + if(select->whereClause && + !(message->r_code == SELECT_PGCATALOG)) + { + char * temp = NULL; + int message_code = message->r_code; + delay_string_append_char(message, str, " WHERE "); + + if(message->table_relname) + temp = message->table_relname; + + if(alias_name) + message->table_relname = alias_name; + else + message->table_relname = node->relname; + + message->rewritelock = message->current_select; + CheckWhereCaluse(select->whereClause, message,dblink,str,0); + message->rewritelock = -1; + message->table_relname = temp; + KeepRewriteQueryReturnCode(message, message_code); + } + + writeRangeFooter(message,dblink,str,info,info2,alias_name); + + if (node->inhOpt == INH_YES) + { + delay_string_append_char(message, str, " * "); + } + } + + /*2009/07/27*/ + if(message->r_code == SELECT_ANALYZE && message->fromClause) + { + int next = message->analyze_num; + build_virtual_table(message,node,next); + } +} + +static void +_rewriteVar(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Var *node) +{ + +} + +static void +_rewriteConst(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Const *node) +{ + +} + +static void +_rewriteParam(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Param *node) +{ + +} + +static void +_rewriteAggref(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Aggref *node) +{ + +} + +static void +_rewriteArrayRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ArrayRef *node) +{ + +} + +static void +_rewriteFuncExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncExpr *node) +{ + +} + +static void +_rewriteOpExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, OpExpr *node) +{ + +} + +static void +_rewriteDistinctExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DistinctExpr *node) +{ + +} + +static void +_rewriteScalarArrayOpExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ScalarArrayOpExpr *node) +{ + +} + +static void +_rewriteBoolExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, BoolExpr *node) +{ + +} + +static void +_rewriteSubLink(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SubLink *node) +{ + if(message->r_code == SELECT_AEXPR) + { + KeepRewriteQueryReturnCode(message, SELECT_AEXPR_FALSE); + return; + } + _rewriteNode(BaseSelect, message, dblink, str, node->testexpr); + + if (node->operName != NIL) + { + Value *v = linitial(node->operName); + if (strcmp(v->val.str, "=") == 0) + delay_string_append_char(message, str, " IN "); + else + { + delay_string_append_char(message, str, v->val.str); + } + } + + switch (node->subLinkType) + { + case EXISTS_SUBLINK: + delay_string_append_char(message, str, " EXISTS "); + break; + + case ARRAY_SUBLINK: + delay_string_append_char(message, str, " ARRAY "); + break; + + case ANY_SUBLINK: + if (node->operName != NIL) + { + Value *v = linitial(node->operName); + if (strcmp(v->val.str, "=") != 0) + { + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, " ANY "); + } + } + break; + + case ALL_SUBLINK: + delay_string_append_char(message, str, " ALL "); + break; + + default: + break; + } + + if (node->subselect) + { + int count = message->current_select; + int part = message->part; + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->subselect); + delay_string_append_char(message, str, ")"); + KeepMessages(message,count,part); + } +} + +static void +_rewriteSubPlan(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SubPlan *node) +{ + +} + +static void +_rewriteFieldSelect(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FieldSelect *node) +{ + +} + +static void +_rewriteFieldStore(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FieldStore *node) +{ + +} + +static void +_rewriteRelabelType(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RelabelType *node) +{ + +} + +static void +_rewriteConvertRowtypeExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ConvertRowtypeExpr *node) +{ + +} + +static void +_rewriteCaseExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CaseExpr *node) +{ + ListCell *lc; + + delay_string_append_char(message, str, "CASE "); + if (node->arg) + _rewriteNode(BaseSelect, message, dblink, str, node->arg); + + foreach (lc, node->args) + { + _rewriteNode(BaseSelect, message, dblink, str, lfirst(lc)); + } + + if (node->defresult) + { + delay_string_append_char(message, str, " ELSE "); + _rewriteNode(BaseSelect, message, dblink, str, node->defresult); + } + + delay_string_append_char(message, str, " END"); +} + +static void +_rewriteCaseWhen(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CaseWhen *node) +{ + delay_string_append_char(message, str, " WHEN "); + _rewriteNode(BaseSelect, message, dblink, str, node->expr); + delay_string_append_char(message, str, " THEN "); + _rewriteNode(BaseSelect, message, dblink, str, node->result); +} + +static void +_rewriteCaseTestExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CaseTestExpr *node) +{ + +} + +static void +_rewriteArrayExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ArrayExpr *node) +{ + delay_string_append_char(message, str, "["); + _rewriteNode(BaseSelect, message, dblink, str, node->elements); + delay_string_append_char(message, str, "]"); +} + +static void +_rewriteRowExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RowExpr *node) +{ + if (node->args == NIL) + delay_string_append_char(message, str, "ROW ()"); + else + { + delay_string_append_char(message, str, "ROW ("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); + } +} + +static void +_rewriteCoalesceExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CoalesceExpr *node) +{ + delay_string_append_char(message, str, "COALESCE ("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); +} + +static void +_rewriteMinMaxExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, MinMaxExpr *node) +{ + if (node->op == IS_GREATEST) + { + delay_string_append_char(message, str, "GREATEST ("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); + } + else if (node->op == IS_LEAST) + { + delay_string_append_char(message, str, "LEAST ("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); + } +} + +static void +_rewriteNullIfExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, NullIfExpr *node) +{ + +} + +static void +_rewriteNullTest(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, NullTest *node) +{ + _rewriteNode(BaseSelect, message, dblink, str, node->arg); + if (node->nulltesttype == IS_NOT_NULL) + delay_string_append_char(message, str, " IS NOT NULL"); + else + delay_string_append_char(message, str, " IS NULL"); +} + +static void +_rewriteBooleanTest(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, BooleanTest *node) +{ + _rewriteNode(BaseSelect, message, dblink, str, node->arg); + + switch (node->booltesttype) + { + case IS_TRUE: + delay_string_append_char(message, str, " IS TRUE"); + break; + + case IS_NOT_TRUE: + delay_string_append_char(message, str, " IS NOT TRUE"); + break; + + case IS_FALSE: + delay_string_append_char(message, str, " IS FALSE"); + break; + + case IS_NOT_FALSE: + delay_string_append_char(message, str, " IS NOT FALSE"); + break; + + case IS_UNKNOWN: + delay_string_append_char(message, str, " IS UNKNOWN"); + break; + + case IS_NOT_UNKNOWN: + delay_string_append_char(message, str, " IS NOT UNKNOWN"); + break; + } +} + +static void +_rewriteCoerceToDomain(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CoerceToDomain *node) +{ + +} + +static void +_rewriteCoerceToDomainValue(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CoerceToDomainValue *node) +{ + +} + +static void +_rewriteSetToDefault(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SetToDefault *node) +{ + delay_string_append_char(message, str, "DEFAULT"); +} + +static void +_rewriteTargetEntry(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TargetEntry *node) +{ + +} + +static void +_rewriteRangeTblRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeTblRef *node) +{ + +} + +static char *GetTableName(Node *node) +{ + + if(IsA(node, RangeVar)) + { + RangeVar *range = (RangeVar *)node; + if(range->alias) + { + Alias *alias = range->alias; + return alias->aliasname; + } else { + return range->relname; + } + } + else if (IsA(node,RangeSubselect)) + { + RangeSubselect *select = (RangeSubselect *)node; + Alias * alias = select->alias; + return alias->aliasname; + } + return NULL; +} + +static int RetVirtualColumn(VirtualTable *virtual, char *tablename, char *colname) +{ + int col_num = virtual->col_num; + int i; + for( i = 0; i < col_num; i++) + { + if(strcmp(virtual->col_list[i], colname) == 0 + && strcmp(virtual->table_list[i], tablename) == 0) + { + return virtual->column_no[i]; + } + } + + /* ERROR OR AMBIGIUS */ + return -1; +} + +static void +ConvertFromUsingToON(RewriteQuery *message, String *str, JoinExpr *node, int select_num) +{ + char *lname; + char *rname; + char comma = 0; + ListCell *lc; + VirtualTable *virtual = message->analyze[select_num]->virtual; + + lname = GetTableName(node->larg); + rname = GetTableName(node->rarg); + + delay_string_append_char(message, str, " ON"); + foreach (lc, node->using) + { + Value *value; + char lbuf[16]; + char rbuf[16]; + + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, " AND "); + + value = lfirst(lc); + snprintf(lbuf, 16, "%d",RetVirtualColumn(virtual,lname,value->val.str)); + snprintf(rbuf, 16, "%d",RetVirtualColumn(virtual,rname,value->val.str)); + delay_string_append_char(message, str, " \"pool_c$"); + delay_string_append_char(message, str, lbuf); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, " = "); + delay_string_append_char(message, str, "\"pool_c$"); + delay_string_append_char(message, str, rbuf); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, " "); + } +} + +static void +_rewriteJoinExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, JoinExpr *node) +{ + char l_state,r_state; + bool from; + int select_num; + bool natural = false; + bool inner = false; + bool cross = false; + bool full = false; + bool left = false; + bool right = false; + char *aliasname; + int using_length = 0; + char **using_list; + + Alias *alias = node->alias; + if(alias) + aliasname = alias->aliasname; + else + aliasname = NULL; + + from = message->fromClause; + select_num = message->current_select; + + _rewriteNode(BaseSelect, message, dblink, str, node->larg); + + /* reset message */ + message->fromClause = from; + message->current_select = select_num; + l_state = message->table_state; + + if(message->r_code == SELECT_ANALYZE && + (IsA(node->larg, RangeVar) || IsA(node->larg,RangeSubselect))) + { + build_join_table(message,aliasname,JDEFAULT); + } + + + if (node->isNatural == TRUE) + { + natural = true; + delay_string_append_char(message, str, " NATURAL"); + } + + if (node->jointype == JOIN_INNER) + { + if (node->using == NIL && node->quals == NULL && !node->isNatural) + { + cross = true; + delay_string_append_char(message, str, " CROSS JOIN "); + } + else + { + delay_string_append_char(message, str, " JOIN "); + inner = true; + } + + } + else if (node->jointype == JOIN_LEFT) + { + delay_string_append_char(message, str, " LEFT OUTER JOIN "); + left = true; + } + else if (node->jointype == JOIN_FULL) + { + delay_string_append_char(message, str, " FULL OUTER JOIN "); + full = true; + } + else if (node->jointype == JOIN_RIGHT) + { + delay_string_append_char(message, str, " RIGHT OUTER JOIN "); + right = true; + } + + _rewriteNode(BaseSelect, message, dblink, str, node->rarg); + + r_state = message->table_state; + message->fromClause = from; + message->current_select = select_num; + + if(message->r_code == SELECT_ANALYZE) + { + if(cross && (IsA(node->rarg, RangeVar) || IsA(node->rarg,RangeSubselect))) + build_join_table(message,aliasname,JNORMAL); + + if(IsA(node->rarg, RangeVar) || IsA(node->rarg,RangeSubselect)) + { + if(natural && inner) + build_join_table(message,aliasname,JNATURAL_INNER); + else if(natural && left) + build_join_table(message,aliasname,JNATURAL_LEFT); + else if(natural && right) + build_join_table(message,aliasname,JNATURAL_RIGHT); + else if(natural && full) + build_join_table(message,aliasname,JFULL); + } + } + + if (node->using != NIL && IsA(node->using, List)) + { + ListCell *lc; + char comma = 0; + int count = 0; + + using_length= list_length(node->using); + using_list = (char **) palloc(sizeof(char *) * using_length); + + if(message->r_code == SELECT_DEFAULT && message->rewritelock == -1 + && message->analyze[select_num]->state == 'S') + { + /* Rewrite Using Cluase to On Clause */ + ConvertFromUsingToON(message, str, node, select_num); + } else { + delay_string_append_char(message, str, " USING("); + + foreach (lc, node->using) + { + Value *value; + + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ","); + + value = lfirst(lc); + delay_string_append_char(message, str, value->val.str); + using_list[count] = value->val.str; + count++; + } + + message->analyze[select_num]->join->using_length = using_length; + message->analyze[select_num]->join->using_list = using_list; + + delay_string_append_char(message, str, ")"); + } + } + + if(message->r_code == SELECT_ANALYZE) + { + if(IsA(node->rarg, RangeVar) || IsA(node->rarg,RangeSubselect)) + { + if(!natural && inner){ + build_join_table(message,aliasname,JINNER); + } + else if(!natural && left) + build_join_table(message,aliasname,JLEFT); + else if(!natural && right) + build_join_table(message,aliasname,JRIGHT); + else if(!natural && full) + build_join_table(message,aliasname,JFULL); + } + message->analyze[select_num]->state = message->analyze[select_num]->join->state; + } + + if (node->quals) + { + int on_select = message->analyze_num - 1; + + delay_string_append_char(message, str, " ON "); + _rewriteNode(BaseSelect, message, dblink, str, node->quals); + + /* This condition means that the sub select is in ON CLAUSE*/ + if(on_select < message->analyze_num -1) + { + int count = message->analyze_num - 1 - on_select; + char joinstate = message->analyze[select_num]->state; + + if(joinstate == 'S') + return; + else + { + int i; + for(i= on_select + 1; i < count + on_select + 1;i++) + { + char onstate = message->analyze[i]->state; + if (onstate == 'S' || onstate == 'P') + { + message->analyze[select_num]->state = 'S'; + pool_debug("_rewriteJoinExpr: Change Join state from %c to %c",joinstate, + message->analyze[select_num]->state); + + return; + } + } + } + } + } +} + +static void +_rewriteFromExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FromExpr *node) +{ +} + +/***************************************************************************** + * + * Stuff from parsenodes.h. + * + *****************************************************************************/ + +static void +_rewriteCreateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + if (node->relation->istemp) + delay_string_append_char(message, str, "TEMP "); + delay_string_append_char(message, str, "TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->tableElts); + delay_string_append_char(message, str, ") "); + + if (node->inhRelations != NIL) + { + delay_string_append_char(message, str, "INHERITS ("); + _rewriteNode(BaseSelect, message, dblink, str, node->inhRelations); + delay_string_append_char(message, str, ")"); + } + + if (node->options) + _rewriteWithDefinition(BaseSelect, message, dblink, str, node->options); + + switch (node->oncommit) + { + case ONCOMMIT_DROP: + delay_string_append_char(message, str, " ON COMMIT DROP"); + break; + + case ONCOMMIT_DELETE_ROWS: + delay_string_append_char(message, str, " ON COMMIT DELETE ROWS"); + + case ONCOMMIT_PRESERVE_ROWS: + delay_string_append_char(message, str, " ON COMMIT PRESERVE ROWS"); + break; + + default: + break; + } + + if (node->tablespacename) + { + delay_string_append_char(message, str, " TABLESPACE \""); + delay_string_append_char(message, str, node->tablespacename); + delay_string_append_char(message, str, "\""); + } +} + +static void +_rewriteIndexStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, IndexStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + + if (node->unique == TRUE) + delay_string_append_char(message, str, "UNIQUE "); + + if (node->concurrent == true) + delay_string_append_char(message, str, "INDEX CONCURRENTLY \""); + else + delay_string_append_char(message, str, "INDEX \""); + delay_string_append_char(message, str, node->idxname); + delay_string_append_char(message, str, "\" ON "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (strcmp(node->accessMethod, DEFAULT_INDEX_TYPE)) + { + delay_string_append_char(message, str, " USING "); + delay_string_append_char(message, str, node->accessMethod); + } + + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->indexParams); + delay_string_append_char(message, str, ")"); + + if (node->tableSpace) + { + delay_string_append_char(message, str, " TABLESPACE \""); + delay_string_append_char(message, str, node->tableSpace); + delay_string_append_char(message, str, "\""); + } + + if (node->whereClause) + { + delay_string_append_char(message, str, " WHERE "); + _rewriteNode(BaseSelect, message, dblink, str, node->whereClause); + } +} + +static void +_rewriteNotifyStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, NotifyStmt *node) +{ + delay_string_append_char(message, str, "NOTIFY "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); +} + +static void +_rewriteDeclareCursorStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DeclareCursorStmt *node) +{ + delay_string_append_char(message, str, "DECLARE \""); + delay_string_append_char(message, str, node->portalname); + delay_string_append_char(message, str, "\" "); + + if (node->options & CURSOR_OPT_SCROLL) + delay_string_append_char(message, str, "SCROLL "); + if (node->options & CURSOR_OPT_BINARY) + delay_string_append_char(message, str, "BINARY "); + if (node->options & CURSOR_OPT_INSENSITIVE) + delay_string_append_char(message, str, "INSENSITIVE "); + + delay_string_append_char(message, str, "CURSOR "); + + if (node->options & CURSOR_OPT_HOLD) + delay_string_append_char(message, str, "WITH HOLD "); + + delay_string_append_char(message, str, "FOR"); + _rewriteNode(BaseSelect, message, dblink, str, node->query); +} + +static void +initSelectStmt(RewriteQuery *message,SelectStmt *node) +{ + int count; + int last; + int i; + AnalyzeSelect *analyze; + + if(message->r_code != SELECT_ANALYZE && message->r_code != SELECT_DEFAULT) + return; + + count = message->analyze_num++; + last = message->current_select; + message->current_select = count; + + if(message->r_code == SELECT_ANALYZE) + { + if(count == 0) + { + message->analyze = (AnalyzeSelect **) palloc(sizeof(AnalyzeSelect *)); + message->analyze[count]=(AnalyzeSelect *) palloc(sizeof(AnalyzeSelect)); + message->part = SELECT_START; + + analyze = message->analyze[count]; + analyze->now_select = 0; + analyze->last_select = -1; + analyze->part = SELECT_START; + analyze->call_part = SELECT_START; + } + else + { + message->analyze = (AnalyzeSelect **) repalloc(message->analyze,sizeof(AnalyzeSelect *) * (count+1)); + message->analyze[count]=(AnalyzeSelect *) palloc(sizeof(AnalyzeSelect)); + analyze = message->analyze[count]; + analyze->now_select = count; + analyze->last_select = last; + analyze->part = message->part; + analyze->call_part = message->analyze[last]->part; + } + + analyze->range =NULL; + analyze->rangeinfo_num =-1; + analyze->virtual = NULL; + analyze->join = NULL; + analyze->state = (char) 0; + analyze->aggregate = false; + analyze->aggexpr = NULL; + analyze->table_name = NULL; + analyze->select_range = false; + analyze->rarg_count = -1; + analyze->larg_count = -1; + analyze->ret_count = 0; + analyze->retlock = false; + + for(i = 0; i< 8; i++) + analyze->partstate[i] = (char)0; + + if(node->larg && node->rarg) + analyze->select_union = true; + else + analyze->select_union = false; + + pool_debug("initSelectStmt: ANALYZE now(%d)",message->current_select); + + /* set default table_state */ + /* S means that tuples was create by systemdb */ + /* L means that tuples was create by one node */ + /* P means that tuples was create by parallel node */ + message->table_state = 'S'; + } +} + +static void writeRangeHeader(RewriteQuery *message,ConInfoTodblink *dblink, String *str,DistDefInfo *info, RepliDefInfo *info2,char *alias) +{ + char port[8]; + char *schema = NULL; + char *table = NULL; + + + pool_debug("writeRangeHeader select_no=%d",message->current_select); + + sprintf(port,"%d",dblink->port); + + delay_string_append_char(message, str, "dblink("); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, "host="); + delay_string_append_char(message, str, dblink->hostaddr); + delay_string_append_char(message, str, " dbname="); + delay_string_append_char(message, str, dblink->dbname); + delay_string_append_char(message, str, " port="); + delay_string_append_char(message, str, port); + delay_string_append_char(message, str, " user="); + delay_string_append_char(message, str, dblink->user); + + if(strlen(dblink->password)) + { + delay_string_append_char(message, str, " password="); + delay_string_append_char(message, str, dblink->password); + } + + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, "'"); + + if(info && !info2) + { + delay_string_append_char(message, str, "SELECT pool_parallel(\""); + schema = info->schema_name; + if(alias) + table = alias; + else + table = info->table_name; + } + else if (!info && info2) + { + delay_string_append_char(message, str, "SELECT pool_loadbalance(\""); + schema = info2->schema_name; + if(alias) + table = alias; + else + table = info2->table_name; + } + + { + VirtualTable *virtual = NULL; + int no = message->current_select; + int v_colnum; + int i; + int first = 0; + + AnalyzeSelect *analyze = message->analyze[no]; + virtual = analyze->virtual; + v_colnum = virtual->col_num; + + delay_string_append_char(message, str, "SELECT "); + + for(i = 0; i < v_colnum; i++) + { + if(!strcmp(virtual->table_list[i],table) && virtual->valid[i] != -1) + { + + if(first == 0) + { + delay_string_append_char(message, str, virtual->table_list[i]); + delay_string_append_char(message, str, "."); + delay_string_append_char(message, str, virtual->col_list[i]); + first = 1; + } + else + { + delay_string_append_char(message, str, ", "); + delay_string_append_char(message, str, virtual->table_list[i]); + delay_string_append_char(message, str, "."); + delay_string_append_char(message, str, virtual->col_list[i]); + } + } + } + + if(first == 0) + delay_string_append_char(message, str, " * "); + + delay_string_append_char(message, str, " FROM "); + } +} + +static void writeRangeFooter(RewriteQuery *message,ConInfoTodblink *dblink, String *str,DistDefInfo *info, RepliDefInfo *info2,char *alias) +{ + int i,num; + char *schema = NULL; + char *table = NULL; + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, ")"); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, ",false)"); + + delay_string_append_char(message, str," AS "); + + if(alias) + table = alias; + else + { + if(info && !info2) + { + schema = info->schema_name; + table = info->table_name; + } + else if (!info && info2) + { + schema = info2->schema_name; + table = info2->table_name; + } + } + + /* send one node */ + if(!table) + { + message->r_code = SELECT_RELATION_ERROR; + } + + delay_string_append_char(message, str, table); + delay_string_append_char(message, str, "("); + + { + VirtualTable *virtual = NULL; + int first = 0; + int no = message->current_select; + AnalyzeSelect *analyze = message->analyze[no]; + virtual = analyze->virtual; + num = virtual->col_num; + + for(i = 0; i < num; i++) + { + char buf[16]; + if(!strcmp(virtual->table_list[i],table) && virtual->valid[i] != -1) + { + + if(first == 0) + first = 1; + else + delay_string_append_char(message, str, ","); + + snprintf(buf, 16, "%d", analyze->virtual->column_no[i]); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str,virtual->type_list[i]); + } + } + + if(first == 0) + { + for(i = 0; i < num; i++) + { + char buf[16]; + if(!strcmp(virtual->table_list[i],table)) + { + if(first == 0) + first = 1; + else + delay_string_append_char(message, str, ","); + + snprintf(buf, 16, "%d", analyze->virtual->column_no[i]); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str,"\""); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str,virtual->type_list[i]); + } + } + } + delay_string_append_char(message, str, ")"); + } +} + +static void writeSelectAggHeader(RewriteQuery *message,ConInfoTodblink *dblink, String *str,int state) +{ + char port[8]; + int count = message->current_select; + AnalyzeSelect *analyze; + Aggexpr *agg; + int i; + int ret_count = 0; + + analyze = message->analyze[count]; + agg = analyze->aggexpr; + + ret_count = agg->t_num + agg->c_num + agg->h_num; + + sprintf(port,"%d",dblink->port); + pool_debug("writeSelectAggHeader select_no=%d state=%d",message->current_select,state); + + delay_string_append_char(message, str, "dblink("); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, "host="); + delay_string_append_char(message, str, dblink->hostaddr); + delay_string_append_char(message, str, " dbname="); + delay_string_append_char(message, str, dblink->dbname); + delay_string_append_char(message, str, " port="); + delay_string_append_char(message, str, port); + delay_string_append_char(message, str, " user="); + delay_string_append_char(message, str, dblink->user); + + if(strlen(dblink->password)) + { + delay_string_append_char(message, str, " password="); + delay_string_append_char(message, str, dblink->password); + } + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, "SELECT pool_parallel(\""); + delay_string_append_char(message, str, "SELECT "); + + message->rewritelock = count; + + for(i = 0; i< agg->t_num; i++) + { + char *funcname = NULL; + funcname = strVal(lfirst(list_head(agg->tfunc_p[i]->funcname))); + if(strcmp(funcname,"avg")) + { + _rewriteFuncCall(NULL,message,NULL,str,agg->tfunc_p[i]); + } + else + { + AvgFuncCall(NULL,message,NULL,str,agg->tfunc_p[i]); + } + ret_count--; + if(ret_count != 0) + delay_string_append_char(message, str, ","); + } + + for(i = 0; i< agg->c_num; i++) + { + _rewriteColumnRef(NULL,message,NULL,str,agg->col_p[i]); + ret_count--; + if(ret_count != 0) + delay_string_append_char(message, str, ","); + } + + for(i = 0; i< agg->h_num; i++) + { + char *funcname = NULL; + funcname = strVal(lfirst(list_head(agg->hfunc_p[i]->funcname))); + if(strcmp(funcname,"avg")) + { + _rewriteFuncCall(NULL,message,NULL,str,agg->hfunc_p[i]); + } + else + { + AvgFuncCall(NULL,message,NULL,str,agg->hfunc_p[i]); + } + ret_count--; + if(ret_count != 0) + delay_string_append_char(message, str, ","); + } + delay_string_append_char(message, str, " FROM "); +} + +static void writeSelectHeader(RewriteQuery *message,ConInfoTodblink *dblink, String *str,int parallel,int state) +{ + char port[8]; + + sprintf(port,"%d",dblink->port); + pool_debug("writeSelectHeader select_no=%d state=%d",message->current_select,state); + + if(state == SELECT_START) + { + delay_string_append_char(message, str, "SELECT * FROM "); + } + + delay_string_append_char(message, str, "dblink("); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, "host="); + delay_string_append_char(message, str, dblink->hostaddr); + delay_string_append_char(message, str, " dbname="); + delay_string_append_char(message, str, dblink->dbname); + delay_string_append_char(message, str, " port="); + delay_string_append_char(message, str, port); + delay_string_append_char(message, str, " user="); + delay_string_append_char(message, str, dblink->user); + + if(strlen(dblink->password)) + { + delay_string_append_char(message, str, " password="); + delay_string_append_char(message, str, dblink->password); + } + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, "'"); + if(parallel) + delay_string_append_char(message, str, "SELECT pool_parallel(\""); + else + delay_string_append_char(message, str, "SELECT pool_loadbalance(\""); + + if(state == SELECT_FROMCLAUSE) + { + int no = message->current_select; + int v_colnum; + int i; + int first = 0; + + AnalyzeSelect *analyze = message->analyze[no]; + + v_colnum = analyze->virtual->col_num; + + delay_string_append_char(message, str, "SELECT "); + + for(i = 0; i < v_colnum; i++) + { + if(analyze->virtual->valid[i] != -1) + { + char *col_name = analyze->virtual->col_list[i]; + + if(first == 0) + { + //delay_string_append_char(message, str, analyze->virtual->table_list[i]); + //delay_string_append_char(message, str, "ooo."); + if(strcmp(col_name,"\"?column?\"")) + delay_string_append_char(message, str, col_name); + else + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, col_name); + delay_string_append_char(message, str, "\""); + } + first = 1; + } + else + { + delay_string_append_char(message, str, ", "); + delay_string_append_char(message, str, analyze->virtual->table_list[i]); + delay_string_append_char(message, str, "."); + if(strcmp(col_name,"\"?column?\"")) + delay_string_append_char(message, str, col_name); + else + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, col_name); + delay_string_append_char(message, str, "\""); + } + } + } + } + + if(first == 0) + delay_string_append_char(message, str, " * "); + + delay_string_append_char(message, str, " FROM "); + } +} + +static char *estimateFuncTypes(AnalyzeSelect *analyze,FuncCall *func) +{ + char *funcname = NULL; + void *obj; + char *type; + obj = lfirst(list_head(func->args)); + + funcname = strVal(lfirst(list_head(func->funcname))); + + if(!strcmp(funcname,"max") || !strcmp(funcname,"min")) + { + if (obj && (IsA(obj, ColumnRef))) + { + char *table_name = NULL; + char *column_name = NULL; + VirtualTable *virtual = analyze->virtual; + + column_name = GetNameFromColumnRef((ColumnRef *) obj,true); + table_name = GetNameFromColumnRef((ColumnRef *) obj ,false); + type = search_type_from_virtual(virtual,table_name,column_name); + return type; + } + else if( obj && (IsA(obj,TypeCast))) + { + TypeCast *typecast = (TypeCast *) obj; + TypeName *typename = (TypeName *)typecast->typename; + type = strVal(lfirst(list_head(typename->names))); + return type; + } + else + { + char *numeric = "numeric"; + type = (char *) palloc(sizeof(char) * strlen(numeric) +1); + strcpy(type,numeric); + return type; + } + } + else if(!strcmp(funcname,"sum")) + { + char *numeric = "numeric"; + type = (char *) palloc(sizeof(char) * strlen(numeric) +1); + strcpy(type,numeric); + return type; + } + + return "numeric"; +} + +static void writeSelectAggFooter(RewriteQuery *message,String *str,AnalyzeSelect *analyze) +{ + int count = message->current_select; + Aggexpr *agg; + int i; + int ret_count = 0; + int group_count = 0; + + analyze = message->analyze[count]; + agg = analyze->aggexpr; + + ret_count = agg->t_num + agg->c_num + agg->h_num; + + group_count = agg->c_num; + + if(group_count != 0) + { + delay_string_append_char(message, str, " GROUP BY "); + + for(i = 0; i< agg->c_num; i++) + { + _rewriteColumnRef(NULL,message,NULL,str,agg->col_p[i]); + group_count--; + if(group_count != 0) + delay_string_append_char(message, str, ","); + } + } + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, ")"); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, ",false)"); + + delay_string_append_char(message, str," AS "); + delay_string_append_char(message, str, analyze->table_name); + + /* symbol of aggregate opt */ + delay_string_append_char(message, str,"g"); + delay_string_append_char(message, str, " ("); + + message->rewritelock = -1; + + for(i = 0; i < ret_count; i++) + { + char buf[16]; + snprintf(buf, 16, "%d", i); + delay_string_append_char(message, str, "pool_g$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + + if(i < agg->t_num) + { + char *funcname = NULL; + funcname = strVal(lfirst(list_head(agg->tfunc_p[i]->funcname))); + if(!strcmp(funcname,"count")) + delay_string_append_char(message, str, "bigint "); + else if(!strcmp(funcname,"avg")) + { + delay_string_append_char(message, str, "numeric "); + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, "pool_g$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, "c"); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, "bigint "); + } + else + { + char *type = estimateFuncTypes(analyze,agg->tfunc_p[i]); + delay_string_append_char(message, str, type); + } + } + else if(i >= agg->t_num && i < agg->t_num + agg->c_num) + { + char *table_name = NULL; + char *column_name = NULL; + char *type = NULL; + VirtualTable *virtual = analyze->virtual; + + column_name = GetNameFromColumnRef(agg->col_p[i - agg->t_num],true); + table_name = GetNameFromColumnRef(agg->col_p[i - agg->t_num],false); + type = search_type_from_virtual(virtual,table_name,column_name); + delay_string_append_char(message, str, type); + } + else if(i >= agg->t_num + agg->c_num) + { + char *funcname = NULL; + int arg = i - agg->t_num - agg->c_num; + funcname = strVal(lfirst(list_head(agg->hfunc_p[arg]->funcname))); + if(!strcmp(funcname,"count")) + delay_string_append_char(message, str, "bigint "); + else if(!strcmp(funcname,"avg")) + { + delay_string_append_char(message, str, "numeric "); + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, "pool_g$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, "c"); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, "bigint "); + } + else + { + char *type = estimateFuncTypes(analyze,agg->hfunc_p[arg]); + delay_string_append_char(message, str, type); + } + } + + if( i + 1 != ret_count) + delay_string_append_char(message, str, ","); + } + delay_string_append_char(message, str, ") "); +} + +static void writeSelectFooter(RewriteQuery *message,String *str,AnalyzeSelect *analyze,int state) +{ + int i,num; + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, ")"); + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, ",false)"); + + delay_string_append_char(message, str," AS "); + delay_string_append_char(message, str, analyze->table_name); + delay_string_append_char(message, str, "("); + pool_debug("writeSelectFooter %s",analyze->table_name); + + if(state != SELECT_FROMCLAUSE) + { + num = analyze->select_ret->col_num; + for(i = 0; i < num; i++) + { + delay_string_append_char(message, str, analyze->select_ret->col_list[i]); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, analyze->select_ret->type_list[i]); + if (i != num -1) + delay_string_append_char(message, str, ","); + } + delay_string_append_char(message, str, ")"); + } + else + { + int first = 0; + num = analyze->virtual->col_num; + + for(i = 0; i < num; i++) + { + if(analyze->virtual->valid[i] != -1) + { + char buf[16]; + if(first == 0) + { + snprintf(buf, 16, "%d", analyze->virtual->column_no[i]); + delay_string_append_char(message, str, "\"pool_c$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, analyze->virtual->type_list[i]); + first = 1; + } else { + delay_string_append_char(message, str, ","); + snprintf(buf, 16, "%d", analyze->virtual->column_no[i]); + delay_string_append_char(message, str, "\"pool_c$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, analyze->virtual->type_list[i]); + } + } + } + + if(first == 0) + { + for(i = 0; i < num; i++) + { + if(first == 0) + { + delay_string_append_char(message, str, analyze->virtual->col_list[i]); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, analyze->virtual->type_list[i]); + first = 1; + } else { + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, analyze->virtual->col_list[i]); + delay_string_append_char(message, str, " "); + delay_string_append_char(message, str, analyze->virtual->type_list[i]); + } + } + } + + delay_string_append_char(message, str, ")"); + } +} + +static void +CopyFromLeftArg(RewriteQuery *message,int current_num) +{ + AnalyzeSelect *l_analyze = message->analyze[current_num + 1]; + AnalyzeSelect *analyze = message->analyze[current_num]; + VirtualTable *virtual = message->analyze[current_num]->virtual; + int col_num; + int i; + char **col_list = NULL; + char **type_list = NULL; + char state; + char *table_name; + + table_name = l_analyze->table_name; + col_list = l_analyze->select_ret->col_list; + type_list = l_analyze->select_ret->type_list; + col_num = l_analyze->select_ret->col_num; + + state = l_analyze->state; + append_virtual_table(message,virtual,col_list,type_list,col_num,table_name,state,current_num + 1); + + analyze->select_ret = (SelectDefInfo *) palloc(sizeof(SelectDefInfo)); + analyze->select_ret->valid = false; + analyze->select_ret->col_num = 0; + for(i =0; iselect_ret,col_list[i],type_list[i]); + } +} + + +static void +ChangeStateByCluase(RewriteQuery *message,void *obj,int before, int after) +{ + AnalyzeSelect *analyze; + int count = message->current_select; + + if(message->r_code != SELECT_ANALYZE) + return; + + analyze = message->analyze[count]; + + if (obj && analyze->partstate[before] == 'P') + analyze->partstate[after] = 'S'; + else + analyze->partstate[after] = analyze->partstate[before]; +} + +static void +ChangeStateRewriteFooter(RewriteQuery *message,String *str,int defore, int after) +{ + AnalyzeSelect *analyze; + int count = message->current_select; + char state; + + if(message->r_code != SELECT_DEFAULT) + return; + + analyze = message->analyze[count]; + + if(analyze->state == 'S' && message->rewritelock == count + && message->ignore_rewrite == -1) + { + state = analyze->partstate[defore]; + + if(state == 'L' || state == 'P') + { + if(state != analyze->partstate[after]) + { + writeSelectFooter(message,str,analyze,SELECT_FROMCLAUSE); + message->rewritelock = -1; + } + } + } +} + +static bool +CheckUnionFromClause(RewriteQuery *message) +{ + int check; + int count = message->current_select; + AnalyzeSelect *analyze; + analyze = message->analyze[count]; + + check = analyze->last_select; + pool_debug("CheckUnion select=%d last_select=%d", count,check); + + if(check == -1) + return false; + else + { + if(message->analyze[check]->select_union && + message->analyze[check]->call_part == SELECT_FROMCLAUSE) + { + pool_debug("CheckUnion true"); + return true; + } + else + return false; + } +} + +static void +_rewriteSelectStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SelectStmt *node) +{ + BaseSelect = (Node *) node; + AnalyzeSelect *analyze; + int count; + int analyze_num = 0; + int target_analyze = 0; + int from_analyze = 0; + bool lock = false; + bool direct = false; + bool aggrewrite = false; + + count = message->analyze_num; + + /* Allocate Memory Space and initialize some Flags*/ + initSelectStmt(message,node); + + if(message->r_code == SELECT_DEFAULT) + { + if(message->current_select == 0) + pool_debug("_rewriteSelectStmt:START QueryRewrite"); + } + + analyze_num = message->analyze_num; + + analyze = message->analyze[count]; + analyze->part = SELECT_START; + + if(message->r_code == SELECT_DEFAULT && message->rewritelock == -1 + && message->ignore_rewrite == -1) + { +#if 0 + if(analyze->state == 'P') + { + if(analyze->call_part != SELECT_FROMCLAUSE || !CheckUnionFromClause(message)) + { + writeSelectHeader(message,dblink,str,PARALLEL,analyze->part); + message->rewritelock = count; + direct = true; + } + else + lock =true; + } +#endif + if(analyze->state == 'L') + { + if(analyze->call_part != SELECT_FROMCLAUSE && !CheckUnionFromClause(message)) + { + writeSelectHeader(message,dblink,str,LOADBALANCE,analyze->part); + message->rewritelock = count; + direct = true; + } + else + lock =true; + } + } + + if (node->larg) /* SETOP */ + { + if(message->r_code == SELECT_ANALYZE) + { + char buf[16]; + char *temp = "pool_t$"; + analyze->virtual = (VirtualTable *) palloc(sizeof(VirtualTable)); + snprintf(buf, 16, "%d", message->virtual_num); + message->virtual_num++; + analyze->table_name = (char *) palloc(sizeof(char) * (strlen(temp) + strlen(buf) + 1)); + strcpy(analyze->table_name,temp); + strcat(analyze->table_name,buf); + analyze->virtual->col_num = 0; + } + + delay_string_append_char(message, str, "("); + message->part = SELECT_START; + _rewriteNode(BaseSelect, message, dblink, str, node->larg); + pool_debug("union larg select_no=%d(%d)",count,message->analyze_num); + + delay_string_append_char(message, str, ")"); + KeepMessages(message,count,SELECT_START); + + /* COPY analyze of left arg */ + if(message->r_code == SELECT_ANALYZE) + { + analyze->larg_count = count + 1; + analyze->rarg_count = message->analyze_num; + pool_debug("_rewriteSelectStmt: COUNT larg=%d, rarg=%d",analyze->larg_count, analyze->rarg_count); + } + + switch (node->op) + { + case SETOP_UNION: + delay_string_append_char(message, str, " UNION "); + break; + + case SETOP_INTERSECT: + delay_string_append_char(message, str, " INTERSECT "); + break; + + case SETOP_EXCEPT: + delay_string_append_char(message, str, " EXCEPT "); + + default: + break; + } + + if (node->all) + delay_string_append_char(message, str, "ALL "); + + if (node->rarg) + { + delay_string_append_char(message, str, "("); + message->part = SELECT_START; + _rewriteNode(BaseSelect, message, dblink, str, node->rarg); + delay_string_append_char(message, str, ")"); + KeepMessages(message,count,SELECT_START); + + if(message->r_code == SELECT_ANALYZE) + CopyFromLeftArg(message,count); + } + + if(message->r_code == SELECT_ANALYZE) + { + pool_debug("_rewriteSelectStmt: STATE larg=%c, rarg=%c",message->analyze[analyze->larg_count]->state, + message->analyze[analyze->rarg_count]->state); + + } + + if(message->r_code == SELECT_DEFAULT) + { + pool_debug("_rewriteSelectStmt: DEFAULT COUNT larg=%d, rarg=%d",analyze->larg_count, analyze->rarg_count); + } + + if(message->r_code == SELECT_ANALYZE) + { + int lcount = analyze->larg_count; + int rcount = analyze->rarg_count; + if(message->analyze[lcount]->state == 'L' && + message->analyze[rcount]->state == 'L') + { + int j; + for(j = 0; j < SELECT_SORTCLAUSE; j++) + { + analyze->partstate[j]='L'; + } + } + else + { + int j; + for(j = 0; j < SELECT_SORTCLAUSE; j++) + { + analyze->partstate[j]='S'; + } + } + } + } + else + { + if (node->intoClause) + { + IntoClause *into = node->intoClause; + RangeVar *rel = (RangeVar *)into->rel; + + delay_string_append_char(message, str, "CREATE "); + if (rel->istemp == true) + delay_string_append_char(message, str, "TEMP "); + delay_string_append_char(message, str, "TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, into->rel); + KeepRewriteQueryReturnCode(message, SELECT_RELATION_ERROR); + + if (into->colNames) + { + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, into->colNames); + delay_string_append_char(message, str, ") "); + KeepRewriteQueryReturnCode(message, SELECT_RELATION_ERROR); + } + + if (into->options) + _rewriteWithDefinition(BaseSelect, message, dblink, str, into->options); + + switch (into->onCommit) + { + case ONCOMMIT_DROP: + delay_string_append_char(message, str, " ON COMMIT DROP"); + break; + + case ONCOMMIT_DELETE_ROWS: + delay_string_append_char(message, str, " ON COMMIT DELETE ROWS"); + break; + + case ONCOMMIT_PRESERVE_ROWS: + delay_string_append_char(message, str, " ON COMMIT PRESERVE ROWS"); + break; + + default: + break; + } + delay_string_append_char(message, str, " AS"); + } + + delay_string_append_char(message, str, " SELECT "); + + /* + * Check from-clause before Checking target-list + */ + if(node->fromClause) + { + message->part = SELECT_FROMCLAUSE; + analyze->part = SELECT_FROMCLAUSE; + message->fromClause = true; + + if(message->r_code == SELECT_ANALYZE) + { + char buf[16]; + char *temp = "pool_t$"; + analyze->virtual = (VirtualTable *) palloc(sizeof(VirtualTable)); + snprintf(buf, 16, "%d", message->virtual_num); + message->virtual_num++; + analyze->table_name = (char *) palloc(sizeof(char) * (strlen(temp) + strlen(buf) + 1)); + strcpy(analyze->table_name,temp); + strcat(analyze->table_name,buf); + analyze->virtual->col_num = 0; + } + + if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == -1) + message->ignore_rewrite = count; + + /* remember analyze_num */ + from_analyze = message->analyze_num; + + _rewriteNode(BaseSelect, message, dblink, str, node->fromClause); + + if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == count) + message->ignore_rewrite = -1; + + message->fromClause = false; + + if(message->r_code == SELECT_ANALYZE) + { + message->table_state = analyze->state; + analyze->partstate[SELECT_FROMCLAUSE] = analyze->state; + } + } + else + { + /* this is const or function call*/ + message->part = SELECT_TARGETLIST; + if(message->r_code == SELECT_ANALYZE) + build_range_info(message,NULL,NULL,NULL,NULL,message->current_select,-1); + } + + message->part = SELECT_OTHER; + analyze->part = SELECT_OTHER; + + if (message->r_code == SELECT_ANALYZE && node->groupClause) + { + analyze->aggregate = true; + } + + if (node->distinctClause) + { + if(message->r_code == SELECT_ANALYZE) + analyze->partstate[SELECT_TARGETLIST] = 'S'; +#if 0 + /* TODO + * DISTINCT optimization + */ + if(message->r_code == SELECT_ANALYZE) + analyze->aggregate = true; +#endif + delay_string_append_char(message, str, "DISTINCT "); + if (lfirst(list_head(node->distinctClause)) != NIL) + { + delay_string_append_char(message, str, "ON ("); + _rewriteNode(BaseSelect, message, dblink,str, node->distinctClause); + KeepMessages(message,count,SELECT_OTHER); + delay_string_append_char(message, str, ") "); + } + } + + message->part = SELECT_TARGETLIST; + analyze->part = SELECT_TARGETLIST; + + if(analyze->partstate[SELECT_FROMCLAUSE] == 'P' && analyze->aggregate) + analyze->partstate[SELECT_TARGETLIST] = 'S'; + + /* TARGETLIST START */ + _rewriteNode(BaseSelect, message, dblink, str, node->targetList); + + aggrewrite = CheckAggOpt(message); + + target_analyze = message->analyze_num; + + if(message->r_code == SELECT_ANALYZE) + { + if (analyze->aggregate && (analyze->partstate[SELECT_FROMCLAUSE] == 'P' + || analyze->partstate[SELECT_TARGETLIST] == 'P')) + analyze->partstate[SELECT_TARGETLIST] = 'S'; + else if (!analyze->partstate[SELECT_TARGETLIST]) + analyze->partstate[SELECT_TARGETLIST] = analyze->partstate[SELECT_FROMCLAUSE]; + } + + KeepMessages(message,count,SELECT_TARGETLIST); + + if (node->fromClause && message->r_code != SELECT_ANALYZE) + { + + message->analyze_num = from_analyze; + + message->part = SELECT_FROMCLAUSE; + analyze->part = SELECT_FROMCLAUSE; + delay_string_append_char(message, str, " FROM "); + + if(message->r_code == SELECT_DEFAULT && + (analyze->state == 'S' || lock) + && message->rewritelock == -1 && message->ignore_rewrite ==-1) + { + if(analyze->partstate[SELECT_FROMCLAUSE] == 'L') + { + writeSelectHeader(message,dblink,str,LOADBALANCE, message->part); + message->rewritelock = count; + } + else if(analyze->partstate[SELECT_FROMCLAUSE] == 'P') + { + if(aggrewrite) + { + writeSelectAggHeader(message,dblink,str, message->part); + } + else + { + writeSelectHeader(message,dblink,str,PARALLEL, message->part); + } + message->rewritelock = count; + } + } + + message->fromClause = true; + _rewriteNode(BaseSelect, message, dblink, str, node->fromClause); + message->fromClause = false; + KeepMessages(message,count,SELECT_FROMCLAUSE); + + if(message->r_code == SELECT_DEFAULT && analyze->state == 'S' + && message->rewritelock == count && message->ignore_rewrite == -1) + { + if(analyze->partstate[SELECT_FROMCLAUSE] == 'L') + { + if(analyze->partstate[SELECT_WHERECLAUSE] != 'L') + { + if(node->whereClause) + { + int message_code = message->r_code; + delay_string_append_char(message, str, " WHERE "); + CheckWhereCaluse(node->whereClause, message,dblink,str,0); + KeepRewriteQueryReturnCode(message, message_code); + } + + writeSelectFooter(message,str,analyze,SELECT_FROMCLAUSE); + message->rewritelock = -1; + } + } + else if(analyze->partstate[SELECT_FROMCLAUSE] == 'P') + { + if(analyze->partstate[SELECT_WHERECLAUSE] != 'P') + { + if(node->whereClause) + { + int message_code = message->r_code; + delay_string_append_char(message, str, " WHERE "); + CheckWhereCaluse(node->whereClause, message,dblink,str,0); + KeepRewriteQueryReturnCode(message, message_code); + } + writeSelectFooter(message,str,analyze,SELECT_FROMCLAUSE); + message->rewritelock = -1; + } + } + } + message->analyze_num = target_analyze; + } + + /* WHERE CLAUSE */ + + message->part = SELECT_OTHER; + if (node->whereClause) + BaseSelect = NULL; + + if (node->whereClause) + { + message->part = SELECT_WHERECLAUSE; + analyze->part = SELECT_WHERECLAUSE; + delay_string_append_char(message, str, " WHERE "); + _rewriteNode(BaseSelect, message, dblink, str, node->whereClause); + KeepMessages(message,count,SELECT_OTHER); + } + + if(!analyze->partstate[SELECT_WHERECLAUSE] && message->r_code == SELECT_ANALYZE) + analyze->partstate[SELECT_WHERECLAUSE] = analyze->partstate[SELECT_FROMCLAUSE]; + + if(aggrewrite) + writeSelectAggFooter(message,str,analyze); + else + ChangeStateRewriteFooter(message,str,SELECT_WHERECLAUSE, SELECT_GROUPBYCLAUSE); + + /* GROUPBY CLAUSE */ + if (node->groupClause) + { + analyze->part = SELECT_GROUPBYCLAUSE; + delay_string_append_char(message, str, " GROUP BY "); + _rewriteNode(BaseSelect, message, dblink, str, node->groupClause); + KeepMessages(message,count,SELECT_OTHER); + } + + ChangeStateByCluase(message,node->groupClause,SELECT_WHERECLAUSE,SELECT_GROUPBYCLAUSE); + + /* HAVING CLAUSE */ + if (node->havingClause) + { + analyze->part = SELECT_HAVINGCLAUSE; + delay_string_append_char(message, str, " HAVING "); + _rewriteNode(BaseSelect, message, dblink, str, node->havingClause); + KeepMessages(message,count,SELECT_OTHER); + + } + + if(message->r_code == SELECT_ANALYZE) + analyze->partstate[SELECT_HAVINGCLAUSE] = analyze->partstate[SELECT_GROUPBYCLAUSE]; + } + + ChangeStateRewriteFooter(message,str,SELECT_HAVINGCLAUSE, SELECT_SORTCLAUSE); + + if (node->sortClause) + { + analyze->part = SELECT_SORTCLAUSE; + delay_string_append_char(message, str, " ORDER BY "); + _rewriteNode(BaseSelect, message, dblink, str, node->sortClause); + KeepMessages(message,count,SELECT_OTHER); + } + + ChangeStateByCluase(message,node->sortClause,SELECT_HAVINGCLAUSE,SELECT_SORTCLAUSE); + + + ChangeStateRewriteFooter(message,str, SELECT_SORTCLAUSE, SELECT_OFFSETCLAUSE); + + if (node->limitOffset) + { + analyze->part = SELECT_OFFSETCLAUSE; + delay_string_append_char(message, str, " OFFSET "); + _rewriteNode(BaseSelect, message, dblink, str, node->limitOffset); + KeepMessages(message,count,SELECT_OTHER); + + } + + ChangeStateByCluase(message,node->limitOffset,SELECT_SORTCLAUSE,SELECT_OFFSETCLAUSE); + + ChangeStateRewriteFooter(message,str,SELECT_OFFSETCLAUSE,SELECT_LIMITCLAUSE); + + if (node->limitCount) + { + analyze->part = SELECT_LIMITCLAUSE; + delay_string_append_char(message, str, " LIMIT "); + if (IsA(node->limitCount, A_Const) && + ((A_Const *)node->limitCount)->val.type == T_Null) + { + delay_string_append_char(message, str, "ALL "); + } + else + { + _rewriteNode(BaseSelect, message, dblink, str, node->limitCount); + KeepMessages(message,count,SELECT_OTHER); + } + } + + ChangeStateByCluase(message,node->limitCount,SELECT_OFFSETCLAUSE,SELECT_LIMITCLAUSE); + + if(message->r_code == SELECT_ANALYZE) + { + int i; + analyze->state = analyze->partstate[SELECT_LIMITCLAUSE]; + + for(i = 0; i< 8; i++) + { + char s = analyze->partstate[i]; + if(s == 'S') + { + analyze->state = s; + break; + } + } + } + + _rewriteNode(BaseSelect, message, dblink, str, node->lockingClause); + KeepMessages(message,count,SELECT_OTHER); + + if(message->r_code == SELECT_ANALYZE) + { + if(node->targetList) + AnalyzeReturnRecord(BaseSelect,message,dblink,str,node->targetList); + + pool_debug("_rewriteSelectStmt select_no=%d state=%s",message->current_select,analyze->partstate); + + if(strstr(analyze->partstate,"E")) + message->is_loadbalance = true; + + /* change state */ + if(count != 0) + { + AnalyzeSelect *last = message->analyze[analyze->last_select]; + if(last->part == SELECT_WHERECLAUSE) + { + char fromstate = last->partstate[SELECT_FROMCLAUSE]; + char wherestate = (char) 0; + + if(last->partstate[SELECT_WHERECLAUSE]) + wherestate = last->partstate[SELECT_WHERECLAUSE]; + + if(fromstate == 'P' && analyze->state == 'L') + { + if(wherestate && wherestate == 'P') + last->partstate[SELECT_WHERECLAUSE] = 'P'; + } + else if(fromstate == 'L' && analyze->state == 'L') + { + last->partstate[SELECT_WHERECLAUSE] = 'L'; + } + else + last->partstate[SELECT_WHERECLAUSE] = 'S'; + } + + if(last->part == SELECT_TARGETLIST) + { + char fromstate = last->partstate[SELECT_FROMCLAUSE]; + char targetstate = (char) 0; + + if(last->partstate[SELECT_TARGETLIST]) + targetstate = last->partstate[SELECT_TARGETLIST]; + + if(fromstate == 'P' && analyze->state == 'L') + { + last->partstate[SELECT_TARGETLIST] = 'P'; + } + else if(fromstate == 'L' && analyze->state == 'L') + { + last->partstate[SELECT_TARGETLIST] = 'L'; + } + else + last->partstate[SELECT_TARGETLIST] = 'S'; + } + } + } + + if(message->r_code == SELECT_DEFAULT && message->rewritelock == count + && message->ignore_rewrite ==-1 ) + { + if(direct) + writeSelectFooter(message,str,analyze,analyze->call_part); + else + writeSelectFooter(message,str,analyze,SELECT_FROMCLAUSE); + + message->rewritelock = -1; + } +} + +static void +initAggexpr(AnalyzeSelect *analyze) +{ + Aggexpr *agg; + + if(analyze->aggexpr) + return; + + analyze->aggexpr = (Aggexpr *) palloc(sizeof(Aggexpr)); + agg = analyze->aggexpr; + agg->usec_p = NULL; + agg->tfunc_p = NULL; + agg->col_p = NULL; + agg->hfunc_p = NULL; + agg->umapc = NULL; + agg->u_num = 0; + agg->t_num = 0; + agg->c_num = 0; + agg->h_num = 0; + agg->hc_num = 0; + agg->s_num = 0; + agg->sc_num = 0; + agg->opt = true; +} + +static int +FuncChangebyAggregate(AnalyzeSelect *analyze, FuncCall *fnode) +{ + Aggexpr *agg; + int i; + + + if(analyze->aggregate && analyze->aggexpr) + agg = analyze->aggexpr; + else + return -1; + + if(!agg->opt) + return -1; + + if(analyze->part == SELECT_TARGETLIST) + { + for(i = 0; i < agg->t_num; i++) + { + if(fnode == agg->tfunc_p[i]) + { + return i; + } + } + } + else if(analyze->part == SELECT_HAVINGCLAUSE) + { + for(i = 0; i < agg->h_num; i++) + { + if(fnode == agg->hfunc_p[i]) + { + return i; + } + } + } + else if(analyze->part == SELECT_SORTCLAUSE) + { + String *sortfunc; + sortfunc = init_string(""); + _outNode(sortfunc, fnode); + + for(i = 0; i < agg->t_num; i++) + { + String *having; + having = init_string(""); + _outNode(having, agg->tfunc_p[i]); + if(!strcmp(sortfunc->data,having->data)) + { + free_string(having); + free_string(sortfunc); + return i; + } else { + if(having) + free_string(having); + } + } + if(sortfunc) + free_string(sortfunc); + } + return -1; +} + +static int +ColumnChangebyAggregate(AnalyzeSelect *analyze,ColumnRef *cnode) +{ + Aggexpr *agg; + int i; + + + if(analyze->aggregate && analyze->aggexpr) + agg = analyze->aggexpr; + else + return -1; + + if(!agg->opt) + return -1; + + if(analyze->part == SELECT_GROUPBYCLAUSE) + { + for(i = 0; i < agg->c_num; i++) + { + if(cnode == agg->col_p[i]) + { + return agg->t_num + i; + } + } + } + else if(analyze->part == SELECT_TARGETLIST) + { + for(i = 0; i < agg->u_num; i++) + { + char *n_c = NULL; + char *n_t = NULL; + char *c_c = NULL; + char *c_t = NULL; + n_c = GetNameFromColumnRef(cnode,true); + n_t = GetNameFromColumnRef(cnode,false); + c_c = GetNameFromColumnRef(agg->usec_p[i],true); + c_t = GetNameFromColumnRef(agg->usec_p[i],false); + + if(n_t && c_t) + { + if(!strcmp(n_t,c_t) && !strcmp(n_c,c_c)) + return agg->t_num + agg->umapc[i]; + } + else + { + if(!strcmp(n_c,c_c)) + return agg->t_num + agg->umapc[i]; + } + } + } + else if(analyze->part == SELECT_HAVINGCLAUSE || analyze->part == SELECT_SORTCLAUSE) + { + for(i = 0; i < agg->c_num; i++) + { + char *n_c = NULL; + char *n_t = NULL; + char *c_c = NULL; + char *c_t = NULL; + n_c = GetNameFromColumnRef(cnode,true); + n_t = GetNameFromColumnRef(cnode,false); + c_c = GetNameFromColumnRef(agg->col_p[i],true); + c_t = GetNameFromColumnRef(agg->col_p[i],false); + + if(n_t && c_t) + { + if(!strcmp(n_t,c_t) && !strcmp(n_c,c_c)) + return agg->t_num + i; + } + else + { + if(!strcmp(n_c,c_c)) + return agg->t_num + i; + } + } + } + return -1; +} + +static void +AppendAggregate(AnalyzeSelect *analyze,FuncCall *fnode,ColumnRef *cnode) +{ + Aggexpr *agg; + + initAggexpr(analyze); + + agg = analyze->aggexpr; + + + if(analyze->part == SELECT_GROUPBYCLAUSE) + { + if(!agg->col_p) + { + agg->col_p = (ColumnRef **) palloc(sizeof(ColumnRef *)); + } + else + { + agg->col_p = (ColumnRef **) repalloc(agg->col_p,(agg->c_num + 1) *sizeof(ColumnRef *)); + } + agg->col_p[agg->c_num] = cnode; + SeekColumnName(agg,cnode,SELECT_GROUPBYCLAUSE); + agg->c_num++; + } + else if(analyze->part == SELECT_TARGETLIST) + { + if(fnode) /* for function */ + { + if(!agg->tfunc_p) + { + agg->tfunc_p = (FuncCall **) palloc(sizeof(FuncCall *)); + } + else + { + agg->tfunc_p = (FuncCall **) repalloc(agg->tfunc_p,(agg->t_num + 1) *sizeof(FuncCall *)); + } + agg->tfunc_p[agg->t_num] = fnode; + agg->t_num++; + } else { /* for Column */ + if(!agg->usec_p) + { + agg->usec_p = (ColumnRef **) palloc(sizeof(ColumnRef *)); + agg->umapc = (int *) palloc(sizeof(int)); + } + else + { + agg->usec_p = (ColumnRef **) repalloc(agg->usec_p,(agg->u_num + 1) *sizeof(ColumnRef *)); + agg->umapc = (int *) repalloc(agg->umapc,(agg->u_num + 1) *sizeof(int)); + } + agg->usec_p[agg->u_num] = cnode; + agg->u_num++; + } + } + else if(analyze->part == SELECT_HAVINGCLAUSE) + { + if(fnode) /* for function */ + { + if(!agg->hfunc_p) + { + agg->hfunc_p = (FuncCall **) palloc(sizeof(FuncCall *)); + } + else + { + agg->hfunc_p = (FuncCall **) repalloc(agg->hfunc_p,(agg->h_num + 1) *sizeof(FuncCall *)); + } + agg->hfunc_p[agg->h_num] = fnode; + agg->h_num++; + } + } +} + +static void +_rewriteFuncCall(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncCall *node) +{ + char *funcname; + bool avg_flag = false; + if(message->r_code == SELECT_AEXPR) + { + KeepRewriteQueryReturnCode(message, SELECT_AEXPR_FALSE); + return; + } + + funcname = strVal(lfirst(list_head(node->funcname))); + + if (CheckAggOpt(message)) + { + int i; + AnalyzeSelect *analyze; + int no = message->current_select; + analyze = message->analyze[no]; + + i = FuncChangebyAggregate(analyze,node); + if(i != -1) + { + if(!strcmp(funcname,"count")) + delay_string_append_char(message, str, "sum"); + else if(!strcmp(funcname,"avg")) + { + delay_string_append_char(message, str, "(sum"); + avg_flag =true; + } + else + _rewriteFuncName(BaseSelect, message, dblink, str, node->funcname); + } + else + _rewriteFuncName(BaseSelect, message, dblink, str, node->funcname); + + } + else + _rewriteFuncName(BaseSelect, message, dblink, str, node->funcname); + + if(message->r_code == SELECT_ANALYZE && funcname) + { + /* aggregate functions */ + if(!strcmp(funcname,"count") || !strcmp(funcname,"max") || !strcmp(funcname,"min") + || !strcmp(funcname,"sum") || !strcmp(funcname,"avg") || !strcmp(funcname,"bit_and") + || !strcmp(funcname,"bit_or") || !strcmp(funcname,"bool_and") || !strcmp(funcname,"bool_or") + || !strcmp(funcname,"every") || !strcmp(funcname,"corr") || !strcmp(funcname,"covar_pop") + || !strcmp(funcname,"covar_samp") || !strcmp(funcname,"regr_avgx") || !strcmp(funcname,"regr_avgy") + || !strcmp(funcname,"regr_count") || !strcmp(funcname,"regr_intercept") || !strcmp(funcname,"regr_r2") + || !strcmp(funcname,"regr_slope") || !strcmp(funcname,"regr_sxx") || !strcmp(funcname,"regr_sxy") + || !strcmp(funcname,"regr_syy") || !strcmp(funcname,"stddev") || !strcmp(funcname,"stddev_pop") + || !strcmp(funcname,"stddev_samp") || !strcmp(funcname,"variance") || !strcmp(funcname,"var_pop") + || !strcmp(funcname,"var_samp")) + { + AnalyzeSelect *analyze; + int no = message->current_select; + analyze = message->analyze[no]; + analyze->aggregate = true; + + if(analyze->part == SELECT_TARGETLIST || analyze->part == SELECT_HAVINGCLAUSE) + { + if(!strcmp(funcname,"count") || !strcmp(funcname,"max") || + !strcmp(funcname,"min") || !strcmp(funcname,"sum") || !strcmp(funcname,"avg")) + { + AppendAggregate(analyze,node,NULL); + } + else + { + initAggexpr(analyze); + analyze->aggexpr->opt = false; + } + } + } + } + + if(strcmp(funcname,"user") == 0 || + strcmp(funcname,"current_user") == 0 || + strcmp(funcname,"session_user") == 0 || + strcmp(funcname,"current_role") == 0) + return ; + + delay_string_append_char(message, str, "("); + + if (node->agg_distinct == TRUE) + delay_string_append_char(message, str, "DISTINCT "); + + if (CheckAggOpt(message)) + { + int i; + AnalyzeSelect *analyze; + int no = message->current_select; + analyze = message->analyze[no]; + i = FuncChangebyAggregate(analyze,node); + if(i != -1) + { + char buf[16]; + snprintf(buf, 16, "%d", i); + delay_string_append_char(message, str, "pool_g$"); + delay_string_append_char(message, str, buf); + pool_debug("_FuncCall: aggregate no = %d",i); + delay_string_append_char(message, str, ")"); + + if(avg_flag) + { + delay_string_append_char(message, str, "/"); + delay_string_append_char(message, str, "sum("); + delay_string_append_char(message, str, "pool_g$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, "c"); + delay_string_append_char(message, str, "))"); + } + return ; + } + } + + if (node->agg_star == TRUE) + delay_string_append_char(message, str, "*"); + else + _rewriteNode(BaseSelect, message, dblink, str, node->args); + + delay_string_append_char(message, str, ")"); +} + +static void +AvgFuncCall(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncCall *node) +{ + char *funcname; + if(message->r_code == SELECT_AEXPR) + { + KeepRewriteQueryReturnCode(message, SELECT_AEXPR_FALSE); + return; + } + + funcname = strVal(lfirst(list_head(node->funcname))); + + delay_string_append_char(message, str, "sum"); + + delay_string_append_char(message, str, "("); + + if (node->agg_distinct == TRUE) + delay_string_append_char(message, str, "DISTINCT "); + + _rewriteNode(BaseSelect, message, dblink, str, node->args); + + delay_string_append_char(message, str, ")"); + delay_string_append_char(message, str, ","); + delay_string_append_char(message, str, "count"); + + delay_string_append_char(message, str, "("); + + if (node->agg_distinct == TRUE) + delay_string_append_char(message, str, "DISTINCT "); + + _rewriteNode(BaseSelect, message, dblink, str, node->args); + + delay_string_append_char(message, str, ")"); +} + +static void +_rewriteDefElem(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DefElem *node) +{ + +} + +static void +_rewriteLockingClause(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, LockingClause *node) +{ + if (node == NULL) + return; + + if (node->forUpdate == TRUE) + delay_string_append_char(message, str, " FOR UPDATE"); + else + delay_string_append_char(message, str, " FOR SHARED"); + + _rewriteNode(BaseSelect, message, dblink, str, node->lockedRels); + + if (node->noWait == TRUE) + delay_string_append_char(message, str, " NOWAIT "); +} + +static void +_rewriteColumnDef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ColumnDef *node) +{ + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->colname); + delay_string_append_char(message, str, "\" "); + _rewriteNode(BaseSelect, message, dblink, str, node->typename); + _rewriteNode(BaseSelect, message, dblink, str, node->constraints); +} + +static void +_rewriteTypeName(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TypeName *node) +{ + ListCell *lc; + char dot = 0; + + foreach (lc, node->names) + { + Value *v = (Value *) lfirst(lc); + char *typename = v->val.str; + + if (dot == 0) + dot = 1; + else + delay_string_append_char(message, str, "."); + if(node->typemod < 0) + { + if(message->rewritelock != -1) + { + delay_string_append_char(message, str, "\"\""); + delay_string_append_char(message, str, typename); + delay_string_append_char(message, str, "\"\""); + } else { + //delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, typename); + //delay_string_append_char(message, str, "\""); + } + } else + delay_string_append_char(message, str, typename); + } + + if (node->typemod > 0) + { + int lower; + char buf[16]; + delay_string_append_char(message, str, "("); + snprintf(buf, 16, "%d", ((node->typemod - VARHDRSZ) >> 16) & 0x00FF); + delay_string_append_char(message, str, buf); + lower = (node->typemod-VARHDRSZ) & 0x00FF; + + if(lower != 0) + { + char buf2[16]; + delay_string_append_char(message, str, ","); + snprintf(buf2, 16, "%d",lower); + delay_string_append_char(message, str, buf2); + } + + delay_string_append_char(message, str, ")"); + } +} + +static void +_rewriteTypeCast(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TypeCast *node) +{ + _rewriteNode(BaseSelect, message, dblink, str, node->arg); + delay_string_append_char(message, str, "::"); + _rewriteNode(BaseSelect, message, dblink, str, node->typename); + +} + +static void +_rewriteIndexElem(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, IndexElem *node) +{ + if (node->name) + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + if (node->opclass != NIL) + _rewriteNode(BaseSelect, message, dblink, str, node->opclass); + } + else + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->expr); + delay_string_append_char(message, str, ")"); + if (node->opclass != NIL) + _rewriteNode(BaseSelect, message, dblink, str, node->opclass); + } +} + + +static void +_rewriteSortClause(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SortClause *node) +{ + +} + +static void +_rewriteGroupClause(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, GroupClause *node) +{ + +} + +static void +_rewriteSetOperationStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SetOperationStmt *node) +{ + +} + + +static void +_rewriteAExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Expr *node) +{ + Value *v; + + switch (node->kind) + { + case AEXPR_OP: + if (list_length(node->name) == 1) + { + Value *op = (Value *) lfirst(list_head(node->name)); + + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, op->val.str); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, " )"); + } + break; + + case AEXPR_AND: + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, " AND "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_OR: + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, " OR "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_NOT: + delay_string_append_char(message, str, " (NOT "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_OP_ANY: + _rewriteNode(BaseSelect,message,dblink,str, node->lexpr); + v = linitial(node->name); + delay_string_append_char(message,str, v->val.str); + delay_string_append_char(message,str, "ANY("); + _rewriteNode(BaseSelect,message,dblink,str, node->rexpr); + delay_string_append_char(message,str, ")"); + break; + + case AEXPR_OP_ALL: + _rewriteNode(BaseSelect,message,dblink,str, node->lexpr); + v = linitial(node->name); + delay_string_append_char(message,str, v->val.str); + delay_string_append_char(message,str, "ALL("); + _rewriteNode(BaseSelect,message,dblink,str, node->rexpr); + delay_string_append_char(message,str, ")"); + break; + + case AEXPR_DISTINCT: + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, " IS DISTINCT FROM "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_NULLIF: + delay_string_append_char(message, str, " NULLIF("); + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + delay_string_append_char(message, str, ", "); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + + case AEXPR_OF: + _rewriteNode(BaseSelect, message, dblink, str, node->lexpr); + v = linitial(node->name); + if (v->val.str[0] == '!') + delay_string_append_char(message, str, " IS NOT OF ("); + else + delay_string_append_char(message, str, " IS OF ("); + _rewriteNode(BaseSelect, message, dblink, str, node->rexpr); + delay_string_append_char(message, str, ")"); + break; + case AEXPR_IN: + _rewriteNode(BaseSelect,message,dblink,str, node->lexpr); + v = (Value *)lfirst(list_head(node->name)); + if (v->val.str[0] == '=') + delay_string_append_char(message,str, " IN ("); + else + delay_string_append_char(message,str, " NOT IN ("); + _rewriteNode(BaseSelect,message,dblink,str, node->rexpr); + delay_string_append_char(message,str, ")"); + break; + default: + break; + } +} + +static void +_rewriteValue(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Value *value) +{ + char buf[16]; + + switch (value->type) + { + case T_Integer: + sprintf(buf, "%ld", value->val.ival); + delay_string_append_char(message, str, buf); + break; + + case T_Float: + delay_string_append_char(message, str, value->val.str); + break; + + case T_String: + /* delay_string_append_char(message, str, "'"); */ + delay_string_append_char(message, str, escape_string(value->val.str)); + /* delay_string_append_char(message, str, "'"); */ + break; + + case T_Null: + delay_string_append_char(message, str, "NULL"); + break; + + default: + break; + } +} + +static char +GetInnerRef(RewriteQuery *message,int last,char *table_name,char *column,char state) +{ + AnalyzeSelect *analyze; + VirtualTable *virtual; + int num, i; + bool get = false; + + analyze = message->analyze[last]; + virtual = analyze->virtual; + num = virtual->col_num; + + for(i=0; i < num; i++) + { + char *vcol = virtual->col_list[i]; + char *vtable = virtual->table_list[i]; + if(table_name + && !strcmp(table_name,vtable) && !strcmp(column,vcol)) + { + pool_debug("GetInnerRef state = %c now select(%d), table_name=(%s), col_name=(%s) detect",state,last,vtable,vcol); + get = true; + break; + } + else if(!table_name && !strcmp(column,vcol)) + { + pool_debug("GetInnerRef state = %c now select(%d), table_name=(%s), col_name=(%s) detect",state,last,vtable,vcol); + get = true; + break; + } + } + + if(get) + return state; + else + { + /* there isn't the inner refarence at parallel part */ + if(state == 'P' || analyze->partstate[SELECT_FROMCLAUSE] =='P') + return 'S'; + + if(last == 0) + return 'E'; + else + return GetInnerRef(message,analyze->last_select,table_name,column,state); + } +} + +static void +ChangeStatebyColumnRef(RewriteQuery *message,ColumnRef *col) +{ + AnalyzeSelect *analyze; + VirtualTable *virtual; + ListCell *c; + List *list; + char first = 0; + char *table_name = NULL; + char *column = NULL; + int num,no; + + list = col->fields; + + no = message->current_select; + analyze = message->analyze[no]; + + if(list->length > 2 || list->length == 0) + { + /* Is this error ? */ + message->analyze[no]->state = 'S'; + return; + } + + foreach (c, col->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + Value *v = (Value *) lfirst(c); + if(list->length == 2 && first == 0) + { + first = 1; + table_name = v->val.str; + } + else + column = v->val.str; + } + } + + if(!column) + { + message->table_state = 'S'; + return; + } + + pool_debug("ChangeStatebyColumnRef %s now(%d),last(%d) part(%d) call_part(%d)", + column, + analyze->now_select, + analyze->last_select, + analyze->part, + analyze->call_part + ); + + virtual = analyze->virtual; + num = virtual->col_num; + + if(message->part==SELECT_WHERECLAUSE || message->part == SELECT_TARGETLIST) + { + if(analyze->partstate[message->part] != 'S') + { + analyze->partstate[message->part] = + GetInnerRef(message,no,table_name,column,analyze->partstate[SELECT_FROMCLAUSE]); + pool_debug("return state is %c",analyze->partstate[message->part]); + } + } +} + +static bool DetectValidColumn(RewriteQuery *message,char *table_name,char *column_name,int no, int call) +{ + AnalyzeSelect *analyze; + VirtualTable *virtual; + int v_num,i; + int get = 0; + int call_num; + bool star = false; + + call_num = message->current_select; + + if(call != -1 && no != call_num && call == SELECT_FROMCLAUSE) + { + int last = message->analyze[no]->last_select; + int call_part = message->analyze[no]->call_part; + + if(last == -1) + { + return false; + } + else + { + return DetectValidColumn(message,table_name,column_name,last,call_part); + } + } + + analyze = message->analyze[no]; + virtual = analyze->virtual; + v_num = virtual->col_num; + + for(i = 0; i< v_num; i++) + { + char *vcol = virtual->col_list[i]; + char *vtable = virtual->table_list[i]; + + if(table_name && !strcmp(table_name,vtable) && !strcmp(column_name,"*")) + { + virtual->valid[i] = message->current_select; + star = true; + } + else if (!table_name && !strcmp(column_name,"*")) + { + virtual->valid[i] = message->current_select; + star = true; + } + + if(table_name + && !strcmp(table_name,vtable) && !strcmp(column_name,vcol)) + { + pool_debug("DetectValidColumn no = %d, table_name=(%s), col_name=(%s) detect",no, vtable, vcol); + get++; + + if(virtual->valid[i] == -1) + { + virtual->valid[i] = message->current_select; + } + else if (virtual->valid[i] > no) + { + virtual->valid[i] = message->current_select; + } + } + else if(!table_name && !strcmp(column_name,vcol)) + { + pool_debug("DetectValidColumn no = %d, col_name=(%s) detect",no, vcol); + get++; + + if(virtual->valid[i] == -1) + { + virtual->valid[i] = message->current_select; + } + else if (virtual->valid[i] > no) + { + virtual->valid[i] = message->current_select; + } + } + } + + if(star) + return true; + + if(get == 1) + { + return true; + } + else if(get == 0) + { + int last = analyze->last_select; + if(last != -1) + { + return DetectValidColumn(message,table_name,column_name,analyze->last_select,analyze->call_part); + } + } + else if(get>= 2) + pool_debug("DetectValidColumn select_no=(%d) col_name=(%s) ambiguous",message->current_select,column_name); + + return false; +} + +static bool GetPoolColumn(RewriteQuery *message,String *str,char *table_name,char *column_name,int no, int call,bool state) +{ + AnalyzeSelect *analyze,*analyze_now; + VirtualTable *virtual; + int v_num,i; + int get = 0; + int call_num; + bool star = false; + + call_num = message->current_select; + + if(call != -1 && no != call_num && call == SELECT_FROMCLAUSE) + { + int last = message->analyze[no]->last_select; + int call_part = message->analyze[no]->call_part; + + if(last == -1) + { + return false; + } + else + { + return GetPoolColumn(message,str,table_name,column_name,last,call_part,state); + } + } + + analyze = message->analyze[no]; + analyze_now = message->analyze[call_num]; + virtual = analyze->virtual; + v_num = virtual->col_num; + + for(i = 0; i< v_num; i++) + { + char *vcol = virtual->col_list[i]; + char *vtable = virtual->table_list[i]; + + if(table_name && !strcmp(table_name,vtable) && !strcmp(column_name,"*")) + { + star = true; + break; + } + else if (!table_name && !strcmp(column_name,"*")) + { + star = true; + break; + } + + if(table_name + && !strcmp(table_name,vtable) && !strcmp(column_name,vcol)) + { + pool_debug("GetPoolColumn no = %d, table_name=(%s), col_name=(%s) new_colname$%d detect",no, vtable, vcol,i); + get++; + break; + } + else if(!table_name && !strcmp(column_name,vcol)) + { + pool_debug("GetPoolColumn no = %d, col_name=(%s) new_colname=pool_c$%d detect",no, vcol,i); + get++; + break; + } + } + + if(star) + { + if(table_name) + { + int first = 0; + for(i = 0; i < v_num; i++) + { + char buf[16]; + if(!strcmp(virtual->table_list[i],table_name) && virtual->valid[i] != -1) + { + if(first == 0) + first = 1; + else + delay_string_append_char(message, str, ","); + + if(message->rewritelock == -1) + { + snprintf(buf, 16, "%d", analyze->virtual->column_no[i]); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str, "\""); + + if(message->ignore_rewrite == -1 && call_num != 0 && analyze->call_part == SELECT_FROMCLAUSE) + { + char buf2[16]; + int col_no = analyze->select_ret->return_list[analyze->ret_count]; + delay_string_append_char(message, str, " AS "); + snprintf(buf2, 16, "%d", col_no); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf2); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str," "); + pool_debug("GetPoolColumn analyze[%d] targetlist=* => pool_c$%s AS pool_c$%s", + no,buf,buf2); + analyze->ret_count++; + continue; + } + } else { + delay_string_append_char(message, str,analyze->virtual->col_list[i]); + } + + delay_string_append_char(message, str, " "); + + if(state && message->rewritelock == -1) + { + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, analyze->select_ret->col_list[message->ret_num]); + delay_string_append_char(message, str, "\" "); + message->ret_num++; + } + } + } + } + else + { + int first = 0; + for(i = 0; i < v_num; i++) + { + char buf[16]; + if(virtual->valid[i] != -1) + { + if(first == 0) + first = 1; + else + delay_string_append_char(message, str, ","); + + if(message->rewritelock == -1) + { + snprintf(buf, 16, "%d", analyze->virtual->column_no[i]); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str,"\""); + + if(message->ignore_rewrite == -1 && call_num != 0 && analyze->call_part == SELECT_FROMCLAUSE) + { + char buf2[16]; + int col_no = analyze->select_ret->return_list[analyze->ret_count]; + delay_string_append_char(message, str, " AS "); + snprintf(buf2, 16, "%d", col_no); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf2); + delay_string_append_char(message, str,"\""); + delay_string_append_char(message, str," "); + analyze->ret_count++; + pool_debug("GetPoolColumn analyze[%d] targetlist=%s => pool_c$%s AS pool_c$%s", + no,column_name,buf,buf2); + continue; + } + + } else { + delay_string_append_char(message, str,analyze->virtual->col_list[i]); + } + delay_string_append_char(message, str, " "); + + if(state && message->rewritelock == -1) + { + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, analyze->select_ret->col_list[message->ret_num]); + message->ret_num++; + } + } + } + } + return true; + } + + if(get == 1) + { + char buf[16]; + snprintf(buf, 16, "%d", virtual->column_no[i]); + +#if 0 + if(analyze_now->partstate[SELECT_FROMCLAUSE] != 'S') { + delay_string_append_char(message, str, analyze->table_name); + delay_string_append_char(message, str, "."); + } else { + delay_string_append_char(message, str, virtual->table_list[i]); + delay_string_append_char(message, str, "."); + } +#endif + delay_string_append_char(message, str, "\"pool_c$"); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, "\""); + + return true; + } + else if(get == 0) + { + int last = analyze->last_select; + if(last != -1) + { + return GetPoolColumn(message,str,table_name,column_name,analyze->last_select,analyze->call_part,state); + } + else + return false; + } + + return false; +} + +static void SeekColumnName(Aggexpr *agg,ColumnRef *node, int state) +{ + char *column = NULL; + char *table = NULL; + int i; + + /* get column & table name from group by */ + column = GetNameFromColumnRef(node,true); + table = GetNameFromColumnRef(node,false); + + if(state == SELECT_GROUPBYCLAUSE) + { + for(i = 0; i < agg->u_num; i++) + { + ColumnRef *unode = agg->usec_p[i]; + char *t_column = NULL; + char *t_table = NULL; + t_column = GetNameFromColumnRef(unode,true); + t_table = GetNameFromColumnRef(unode,false); + + if(table && t_table) + { + if(!strcmp(table,t_table) && !strcmp(column,t_column)) + { + agg->umapc[i] = agg->c_num; + return; + } + } + else + { + if(!strcmp(column,t_column)) + { + agg->umapc[i] = agg->c_num; + return; + } + } + } + } +} + +static bool CheckAggOpt(RewriteQuery *message) +{ + AnalyzeSelect *analyze; + if(message->r_code != SELECT_DEFAULT) + return false; + + analyze = message->analyze[message->current_select]; + + if(analyze->aggregate && analyze->aggexpr && analyze->aggexpr->opt + && (analyze->part == SELECT_TARGETLIST || analyze->part == SELECT_GROUPBYCLAUSE + || analyze->part == SELECT_HAVINGCLAUSE || analyze->part == SELECT_SORTCLAUSE) + && analyze->partstate[SELECT_FROMCLAUSE] == 'P' + && analyze->partstate[SELECT_TARGETLIST] == 'S' + && analyze->partstate[SELECT_WHERECLAUSE] == 'P') + return true; + + return false; +} + +static char *GetNameFromColumnRef(ColumnRef *node,bool state) +{ + ListCell *c; + List *list; + list = node->fields; + int first = 0; + char *table_name = NULL; + char *column_name = NULL; + + foreach (c, node->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + Value *v = (Value *) lfirst(c); + if(list->length == 2 && first == 0) + { + first = 1; + table_name = v->val.str; + } + else + column_name = v->val.str; + } + } + + if(state) + return column_name; + else + return table_name; +} + +static void +_rewriteColumnRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ColumnRef *node) +{ + ListCell *c; + List *list; + char first = 0; + char *table_name = NULL; + char *column_name = NULL; + + if(CheckAggOpt(message)) + { + int i; + AnalyzeSelect *analyze = message->analyze[message->current_select]; + + i = ColumnChangebyAggregate(analyze,node); + if(i != -1) + { + char buf[16]; + snprintf(buf, 16, "%d", i); + delay_string_append_char(message, str, "pool_g$"); + delay_string_append_char(message, str, buf); + pool_debug("_rewriteColumnRef: aggregate no = %d",i); + return ; + } + } + + list = node->fields; + + foreach (c, node->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + + if(message->r_code == SELECT_AEXPR && + (_checkVirtualColumn(node, message) != 1)) + { + KeepRewriteQueryReturnCode(message, SELECT_AEXPR_FALSE); + return; + } + + Value *v = (Value *) lfirst(c); + if(list->length == 2 && first == 0) + { + first = 1; + table_name = v->val.str; + } + else + column_name = v->val.str; + } + } + + if(message->r_code == SELECT_ANALYZE) + { + AnalyzeSelect *analyze = message->analyze[message->current_select]; + + if(analyze->part == SELECT_GROUPBYCLAUSE || analyze->part == SELECT_TARGETLIST) + AppendAggregate(analyze,NULL,node); + + if(!DetectValidColumn(message,table_name,column_name,message->current_select,-1)) + { + message->is_loadbalance = true; + pool_debug("_rewriteColumnRef: wrong column select_no=%d",message->current_select); + } + if(strcmp(column_name,"*")) + ChangeStatebyColumnRef(message,node); + } + else if(message->r_code == SELECT_DEFAULT) + { + + if(message->rewritelock == -1) + { + if(!GetPoolColumn(message,str,table_name,column_name,message->current_select,-1,false)) + delay_string_append_char(message, str, column_name); + } + else + { + if(table_name) + { + if(message->rewritelock == -1) + { + AnalyzeSelect *analyze = message->analyze[message->current_select]; + char s = analyze->partstate[SELECT_FROMCLAUSE]; + + if(s == 'L' || s =='P') + { + delay_string_append_char(message, str, analyze->table_name); + } + } + else + delay_string_append_char(message, str, table_name); + delay_string_append_char(message, str, "."); + } + delay_string_append_char(message, str, column_name); + } + } +} + +static void +_rewriteParamRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ParamRef *node) +{ + char buf[16]; + + snprintf(buf, 16, "%d", node->number); + delay_string_append_char(message, str, "$"); + delay_string_append_char(message, str, buf); +} + +static void +_rewriteAConst(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Const *node) +{ + char buf[16]; + char *name = NULL; + + if (node->typename) + { + Value *v = linitial(node->typename->names); + name = v->val.str; + _rewriteNode(BaseSelect, message, dblink, str, node->typename); + delay_string_append_char(message, str, " "); + } + + switch (node->val.type) + { + case T_Integer: + sprintf(buf, "%ld", node->val.val.ival); + delay_string_append_char(message, str, buf); + break; + + case T_Float: + delay_string_append_char(message, str, node->val.val.str); + break; + + case T_String: + if(message->rewritelock != -1) + { + delay_string_append_char(message, str, "\'\'"); + delay_string_append_char(message, str, escape_string(node->val.val.str)); + delay_string_append_char(message, str, "\'\'"); + } else { + delay_string_append_char(message, str, "\'"); + delay_string_append_char(message, str, escape_string(node->val.val.str)); + delay_string_append_char(message, str, "\'"); + } + break; + + case T_Null: + delay_string_append_char(message, str, "NULL"); + break; + + default: + break; + } + + if (name && (strcmp(name, "interval") == 0) && + node->typename->typmods) + { + A_Const *v = linitial(node->typename->typmods); + int mask = v->val.val.ival; + + if (mask == INTERVAL_MASK(YEAR)) + delay_string_append_char(message, str, " YEAR"); + else if (mask == INTERVAL_MASK(MONTH)) + delay_string_append_char(message, str, " MONTH"); + else if (mask == INTERVAL_MASK(DAY)) + delay_string_append_char(message, str, " DAY"); + else if (mask == INTERVAL_MASK(HOUR)) + delay_string_append_char(message, str, " HOUR"); + else if (mask == INTERVAL_MASK(MINUTE)) + delay_string_append_char(message, str, " MINUTE"); + else if (mask == INTERVAL_MASK(SECOND)) + delay_string_append_char(message, str, " SECOND"); + else if (mask == (INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH))) + delay_string_append_char(message, str, " YEAR TO MONTH"); + else if (mask == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR))) + delay_string_append_char(message, str, " DAY TO HOUR"); + else if (mask == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | + INTERVAL_MASK(MINUTE))) + delay_string_append_char(message, str, " DAY TO MINUTE"); + else if (mask == (INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | + INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND))) + delay_string_append_char(message, str, " DAY TO SECOND"); + else if (mask == (INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) + delay_string_append_char(message, str, " HOUR TO MINUTE"); + else if (mask == (INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | + INTERVAL_MASK(SECOND))) + delay_string_append_char(message, str, " HOUR TO SECOND"); + } +} + +static void +_rewriteA_Indices(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Indices *node) +{ + delay_string_append_char(message, str, "["); + if (node->lidx) + { + _rewriteNode(BaseSelect, message, dblink, str, node->lidx); + delay_string_append_char(message, str, ":"); + } + _rewriteNode(BaseSelect, message, dblink, str, node->uidx); + delay_string_append_char(message, str, "]"); +} + +static void +_rewriteA_Indirection(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, A_Indirection *node) +{ + _rewriteNode(BaseSelect, message, dblink, str, node->arg); + _rewriteNode(BaseSelect, message, dblink, str, node->indirection); + +} + +static bool +AliasToResTargetCondition(RewriteQuery *message,String *str) +{ + int select_no = message->current_select; + AnalyzeSelect *n_analyze; + AnalyzeSelect *u_analyze; + char buf[16]; + int ret; + int col_no; + + if(select_no == 0 || message->r_code != SELECT_DEFAULT + || message->rewritelock != -1 || message->ignore_rewrite != -1) + return false; + + n_analyze=message->analyze[select_no]; + u_analyze=message->analyze[select_no - 1]; + + if(n_analyze->call_part == SELECT_FROMCLAUSE) + { + ret = n_analyze->ret_count; + col_no = n_analyze->select_ret->return_list[n_analyze->ret_count]; + pool_debug("AliasToResTargetCondition select no =%d,ret_no = %d,col_no =%d,colname=%s", select_no,ret,col_no,n_analyze->select_ret->col_list[ret]); + delay_string_append_char(message, str, " AS "); + snprintf(buf, 16, "%d", col_no); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str,"\""); + delay_string_append_char(message, str," "); + return true; + } + else if(u_analyze->select_union && u_analyze->call_part == SELECT_FROMCLAUSE) + { + ret = u_analyze->ret_count; + col_no = u_analyze->select_ret->return_list[u_analyze->ret_count]; + pool_debug("AliasToResTargetCondition(union) select now=%d up=%d,ret_no = %d,col_no =%d,colname=%s", select_no,select_no-1,ret,col_no,u_analyze->select_ret->col_list[ret]); + delay_string_append_char(message, str, " AS "); + snprintf(buf, 16, "%d", col_no); + delay_string_append_char(message, str,"\"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str,"\""); + delay_string_append_char(message, str," "); + u_analyze->ret_count++; + return true; + } + else + return false; +} + +static void +_rewriteResTarget(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ResTarget *node) +{ + int select_no = message->current_select; + AnalyzeSelect *analyze = NULL; + SelectDefInfo *select = NULL; + + if(message->r_code == SELECT_DEFAULT) + { + analyze= message->analyze[select_no]; + select = analyze->select_ret; + } + + if (node->indirection != NIL) + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\"="); + _rewriteNode(BaseSelect, message, dblink, str, node->val); + } + else + { + char *star = NULL; + char *table_name = NULL; + + if(message->r_code == SELECT_DEFAULT && !node->name) + { + if (node->val && (IsA(node->val, ColumnRef))) + { + int first = 0; + ListCell *c; + ColumnRef *col; + + col = (ColumnRef *) node->val; + foreach (c, col->fields) + { + Node *n = (Node *) lfirst(c); + + if (IsA(n, String)) + { + Value *v = (Value *) lfirst(c); + if(col->fields->length == 2 && first == 0) + { + first = 1; + table_name = v->val.str; + } + else + star = v->val.str; + } + } + } + + if(star && strcmp(star,"*")) + { + star = NULL; + } + } + + if(select_no == 0 && star) + { + GetPoolColumn(message,str,table_name,star,message->current_select,-1,true); + return; + } + else + { + _rewriteNode(BaseSelect, message, dblink, str, node->val); + if(star) + return; + } + + if(AliasToResTargetCondition(message,str)) + return; + + if (node->name) + { + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, node->name); + if(message->r_code == SELECT_DEFAULT && select_no == 0) + message->ret_num++; + return; + } + else if(message->r_code == SELECT_DEFAULT && select_no == 0 + && !node->name) + { + char *col_name = select->col_list[message->ret_num]; + pool_debug("_rewriteResTarget: check(%d) ret_num=%d",message->current_select,message->ret_num); + pool_debug("_rewriteResTarget: col ret_num=%d col_name=%s",message->current_select,col_name); + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, col_name); + + message->ret_num++; + } + } +} + +static void +_rewriteConstraint(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, Constraint *node) +{ + if (node->name) + { + delay_string_append_char(message, str, "CONSTRAINT \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + } + + switch (node->contype) + { + case CONSTR_CHECK: + delay_string_append_char(message, str, " CHECK ("); + _rewriteNode(BaseSelect, message, dblink, str, node->raw_expr); + delay_string_append_char(message, str, ")"); + break; + + case CONSTR_UNIQUE: + delay_string_append_char(message, str, " UNIQUE"); + if (node->keys) + { + delay_string_append_char(message, str, "("); + _rewriteIdList(BaseSelect, message, dblink, str, node->keys); + delay_string_append_char(message, str, ")"); + } + + if (node->indexspace) + { + delay_string_append_char(message, str, " USING INDEX TABLESPACE \""); + delay_string_append_char(message, str, node->indexspace); + delay_string_append_char(message, str, "\""); + } + break; + + case CONSTR_PRIMARY: + delay_string_append_char(message, str, " PRIMARY KEY"); + if (node->keys) + { + delay_string_append_char(message, str, "("); + _rewriteIdList(BaseSelect, message, dblink, str, node->keys); + delay_string_append_char(message, str, ")"); + } + if (node->indexspace) + { + delay_string_append_char(message, str, " USING INDEX TABLESPACE \""); + delay_string_append_char(message, str, node->indexspace); + delay_string_append_char(message, str, "\""); + } + break; + + case CONSTR_NOTNULL: + delay_string_append_char(message, str, " NOT NULL"); + break; + + case CONSTR_NULL: + delay_string_append_char(message, str, " NULL"); + break; + + case CONSTR_DEFAULT: + delay_string_append_char(message, str, "DEFAULT "); + _rewriteNode(BaseSelect, message, dblink, str, node->raw_expr); + break; + + default: + break; + } +} + +static void +_rewriteFkConstraint(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FkConstraint *node) +{ + if (node->constr_name) + { + delay_string_append_char(message, str, "CONSTRAINT \""); + delay_string_append_char(message, str, node->constr_name); + delay_string_append_char(message, str, "\""); + } + + if (node->fk_attrs != NIL) + { + delay_string_append_char(message, str, " FOREIGN KEY ("); + _rewriteIdList(BaseSelect, message, dblink, str, node->fk_attrs); + delay_string_append_char(message, str, ")" ); + } + + delay_string_append_char(message, str, " REFERENCES "); + _rewriteNode(BaseSelect, message, dblink, str, node->pktable); + + if (node->pk_attrs != NIL) + { + delay_string_append_char(message, str, "("); + _rewriteIdList(BaseSelect, message, dblink, str, node->pk_attrs); + delay_string_append_char(message, str, ")"); + } + + switch (node->fk_matchtype) + { + case FKCONSTR_MATCH_FULL: + delay_string_append_char(message, str, " MATCH FULL"); + break; + + case FKCONSTR_MATCH_PARTIAL: + delay_string_append_char(message, str, " MATCH PARTIAL"); + break; + + default: + break; + } + + switch (node->fk_upd_action) + { + case FKCONSTR_ACTION_RESTRICT: + delay_string_append_char(message, str, " ON UPDATE RESTRICT"); + break; + + case FKCONSTR_ACTION_CASCADE: + delay_string_append_char(message, str, " ON UPDATE CASCADE"); + break; + + case FKCONSTR_ACTION_SETNULL: + delay_string_append_char(message, str, " ON UPDATE SET NULL"); + break; + + case FKCONSTR_ACTION_SETDEFAULT: + delay_string_append_char(message, str, " ON UPDATE SET DEFAULT"); + break; + + default: + break; + } + + switch (node->fk_del_action) + { + case FKCONSTR_ACTION_RESTRICT: + delay_string_append_char(message, str, " ON DELETE RESTRICT"); + break; + + case FKCONSTR_ACTION_CASCADE: + delay_string_append_char(message, str, " ON DELETE CASCADE"); + break; + + case FKCONSTR_ACTION_SETNULL: + delay_string_append_char(message, str, " ON DELETE SET NULL"); + break; + + case FKCONSTR_ACTION_SETDEFAULT: + delay_string_append_char(message, str, " ON DELETE SET DEFAULT"); + break; + + default: + break; + } + + if (node->deferrable) + delay_string_append_char(message, str, " DEFERRABLE"); + + if (node->initdeferred) + delay_string_append_char(message, str, " INITIALLY DEFERRED"); +} + + +static void +_rewriteSortBy(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, SortBy *node) +{ + _rewriteNode(BaseSelect, message, dblink, str, node->node); + + if (node->sortby_dir == SORTBY_USING) + { + delay_string_append_char(message, str, " USING "); + _rewriteNode(BaseSelect, message, dblink, str, node->useOp); + } + else if (node->sortby_dir == SORTBY_DESC) + delay_string_append_char(message, str, " DESC "); + + if (node->sortby_nulls == SORTBY_NULLS_FIRST) + delay_string_append_char(message, str, " NULLS FIRST "); + else if (node->sortby_nulls == SORTBY_NULLS_LAST) + delay_string_append_char(message, str, " NULLS LAST "); +} + +static void _rewriteInsertStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, InsertStmt *node) +{ + delay_string_append_char(message, str, "INSERT INTO "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (node->cols == NIL && node->selectStmt == NULL) + delay_string_append_char(message, str, " DEFAULT VALUES"); + + if (node->cols) + { + char comma = 0; + ListCell *lc; + + delay_string_append_char(message, str, "("); + + foreach (lc, node->cols) + { + ResTarget *node = lfirst(lc); + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ", "); + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + } + delay_string_append_char(message, str, ")"); + } + + if (node->selectStmt) + { + _rewriteNode(BaseSelect, message, dblink, str, node->selectStmt); + } + + if (node->returningList) + { + delay_string_append_char(message, str, " RETURNING "); + _rewriteNode(BaseSelect, message, dblink, str, node->returningList); + } +} + +static void _rewriteUpdateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, UpdateStmt *node) +{ + ListCell *lc; + char comma = 0; + + delay_string_append_char(message, str, "UPDATE "); + + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + delay_string_append_char(message, str, " SET "); + foreach (lc, node->targetList) + { + ResTarget *node = lfirst(lc); + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ", "); + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" ="); + _rewriteNode(BaseSelect, message, dblink, str, node->val); + } + + if (node->fromClause) + { + delay_string_append_char(message, str, " FROM "); + _rewriteNode(BaseSelect, message, dblink, str, node->fromClause); + } + + if (node->whereClause) + { + delay_string_append_char(message, str, " WHERE "); + _rewriteNode(BaseSelect, message, dblink, str, node->whereClause); + } + + if (node->returningList) + { + delay_string_append_char(message, str, " RETURNING "); + _rewriteNode(BaseSelect, message, dblink, str, node->returningList); + } +} + +static void _rewriteDeleteStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DeleteStmt *node) +{ + delay_string_append_char(message, str, "DELETE FROM "); + + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (node->usingClause) + { + delay_string_append_char(message, str, " USING "); + _rewriteNode(BaseSelect, message, dblink, str, node->usingClause); + } + + if (node->whereClause) + { + delay_string_append_char(message, str, " WHERE "); + _rewriteNode(BaseSelect, message, dblink, str, node->whereClause); + } + + if (node->returningList) + { + delay_string_append_char(message, str, " RETURNING "); + _rewriteNode(BaseSelect, message, dblink, str, node->returningList); + } +} + +static void _rewriteTransactionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TransactionStmt *node) +{ + switch (node->kind) + { + case TRANS_STMT_BEGIN: + delay_string_append_char(message, str, "BEGIN "); + break; + + case TRANS_STMT_START: + delay_string_append_char(message, str, "START TRANSACTION "); + break; + + case TRANS_STMT_COMMIT: + delay_string_append_char(message, str, "COMMIT "); + break; + + case TRANS_STMT_ROLLBACK: + delay_string_append_char(message, str, "ABORT "); + break; + + case TRANS_STMT_SAVEPOINT: + delay_string_append_char(message, str, "SAVEPOINT "); + break; + + case TRANS_STMT_RELEASE: + delay_string_append_char(message, str, "RELEASE "); + break; + + case TRANS_STMT_ROLLBACK_TO: + delay_string_append_char(message, str, "ROLLBACK TO "); + break; + + case TRANS_STMT_PREPARE: + delay_string_append_char(message, str, "PREPARE TRANSACTION "); + break; + + case TRANS_STMT_COMMIT_PREPARED: + delay_string_append_char(message, str, "COMMIT PREPARED "); + break; + + case TRANS_STMT_ROLLBACK_PREPARED: + delay_string_append_char(message, str, "ROLLBACK PREPARED "); + break; + + default: + break; + } + + if (node->options) + _rewriteSetTransactionModeList(BaseSelect, message, dblink, str, node->options); + + if (node->gid) + delay_string_append_char(message, str, node->gid); +} + + +static void _rewriteTruncateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, TruncateStmt *node) +{ + delay_string_append_char(message, str, "TRUNCATE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relations); +} + +static void _rewriteVacuumStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VacuumStmt *node) +{ + if (node->vacuum == true) + delay_string_append_char(message, str, "VACUUM "); + else + delay_string_append_char(message, str, "ANALYZE "); + + if (node->full == TRUE) + delay_string_append_char(message, str, "FULL "); + + if (node->freeze_min_age == 0) + delay_string_append_char(message, str, "FREEZE "); + + if (node->verbose == TRUE) + delay_string_append_char(message, str, "VERBOSE "); + + if (node->analyze) + delay_string_append_char(message, str, "ANALYZE "); + + _rewriteNode(BaseSelect, message, dblink, str, node->va_cols); +} + +static void _rewriteExplainStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ExplainStmt *node) +{ + delay_string_append_char(message, str, "EXPLAIN "); + + if (node->analyze == TRUE) + delay_string_append_char(message, str, "ANALYZE "); + if (node->verbose == TRUE) + delay_string_append_char(message, str, "VERBOSE "); + + _rewriteNode(BaseSelect, message, dblink, str, node->query); +} + +static void _rewriteClusterStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ClusterStmt *node) +{ + delay_string_append_char(message, str, "CLUSTER "); + + if (node->indexname) + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->indexname); + delay_string_append_char(message, str, "\" ON "); + } + if (node->relation) + _rewriteNode(BaseSelect, message, dblink, str, node->relation); +} + +static void _rewriteCheckPointStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CheckPointStmt *node) +{ + delay_string_append_char(message, str, "CHECKPOINT"); +} + +static void _rewriteClosePortalStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ClosePortalStmt *node) +{ + delay_string_append_char(message, str, "CLOSE "); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->portalname); + delay_string_append_char(message, str, "\""); +} + +static void _rewriteListenStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ListenStmt *node) +{ + delay_string_append_char(message, str, "LISTEN "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); +} + +static void _rewriteUnlistenStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, UnlistenStmt *node) +{ + delay_string_append_char(message, str, "UNLISTEN "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); +} + +static void _rewriteLoadStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, LoadStmt *node) +{ + delay_string_append_char(message, str, "LOAD '"); + delay_string_append_char(message, str, node->filename); + delay_string_append_char(message, str, "'"); +} + +static void _rewriteCopyStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CopyStmt *node) +{ + int binary = FALSE; + int oids = FALSE; + char *delimiter = NULL; + char *null = NULL; + int csv = FALSE; + int header = FALSE; + char *quote = NULL; + char *escape = NULL; + Node *force_quote = NULL; + Node *force_notnull = NULL; + ListCell *lc; + + foreach (lc, node->attlist) + { + DefElem *e = lfirst(lc); + + if (strcmp(e->defname, "binary") == 0) + binary = TRUE; + else if (strcmp(e->defname, "oids") == 0) + oids = TRUE; + else if (strcmp(e->defname, "delimiter") == 0) + delimiter = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "null") == 0) + null = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "csv") == 0) + csv = TRUE; + else if (strcmp(e->defname, "header") == 0) + header = TRUE; + else if (strcmp(e->defname, "quote") == 0) + quote = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "escape") == 0) + escape = ((Value *) e->arg)->val.str; + else if (strcmp(e->defname, "force_quote") == 0) + force_quote = e->arg; + else if (strcmp(e->defname, "force_notnull") == 0) + force_notnull = e->arg; + } + + delay_string_append_char(message, str, "COPY "); + + if (node->query) + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->query); + delay_string_append_char(message, str, ")"); + } + + if (binary == TRUE) + delay_string_append_char(message, str, "BINARY "); + + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (node->attlist) + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->attlist); + delay_string_append_char(message, str, ") "); + } + + if (oids == TRUE) + delay_string_append_char(message, str, " OIDS "); + + if (node->is_from == TRUE) + delay_string_append_char(message, str, " FROM "); + else + delay_string_append_char(message, str, " TO "); + + if (node->filename) + { + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, node->filename); + delay_string_append_char(message, str, "'"); + } + else + delay_string_append_char(message, str, node->is_from == TRUE ? "STDIN" : "STDOUT"); + + if (delimiter) + { + delay_string_append_char(message, str, " DELIMITERS '"); + delay_string_append_char(message, str, delimiter); + delay_string_append_char(message, str, "'"); + } + + if (null) + { + delay_string_append_char(message, str, "NULL '"); + delay_string_append_char(message, str, null); + delay_string_append_char(message, str, "' "); + } + + if (csv == TRUE) + delay_string_append_char(message, str, "CSV "); + + if (header == TRUE) + delay_string_append_char(message, str, "HEADER "); + + if (quote) + { + delay_string_append_char(message, str, "QUOTE '"); + delay_string_append_char(message, str, quote); + delay_string_append_char(message, str, "' "); + } + + if (escape) + { + delay_string_append_char(message, str, "ESCAPE '"); + delay_string_append_char(message, str, escape); + delay_string_append_char(message, str, "' "); + } + + if (force_quote) + { + delay_string_append_char(message, str, "FORCE QUOTE "); + _rewriteNode(BaseSelect, message, dblink, str, force_quote); + } + + if (force_notnull) + { + delay_string_append_char(message, str, " FORCE NOT NULL "); + _rewriteNode(BaseSelect, message, dblink, str, force_notnull); + } +} + +static void _rewriteDeallocateStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DeallocateStmt *node) +{ + delay_string_append_char(message, str, "DEALLOCATE \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); +} + +static void _rewriteRenameStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RenameStmt *node) +{ + ListCell *lc; + char comma = 0; + + delay_string_append_char(message, str, "ALTER "); + + switch (node->renameType) + { + case OBJECT_AGGREGATE: + delay_string_append_char(message, str, "AGGREGATE "); + _rewriteNode(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " ("); + delay_string_append_char(message, str, ") RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_CONVERSION: + delay_string_append_char(message, str, "CONVERSION "); + _rewriteNode(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_DATABASE: + delay_string_append_char(message, str, "DATABASE \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_FUNCTION: + delay_string_append_char(message, str, "FUNCTION "); + + foreach (lc, node->object) + { + Node *n = lfirst(lc); + if (IsA(n, String)) + { + Value *value = (Value *) n; + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, "."); + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, value->val.str); + delay_string_append_char(message, str, "\""); + } + else + _rewriteNode(BaseSelect, message, dblink, str, n); + } + + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->objarg); + delay_string_append_char(message, str, ")"); + delay_string_append_char(message, str, " RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_ROLE: + delay_string_append_char(message, str, "ROLE \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_LANGUAGE: + delay_string_append_char(message, str, "LANGUAGE \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_OPCLASS: + delay_string_append_char(message, str, "OPERATOR CLASS "); + _rewriteNode(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " USING "); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, " RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_SCHEMA: + delay_string_append_char(message, str, "SCHEMA \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TABLE: + delay_string_append_char(message, str, "TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_INDEX: + delay_string_append_char(message, str, "INDEX "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_COLUMN: + delay_string_append_char(message, str, "TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " RENAME \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TRIGGER: + delay_string_append_char(message, str, "TRIGGER \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" ON "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TABLESPACE: + delay_string_append_char(message, str, "TABLESPACE \""); + delay_string_append_char(message, str, node->subname); + delay_string_append_char(message, str, "\" RENAME TO \""); + delay_string_append_char(message, str, node->newname); + delay_string_append_char(message, str, "\""); + break; + + default: + break; + } +} + +static void +_rewriteOptRoleList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *options) +{ + ListCell *lc; + + foreach (lc, options) + { + DefElem *elem = lfirst(lc); + Value *value = (Value *) elem->arg; + + if (strcmp(elem->defname, "password") == 0) + { + if (value == NULL) + delay_string_append_char(message, str, " PASSWORD NULL"); + else + { + delay_string_append_char(message, str, " PASSWORD '"); + delay_string_append_char(message, str, value->val.str); + delay_string_append_char(message, str, "'"); + } + } + else if (strcmp(elem->defname, "encryptedPassword") == 0) + { + delay_string_append_char(message, str, " ENCRYPTED PASSWORD '"); + delay_string_append_char(message, str, value->val.str); + delay_string_append_char(message, str, "'"); + } + else if (strcmp(elem->defname, "unencryptedPassword") == 0) + { + delay_string_append_char(message, str, " UNENCRYPTED PASSWORD '"); + delay_string_append_char(message, str, value->val.str); + delay_string_append_char(message, str, "'"); + } + else if (strcmp(elem->defname, "superuser") == 0) + { + if (value->val.ival == TRUE) + delay_string_append_char(message, str, " SUPERUSER"); + else + delay_string_append_char(message, str, " NOSUPERUSER"); + } + else if (strcmp(elem->defname, "inherit") == 0) + { + if (value->val.ival == TRUE) + delay_string_append_char(message, str, " INHERIT"); + else + delay_string_append_char(message, str, " NOINHERIT"); + } + else if (strcmp(elem->defname, "createdb") == 0) + { + if (value->val.ival == TRUE) + delay_string_append_char(message, str, " CREATEDB"); + else + delay_string_append_char(message, str, " NOCREATEDB"); + } + else if (strcmp(elem->defname, "createrole") == 0) + { + if (value->val.ival == TRUE) + delay_string_append_char(message, str, " CREATEROLE"); + else + delay_string_append_char(message, str, " NOCREATEROLE"); + } + else if (strcmp(elem->defname, "canlogin") == 0) + { + if (value->val.ival == TRUE) + delay_string_append_char(message, str, " LOGIN"); + else + delay_string_append_char(message, str, " NOLOGIN"); + } + else if (strcmp(elem->defname, "connectionlimit") == 0) + { + char buf[16]; + + delay_string_append_char(message, str, " CONNECTION LIMIT "); + snprintf(buf, 16, "%ld", value->val.ival); + delay_string_append_char(message, str, buf); + } + else if (strcmp(elem->defname, "validUntil") == 0) + { + delay_string_append_char(message, str, " VALID UNTIL '"); + delay_string_append_char(message, str, value->val.str); + delay_string_append_char(message, str, "'"); + } + else if (strcmp(elem->defname, "rolemembers") == 0) + { + delay_string_append_char(message, str, " ROLE "); + _rewriteIdList(BaseSelect, message, dblink, str, (List *) elem->arg); + } + else if (strcmp(elem->defname, "sysid") == 0) + { + char buf[16]; + + delay_string_append_char(message, str, " SYSID "); + snprintf(buf, 16, "%ld", value->val.ival); + delay_string_append_char(message, str, buf); + } + else if (strcmp(elem->defname, "adminmembers") == 0) + { + delay_string_append_char(message, str, " ADMIN "); + _rewriteIdList(BaseSelect, message, dblink, str, (List *) elem->arg); + } + else if (strcmp(elem->defname, "addroleto") == 0) + { + delay_string_append_char(message, str, " IN ROLE "); + _rewriteIdList(BaseSelect, message, dblink, str, (List *) elem->arg); + } + } +} + +static void +_rewriteCreateRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateRoleStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + switch (node->stmt_type) + { + case ROLESTMT_ROLE: + delay_string_append_char(message, str, "ROLE \""); + break; + + case ROLESTMT_USER: + delay_string_append_char(message, str, "USER \""); + break; + + case ROLESTMT_GROUP: + delay_string_append_char(message, str, "GROUP \""); + break; + } + delay_string_append_char(message, str, node->role); + delay_string_append_char(message, str, "\""); + + _rewriteOptRoleList(BaseSelect, message, dblink, str, node->options); +} + +static void +_rewriteAlterRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterRoleStmt *node) +{ + delay_string_append_char(message, str, "ALTER ROLE \""); + delay_string_append_char(message, str, node->role); + delay_string_append_char(message, str, "\""); + if (node->options) + _rewriteOptRoleList(BaseSelect, message, dblink, str, node->options); +} + +static void +_rewriteAlterRoleSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterRoleSetStmt *node) +{ + delay_string_append_char(message, str, "ALTER ROLE \""); + delay_string_append_char(message, str, node->role); + delay_string_append_char(message, str, "\" "); + + if (node->setstmt) + { + _rewriteNode(BaseSelect, message, dblink, str, node->setstmt); + } +} + + +static void +_rewriteSetTransactionModeList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list) +{ + ListCell *lc; + char comma = 0; + + foreach (lc, list) + { + DefElem *elem = lfirst(lc); + + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ","); + + if (strcmp(elem->defname, "transaction_isolation") == 0) + { + A_Const *v = (A_Const *) elem->arg; + delay_string_append_char(message, str, " ISOLATION LEVEL "); + delay_string_append_char(message, str, v->val.val.str); + } + else if (strcmp(elem->defname, "transaction_read_only") == 0) + { + A_Const *n = (A_Const *) elem->arg; + if (n->val.val.ival == TRUE) + delay_string_append_char(message, str, "READ ONLY "); + else + delay_string_append_char(message, str, "READ WRITE "); + } + } +} + + +static void +_rewriteSetRest(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VariableSetStmt *node) +{ + if (strcmp(node->name, "timezone") == 0) + { + delay_string_append_char(message, str, "TIME ZONE "); + if (node->kind != VAR_RESET) + _rewriteNode(BaseSelect, message, dblink, str, node->args); + } + else if (strcmp(node->name, "TRANSACTION") == 0) + { + delay_string_append_char(message, str, "TRANSACTION "); + _rewriteSetTransactionModeList(BaseSelect, message, dblink, str, node->args); + } + else if (strcmp(node->name, "SESSION CHARACTERISTICS") == 0) + { + delay_string_append_char(message, str, "SESSION CHARACTERISTICS AS TRANSACTION "); + _rewriteSetTransactionModeList(BaseSelect, message, dblink, str, node->args); + } + else if (strcmp(node->name, "role") == 0) + { + delay_string_append_char(message, str, "ROLE "); + if (node->kind != VAR_RESET) + _rewriteNode(BaseSelect, message, dblink, str, node->args); + } + else if (strcmp(node->name, "session_authorization") == 0) + { + delay_string_append_char(message, str, "SESSION AUTHORIZATION "); + if (node->args == NIL && node->kind != VAR_RESET) + delay_string_append_char(message, str, "DEFAULT"); + else + _rewriteNode(BaseSelect, message, dblink, str, node->args); + } + else if (strcmp(node->name, "transaction_isolation") == 0) + { + delay_string_append_char(message, str, "TRANSACTION ISOLATION LEVEL"); + if (node->kind != VAR_RESET) + _rewriteSetTransactionModeList(BaseSelect, message, dblink, str, node->args); + } + else if (strcmp(node->name, "xmloption") == 0) + { + A_Const *v = linitial(node->args); + delay_string_append_char(message, str, "XML OPTOIN "); + delay_string_append_char(message, str, v->val.val.str); + } + else + { + delay_string_append_char(message, str, node->name); + if (node->kind != VAR_RESET) + { + if (node->kind == VAR_SET_CURRENT) + { + delay_string_append_char(message, str, " FROM CURRENT"); + } + else + { + delay_string_append_char(message, str, " TO "); + if (node->args == NULL) + { + delay_string_append_char(message, str, "DEFAULT"); + } + else + _rewriteNode(BaseSelect, message, dblink, str, node->args); + } + } + } +} + +static void +_rewriteDropRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropRoleStmt *node) +{ + delay_string_append_char(message, str, "DROP ROLE "); + if (node->missing_ok == TRUE) + delay_string_append_char(message, str, "IF EXISTS "); + _rewriteIdList(BaseSelect, message, dblink, str, node->roles); +} + +static void +_rewriteCreateSchemaStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateSchemaStmt *node) +{ + delay_string_append_char(message, str, "CREATE SCHEMA \""); + delay_string_append_char(message, str, node->schemaname); + delay_string_append_char(message, str, "\""); + if (node->authid) + { + delay_string_append_char(message, str, "AUTHORIZATION \""); + delay_string_append_char(message, str, node->authid); + delay_string_append_char(message, str, "\" "); + } + _rewriteNode(BaseSelect, message, dblink, str, node->schemaElts); +} + +static void +_rewriteVariableSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VariableSetStmt *node) +{ + if (node->kind == VAR_RESET_ALL) + { + delay_string_append_char(message, str, "RESET ALL"); + return; + } + + if (node->kind == VAR_RESET) + delay_string_append_char(message, str, "RESET "); + else + delay_string_append_char(message, str, "SET "); + + if (node->is_local) + delay_string_append_char(message, str, "LOCAL "); + + _rewriteSetRest(BaseSelect, message, dblink, str, node); +} + +static void +_rewriteVariableShowStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, VariableShowStmt *node) +{ + if (strcmp(node->name, "timezone") == 0) + delay_string_append_char(message, str, "SHOW TIME ZONE"); + else if (strcmp(node->name, "transaction_isolation") == 0) + delay_string_append_char(message, str, "SHOW TRANSACTION ISOLATION LEVEL"); + else if (strcmp(node->name, "session_authorization") == 0) + delay_string_append_char(message, str, "SHOW SESSION AUTHORIZATION"); + else if (strcmp(node->name, "all") == 0) + delay_string_append_char(message, str, "SHOW ALL"); + else + { + delay_string_append_char(message, str, "SHOW "); + delay_string_append_char(message, str, node->name); + } +} + +static void +_rewriteConstraintsSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ConstraintsSetStmt *node) +{ + delay_string_append_char(message, str, "SET CONSTRAINTS "); + + if (node->constraints == NIL) + delay_string_append_char(message, str, "ALL"); + else + _rewriteNode(BaseSelect, message, dblink, str, node->constraints); + + delay_string_append_char(message, str, node->deferred == TRUE ? " DEFERRED" : " IMMEDIATE"); +} + +static void +_rewriteAlterTableCmd(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterTableCmd *node) +{ + char buf[16]; + + switch (node->subtype) + { + case AT_AddColumn: + delay_string_append_char(message, str, "ADD "); + _rewriteNode(BaseSelect, message, dblink, str, node->def); + break; + + case AT_ColumnDefault: + delay_string_append_char(message, str, "ALTER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" "); + if (node->def == NULL) + delay_string_append_char(message, str, "DROP DEFAULT"); + else + { + delay_string_append_char(message, str, "SET DEFAULT "); + _rewriteNode(BaseSelect, message, dblink, str, node->def); + } + break; + + case AT_DropNotNull: + delay_string_append_char(message, str, "ALTER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" DROP NOT NULL"); + break; + + case AT_SetNotNull: + delay_string_append_char(message, str, "ALTER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" SET NOT NULL"); + break; + + case AT_SetStatistics: + delay_string_append_char(message, str, "ALTER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" SET STATISTICS "); + snprintf(buf, 16, "%ld", ((Value *) node->def)->val.ival); + delay_string_append_char(message, str, buf); + break; + + case AT_SetStorage: + delay_string_append_char(message, str, "ALTER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" SET STORAGE "); + delay_string_append_char(message, str, ((Value *) node->def)->val.str); + break; + + case AT_DropColumn: + delay_string_append_char(message, str, "DROP \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" "); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, "CASCADE"); + break; + + case AT_AlterColumnType: + delay_string_append_char(message, str, "ALTER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" TYPE "); + _rewriteNode(BaseSelect, message, dblink, str, node->def); + if (node->transform) + { + delay_string_append_char(message, str, " USING "); + _rewriteNode(BaseSelect, message, dblink, str, node->transform); + } + break; + + case AT_AddConstraint: + delay_string_append_char(message, str, "ADD "); + _rewriteNode(BaseSelect, message, dblink, str, node->def); + break; + + case AT_DropConstraint: + delay_string_append_char(message, str, "DROP CONSTRAINT \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); + break; + + case AT_DropOids: + delay_string_append_char(message, str, "SET WITHOUT OIDS"); + break; + + case AT_ClusterOn: + delay_string_append_char(message, str, "CLUSTER ON \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + break; + + case AT_EnableAlwaysTrig: + /* not implemented */ + break; + + case AT_EnableReplicaTrig: + /* not implemented */ + break; + + case AT_DropCluster: + delay_string_append_char(message, str, "SET WITHOUT CLUSTER"); + break; + + case AT_EnableTrig: + delay_string_append_char(message, str, "ENABLE TRIGGER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + break; + + case AT_EnableTrigAll: + delay_string_append_char(message, str, "ENABLE TRIGGER ALL"); + break; + + case AT_EnableRule: + /* not implemented */ + break; + + case AT_EnableReplicaRule: + /* not implemented */ + break; + + case AT_EnableAlwaysRule: + /* not implemented */ + break; + + case AT_DisableRule: + /* not implemented */ + break; + + case AT_AddInherit: + /* not implemented */ + break; + + case AT_EnableTrigUser: + delay_string_append_char(message, str, "ENABLE TRIGGER USER"); + break; + + case AT_DisableTrig: + delay_string_append_char(message, str, "DISABLE TRIGGER \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + break; + + case AT_DisableTrigAll: + delay_string_append_char(message, str, "DISABLE TRIGGER ALL"); + break; + + case AT_DisableTrigUser: + delay_string_append_char(message, str, "DISABLE TRIGGER USER"); + break; + + case AT_ChangeOwner: + delay_string_append_char(message, str, "OWNER TO \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + break; + + case AT_SetTableSpace: + delay_string_append_char(message, str, "SET TABLESPACE \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + break; + + case AT_SetRelOptions: + /* not implemented */ + break; + + case AT_ResetRelOptions: + /* not implemented */ + break; + + default: + break; + } +} + +static void +_rewriteAlterTableStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterTableStmt *node) +{ + if (node->relkind == OBJECT_TABLE) + delay_string_append_char(message, str, "ALTER TABLE "); + else + delay_string_append_char(message, str, "ALTER INDEX "); + + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " "); + _rewriteNode(BaseSelect, message, dblink, str, node->cmds); +} + +static void +_rewriteOptSeqList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *options) +{ + ListCell *lc; + + foreach (lc, options) + { + DefElem *e = lfirst(lc); + Value *v = (Value *)e->arg; + char buf[16]; + + if (strcmp(e->defname, "cycle") == 0) + { + if (v->val.ival == TRUE) + delay_string_append_char(message, str, " CYCLE"); + else + delay_string_append_char(message, str, " NO CYCLE"); + } + else if (strcmp(e->defname, "minvalue") == 0 && !v) + delay_string_append_char(message, str, " NO MINVALUE"); + else if (strcmp(e->defname, "maxvalue") == 0 && !v) + delay_string_append_char(message, str, " NO MAXVALUE"); + else if (strcmp(e->defname, "owned_by") == 0) + { + delay_string_append_char(message, str, " OWNED BY "); + _rewriteIdList(BaseSelect, message, dblink, str, (List *)e->arg); + } + else + { + if (strcmp(e->defname, "cache") == 0) + delay_string_append_char(message, str, " CACHE "); + else if (strcmp(e->defname, "increment") == 0) + delay_string_append_char(message, str, " INCREMENT "); + else if (strcmp(e->defname, "maxvalue") == 0 && v) + delay_string_append_char(message, str, " MAXVALUE "); + else if (strcmp(e->defname, "minvalue") == 0 && v) + delay_string_append_char(message, str, " MINVALUE "); + else if (strcmp(e->defname, "start") == 0) + delay_string_append_char(message, str, " START "); + else if (strcmp(e->defname, "restart") == 0) + delay_string_append_char(message, str, " RESTART "); + + if (IsA(e->arg, String)) + delay_string_append_char(message, str, v->val.str); + else + { + snprintf(buf, 16, "%ld", v->val.ival); + delay_string_append_char(message, str, buf); + } + } + } +} + +static void +_rewriteCreateSeqStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateSeqStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + if (node->sequence->istemp) + delay_string_append_char(message, str, "TEMP "); + delay_string_append_char(message, str, "SEQUENCE "); + _rewriteNode(BaseSelect, message, dblink, str, node->sequence); + + _rewriteOptSeqList(BaseSelect, message, dblink, str, node->options); +} + +static void +_rewriteAlterSeqStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterSeqStmt *node) +{ + delay_string_append_char(message, str, "ALTER SEQUENCE "); + _rewriteNode(BaseSelect, message, dblink, str, node->sequence); + _rewriteOptSeqList(BaseSelect, message, dblink, str, node->options); +} + +static void +_rewriteCreatePLangStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreatePLangStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + if (node->pltrusted == true) + delay_string_append_char(message, str, "TRUSTED "); + delay_string_append_char(message, str, "LANGUAGE \""); + delay_string_append_char(message, str, node->plname); + delay_string_append_char(message, str, "\""); + + if (node->plhandler != NIL) + { + ListCell *lc; + char dot = 0; + + delay_string_append_char(message, str, " HANDLER "); + foreach (lc, node->plhandler) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + delay_string_append_char(message, str, "."); + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "\""); + } + } + + if (node->plvalidator != NIL) + { + ListCell *lc; + char dot = 0; + + delay_string_append_char(message, str, " VALIDATOR "); + foreach (lc, node->plvalidator) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + delay_string_append_char(message, str, "."); + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "\""); + } + } +} + +static void +_rewriteDropPLangStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropPLangStmt *node) +{ + delay_string_append_char(message, str, "DROP LANGUAGE \""); + delay_string_append_char(message, str, node->plname); + delay_string_append_char(message, str, "\""); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); +} + +static void +_rewriteCreateTableSpaceStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateTableSpaceStmt *node) +{ + delay_string_append_char(message, str, "CREATE TABLESPACE \""); + delay_string_append_char(message, str, node->tablespacename); + delay_string_append_char(message, str, "\" "); + + if (node->owner) + { + delay_string_append_char(message, str, "OWNER \""); + delay_string_append_char(message, str, node->owner); + delay_string_append_char(message, str, "\" "); + } + + delay_string_append_char(message, str, "LOCATION '"); + delay_string_append_char(message, str, node->location); + delay_string_append_char(message, str, "'"); +} + +static void +_rewriteDropTableSpaceStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropTableSpaceStmt *node) +{ + delay_string_append_char(message, str, "DROP TABLESPACE \""); + delay_string_append_char(message, str, node->tablespacename); + delay_string_append_char(message, str, "\""); +} + +static void +_rewriteFuncName(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *func_name) +{ + ListCell *lc; + Value *v; + char dot = 0; + + if (func_name == NULL) + return; + + foreach (lc, func_name) + { + v = (Value *) lfirst(lc); + + if (dot == 0) + dot = 1; + else + delay_string_append_char(message, str, "."); + + if (IsA(v, String)) + { + //delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, v->val.str); + //delay_string_append_char(message, str, "\""); + } + else + { + } + } +} + +static void +_rewriteCreateTrigStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateTrigStmt *node) +{ + int i, len; + + if (node->isconstraint == TRUE) + delay_string_append_char(message, str, "CREATE CONSTRAINT TRIGGER \""); + else + delay_string_append_char(message, str, "CREATE TRIGGER \""); + delay_string_append_char(message, str, node->trigname); + delay_string_append_char(message, str, "\" "); + + if (node->before == TRUE) + delay_string_append_char(message, str, "BEFORE "); + else + delay_string_append_char(message, str, "AFTER "); + + len = strlen(node->actions); + for (i = 0; i < len; i++) + { + if (i) + delay_string_append_char(message, str, "OR "); + + if (node->actions[i] == 'i') + delay_string_append_char(message, str, "INSERT "); + else if (node->actions[i] == 'd') + delay_string_append_char(message, str, "DELETE "); + else + delay_string_append_char(message, str, "UPDATE "); + } + + delay_string_append_char(message, str, "ON "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (node->constrrel) + { + delay_string_append_char(message, str, " FROM "); + _rewriteNode(BaseSelect, message, dblink, str, node->constrrel); + } + + if (node->deferrable) + delay_string_append_char(message, str, " DEFERRABLE"); + if (node->initdeferred) + delay_string_append_char(message, str, " INITIALLY DEFERRED"); + + if (node->row == TRUE) + delay_string_append_char(message, str, " FOR EACH ROW "); + else + delay_string_append_char(message, str, " FOR EACH STATEMENT "); + + delay_string_append_char(message, str, "EXECUTE PROCEDURE "); + + _rewriteFuncName(BaseSelect, message, dblink, str, node->funcname); + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); +} + +static void +_rewriteDropPropertyStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropPropertyStmt *node) +{ + switch (node->removeType) + { + case OBJECT_TRIGGER: + delay_string_append_char(message, str, "DROP TRIGGER \""); + delay_string_append_char(message, str, node->property); + delay_string_append_char(message, str, "\" ON "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); + break; + + case OBJECT_RULE: + delay_string_append_char(message, str, "DROP RULE \""); + delay_string_append_char(message, str, node->property); + delay_string_append_char(message, str, "\" ON "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); + break; + + default: + break; + } +} + +static void +_rewriteDefinition(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *definition) +{ + ListCell *lc; + char comma = 0; + + if (definition == NIL) + return; + + delay_string_append_char(message, str, "("); + foreach (lc, definition) + { + DefElem *e = lfirst(lc); + + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ", "); + + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, e->defname); + delay_string_append_char(message, str, "\""); + + if (e->arg) + { + delay_string_append_char(message, str, "="); + _rewriteNode(BaseSelect, message, dblink, str, e->arg); + } + } + delay_string_append_char(message, str, ")"); +} + +static void +_rewriteDefineStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DefineStmt *node) +{ + ListCell *lc; + char dot = 0; + + switch (node->kind) + { + case OBJECT_AGGREGATE: + delay_string_append_char(message, str, "CREATE AGGREGATE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->defnames); + delay_string_append_char(message, str, " "); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + case OBJECT_OPERATOR: + delay_string_append_char(message, str, "CREATE OPERATOR "); + + foreach (lc, node->defnames) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + delay_string_append_char(message, str, "."); + + delay_string_append_char(message, str, v->val.str); + } + + delay_string_append_char(message, str, " "); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + case OBJECT_TYPE: + delay_string_append_char(message, str, "CREATE TYPE"); + _rewriteFuncName(BaseSelect, message, dblink, str, node->defnames); + delay_string_append_char(message, str, " "); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + case OBJECT_TSPARSER: + delay_string_append_char(message, str, "CREATE TEXT SEARCH PARSER "); + _rewriteIdList(BaseSelect, message, dblink, str, node->defnames); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + case OBJECT_TSDICTIONARY: + delay_string_append_char(message, str, "CREATE TEXT SEARCH DICTIONARY "); + _rewriteIdList(BaseSelect, message, dblink, str, node->defnames); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + case OBJECT_TSTEMPLATE: + delay_string_append_char(message, str, "CREATE TEXT SEARCH TEMPLATE "); + _rewriteIdList(BaseSelect, message, dblink, str, node->defnames); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + case OBJECT_TSCONFIGURATION: + delay_string_append_char(message, str, "CREATE TEXT SEARCH CONFIGURATION "); + _rewriteIdList(BaseSelect, message, dblink, str, node->defnames); + _rewriteDefinition(BaseSelect, message, dblink, str, node->definition); + break; + + default: + break; + } +} + +static void +_rewriteOperatorName(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list) +{ + char dot = 0; + ListCell *lc; + + foreach (lc, list) + { + Value *v = lfirst(lc); + + if (dot == 0) + dot = 1; + else + delay_string_append_char(message, str, "."); + + delay_string_append_char(message, str, v->val.str); + } +} + +static void +_rewriteCreateOpClassItem(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateOpClassItem *node) +{ + char buf[16]; + + switch (node->itemtype) + { + case OPCLASS_ITEM_OPERATOR: + delay_string_append_char(message, str, "OPERATOR "); + snprintf(buf, 16, "%d", node->number); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + _rewriteOperatorName(BaseSelect, message, dblink, str, node->name); + + if (node->args != NIL) + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); + } + if (node->recheck == TRUE) + delay_string_append_char(message, str, " RECHECK"); + break; + + case OPCLASS_ITEM_FUNCTION: + delay_string_append_char(message, str, "FUNCTION "); + snprintf(buf, 16, "%d", node->number); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->name); + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); + break; + + case OPCLASS_ITEM_STORAGETYPE: + delay_string_append_char(message, str, "STORAGE "); + _rewriteNode(BaseSelect, message, dblink, str, node->storedtype); + break; + + default: + break; + } + +} + +static void +_rewriteCreateOpClassStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateOpClassStmt *node) +{ + delay_string_append_char(message, str, "CREATE OPERATOR CLASS "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->opclassname); + + if (node->isDefault == TRUE) + delay_string_append_char(message, str, " DEFAULT"); + + delay_string_append_char(message, str, " FOR TYPE "); + _rewriteNode(BaseSelect, message, dblink, str, node->datatype); + delay_string_append_char(message, str, " USING "); + delay_string_append_char(message, str, node->amname); + delay_string_append_char(message, str, " AS "); + _rewriteNode(BaseSelect, message, dblink, str, node->items); +} + +static void +_rewriteRemoveOpClassStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RemoveOpClassStmt *node) +{ + delay_string_append_char(message, str, "DROP OPERATOR CLASS "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->opclassname); + delay_string_append_char(message, str, " USING "); + delay_string_append_char(message, str, node->amname); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); +} + +static void +_rewriteDropStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropStmt *node) +{ + ListCell *lc; + char comma = 0; + + delay_string_append_char(message, str, "DROP "); + switch (node->removeType) + { + case OBJECT_TABLE: + delay_string_append_char(message, str, "TABLE "); + break; + + case OBJECT_SEQUENCE: + delay_string_append_char(message, str, "SEQUENCE "); + break; + + case OBJECT_VIEW: + delay_string_append_char(message, str, "VIEW "); + break; + + case OBJECT_INDEX: + delay_string_append_char(message, str, "INDEX "); + break; + + case OBJECT_TYPE: + delay_string_append_char(message, str, "TYPE "); + break; + + case OBJECT_DOMAIN: + delay_string_append_char(message, str, "DOMAIN "); + break; + + case OBJECT_CONVERSION: + delay_string_append_char(message, str, "CONVERSION "); + break; + + case OBJECT_SCHEMA: + delay_string_append_char(message, str, "SCHEMA "); + break; + + default: + break; + } + + foreach (lc, node->objects) + { + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ", "); + _rewriteFuncName(BaseSelect, message, dblink, str, lfirst(lc)); + } + + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); +} + +static void +_rewriteFetchStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FetchStmt *node) +{ + char buf[16]; + + snprintf(buf, 16, "%ld", node->howMany); + + if (node->ismove == TRUE) + delay_string_append_char(message, str, "MOVE "); + else + delay_string_append_char(message, str, "FETCH "); + + switch (node->direction) + { + case FETCH_FORWARD: + delay_string_append_char(message, str, "FORWARD "); + if (node->howMany == FETCH_ALL) + delay_string_append_char(message, str, "ALL "); + else + { + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + } + break; + + case FETCH_BACKWARD: + delay_string_append_char(message, str, "BACKWARD "); + if (node->howMany == FETCH_ALL) + delay_string_append_char(message, str, "ALL "); + else + { + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + } + break; + + case FETCH_ABSOLUTE: + if (node->howMany == 1) + delay_string_append_char(message, str, "FIRST "); + else if (node->howMany == -1) + delay_string_append_char(message, str, "LAST "); + else + { + delay_string_append_char(message, str, "ABSOLUTE "); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + } + break; + + case FETCH_RELATIVE: + delay_string_append_char(message, str, "RELATIVE "); + delay_string_append_char(message, str, buf); + delay_string_append_char(message, str, " "); + break; + } + + delay_string_append_char(message, str, "IN \""); + delay_string_append_char(message, str, node->portalname); + delay_string_append_char(message, str, "\""); +} + +static void +_rewritePrivilegeList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list) +{ + ListCell *lc; + char comma = 0; + + if (list == NIL) + delay_string_append_char(message, str, "ALL"); + else + { + foreach (lc, list) + { + Value *v = lfirst(lc); + + if (comma == 0) + comma = 1; + else + delay_string_append_char(message, str, ", "); + + delay_string_append_char(message, str, v->val.str); + } + } +} + +static void +_rewriteFunctionParameter(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FunctionParameter *node) +{ + switch (node->mode) + { + case FUNC_PARAM_OUT: + delay_string_append_char(message, str, "OUT "); + break; + + case FUNC_PARAM_INOUT: + delay_string_append_char(message, str, "INOUT "); + break; + + default: + break; + } + + /* function name */ + if (node->name) + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" "); + } + + _rewriteNode(BaseSelect, message, dblink, str, node->argType); +} + +static void +_rewriteFuncWithArgs(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, FuncWithArgs *node) +{ + _rewriteFuncName(BaseSelect, message, dblink, str, node->funcname); + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->funcargs); + delay_string_append_char(message, str, ")"); +} + +static void +_rewritePrivTarget(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, PrivTarget *node) +{ + switch (node->objtype) + { + case ACL_OBJECT_RELATION: + _rewriteNode(BaseSelect, message, dblink, str, node->objs); + break; + + case ACL_OBJECT_SEQUENCE: + delay_string_append_char(message, str, "SEQUENCE "); + _rewriteNode(BaseSelect, message, dblink, str, node->objs); + break; + + case ACL_OBJECT_FUNCTION: + delay_string_append_char(message, str, "FUNCTION "); + _rewriteNode(BaseSelect, message, dblink, str, node->objs); + break; + + case ACL_OBJECT_DATABASE: + delay_string_append_char(message, str, "DATABASE "); + _rewriteIdList(BaseSelect, message, dblink, str, node->objs); + break; + + case ACL_OBJECT_LANGUAGE: + delay_string_append_char(message, str, "LANGUAGE "); + _rewriteIdList(BaseSelect, message, dblink, str, node->objs); + break; + + case ACL_OBJECT_NAMESPACE: + delay_string_append_char(message, str, "SCHEMA "); + _rewriteIdList(BaseSelect, message, dblink, str, node->objs); + break; + + case ACL_OBJECT_TABLESPACE: + delay_string_append_char(message, str, "TABLESPACE "); + _rewriteIdList(BaseSelect, message, dblink, str, node->objs); + break; + } +} + +static void +_rewritePrivGrantee(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, PrivGrantee *node) +{ + if (node->rolname == NULL) + delay_string_append_char(message, str, "PUBLIC"); + else + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, node->rolname); + delay_string_append_char(message, str, "\""); + } +} + +static void +_rewriteGrantStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, GrantStmt *node) +{ + PrivTarget *n; + + if (node->is_grant == true) + delay_string_append_char(message, str, "GRANT "); + else + { + delay_string_append_char(message, str, "REVOKE "); + if (node->grant_option == true) + delay_string_append_char(message, str, "GRANT OPTION FOR "); + } + + _rewritePrivilegeList(BaseSelect, message, dblink, str, node->privileges); + + delay_string_append_char(message, str, " ON "); + + n = makeNode(PrivTarget); + n->objtype = node->objtype; + n->objs = node->objects; + _rewriteNode(BaseSelect, message, dblink, str, n); + pfree(n); + + if (node->is_grant == true) + delay_string_append_char(message, str, " TO "); + else + delay_string_append_char(message, str, " FROM "); + _rewriteNode(BaseSelect, message, dblink, str, node->grantees); + + if (node->is_grant == true && node->grant_option == TRUE) + delay_string_append_char(message, str, " WITH GRANT OPTION"); + + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); + +} + +static void +_rewriteGrantRoleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, GrantRoleStmt *node) +{ + if (node->is_grant == true) + delay_string_append_char(message, str, "GRANT "); + else + { + delay_string_append_char(message, str, "REVOKE "); + if (node->admin_opt == true) + delay_string_append_char(message, str, "ADMIN OPTION FOR "); + } + + _rewriteIdList(BaseSelect, message, dblink, str, node->granted_roles); + + delay_string_append_char(message, str, node->is_grant == true ? " TO " : " FROM "); + + _rewriteIdList(BaseSelect, message, dblink, str, node->grantee_roles); + + if (node->admin_opt == true && node->is_grant == true) + delay_string_append_char(message, str, " WITH ADMIN OPTION"); + + if (node->grantor != NULL) + { + delay_string_append_char(message, str, " GRANTED BY \""); + delay_string_append_char(message, str, node->grantor); + delay_string_append_char(message, str, "\""); + } + + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); +} + +static void +_rewriteFuncOptList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *list) +{ + ListCell *lc; + + foreach (lc, list) + { + DefElem *e = lfirst(lc); + Value *v = (Value *) e->arg; + + if (strcmp(e->defname, "strict") == 0) + { + if (v->val.ival == TRUE) + delay_string_append_char(message, str, " STRICT"); + else + delay_string_append_char(message, str, " CALLED ON NULL INPUT"); + } + else if (strcmp(e->defname, "volatility") == 0) + { + char *s = v->val.str; + if (strcmp(s, "immutable") == 0) + delay_string_append_char(message, str, " IMMUTABLE"); + else if (strcmp(s, "stable") == 0) + delay_string_append_char(message, str, " STABLE"); + else if (strcmp(s, "volatile") == 0) + delay_string_append_char(message, str, " VOLATILE"); + } + else if (strcmp(e->defname, "security") == 0) + { + if (v->val.ival == TRUE) + delay_string_append_char(message, str, " SECURITY DEFINER"); + else + delay_string_append_char(message, str, " SECURITY INVOKER"); + } + else if (strcmp(e->defname, "as") == 0) + { + delay_string_append_char(message, str, " AS "); + _rewriteNode(BaseSelect, message, dblink, str, e->arg); + } + else if (strcmp(e->defname, "language") == 0) + { + delay_string_append_char(message, str, " LANGUAGE '"); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "'"); + } + } +} + +static void +_rewriteCreateFunctionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateFunctionStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + if (node->replace == true) + delay_string_append_char(message, str, "OR REPLACE "); + delay_string_append_char(message, str, "FUNCTION "); + + _rewriteFuncName(BaseSelect, message, dblink, str, node->funcname); + + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->parameters); + delay_string_append_char(message, str, ")"); + + if (node->returnType) + { + delay_string_append_char(message, str, " RETURNS "); + _rewriteNode(BaseSelect, message, dblink, str, node->returnType); + } + + _rewriteFuncOptList(BaseSelect, message, dblink, str, node->options); + + if (node->withClause) + { + delay_string_append_char(message, str, " WITH "); + _rewriteDefinition(BaseSelect, message, dblink, str, node->withClause); + } +} + +static void +_rewriteAlterFunctionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterFunctionStmt *node) +{ + delay_string_append_char(message, str, "ALTER FUNCTION "); + _rewriteNode(BaseSelect, message, dblink, str, node->func); + _rewriteFuncOptList(BaseSelect, message, dblink, str, node->actions); +} + +static void +_rewriteRemoveFuncStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RemoveFuncStmt *node) +{ + switch (node->kind) + { + case OBJECT_FUNCTION: + delay_string_append_char(message, str, "DROP FUNCTION "); + break; + + case OBJECT_AGGREGATE: + delay_string_append_char(message, str, "DROP AGGREGATE "); + break; + + case OBJECT_OPERATOR: + delay_string_append_char(message, str, "DROP OPERATOR CLASS "); + break; + + default: + break; + } + + if (node->missing_ok) + delay_string_append_char(message, str, "IF EXISTS "); + + _rewriteFuncName(BaseSelect, message, dblink, str, node->name); + + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->args); + delay_string_append_char(message, str, ")"); + + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); +} + +static void +_rewriteCreateCastStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateCastStmt *node) +{ + delay_string_append_char(message, str, "CREATE CAST ("); + _rewriteNode(BaseSelect, message, dblink, str, node->sourcetype); + delay_string_append_char(message, str, " AS "); + _rewriteNode(BaseSelect, message, dblink, str, node->targettype); + delay_string_append_char(message, str, ") WITH FUNCTION "); + _rewriteNode(BaseSelect, message, dblink, str, node->func); + + switch (node->context) + { + case COERCION_IMPLICIT: + delay_string_append_char(message, str, " AS IMPLICIT"); + break; + + case COERCION_ASSIGNMENT: + delay_string_append_char(message, str, " AS ASSIGNMENT"); + break; + + default: + break; + } +} + +static void +_rewriteDropCastStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropCastStmt *node) +{ + delay_string_append_char(message, str, "DROP CAST ("); + _rewriteNode(BaseSelect, message, dblink, str, node->sourcetype); + delay_string_append_char(message, str, " AS "); + _rewriteNode(BaseSelect, message, dblink, str, node->targettype); + delay_string_append_char(message, str, ")"); + + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); +} + +static void +_rewriteReindexStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ReindexStmt *node) +{ + delay_string_append_char(message, str, "REINDEX "); + + switch (node->kind) + { + case OBJECT_DATABASE: + if (node->do_system == true && node->do_user == false) + delay_string_append_char(message, str, "SYSTEM "); + else + delay_string_append_char(message, str, "DATABASE "); + break; + + case OBJECT_INDEX: + delay_string_append_char(message, str, "INDEX "); + break; + + case OBJECT_TABLE: + delay_string_append_char(message, str, "TABLE "); + break; + + default: + break; + } + + if (node->relation) + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (node->name) + { + delay_string_append_char(message, str, "\""); + delay_string_append_char(message, str, (char *) node->name); + delay_string_append_char(message, str, "\""); + } +} + +static void +_rewriteAlterObjectSchemaStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterObjectSchemaStmt *node) +{ + delay_string_append_char(message, str, "ALTER "); + + switch (node->objectType) + { + case OBJECT_AGGREGATE: + delay_string_append_char(message, str, "AGGREGATE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, "("); + if (lfirst(list_head(node->objarg)) == NULL) + delay_string_append_char(message, str, "*"); + else + _rewriteNode(BaseSelect, message, dblink, str, lfirst(list_head(node->objarg))); + delay_string_append_char(message, str, ") SET SCHAME \""); + delay_string_append_char(message, str, node->newschema); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_DOMAIN: + delay_string_append_char(message, str, "DOMAIN "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " SET SCHEMA \""); + delay_string_append_char(message, str, node->newschema); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_FUNCTION: + delay_string_append_char(message, str, "FUNCTION "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->objarg); + delay_string_append_char(message, str, ") SET SCHEMA \""); + delay_string_append_char(message, str, node->newschema); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_SEQUENCE: + delay_string_append_char(message, str, "SEQUENCE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " SET SCHEMA \""); + delay_string_append_char(message, str, node->newschema); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TABLE: + delay_string_append_char(message, str, "TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + delay_string_append_char(message, str, " SET SCHEMA \""); + delay_string_append_char(message, str, node->newschema); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TYPE: + delay_string_append_char(message, str, "TYPE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " SET SCHEMA \""); + delay_string_append_char(message, str, node->newschema); + delay_string_append_char(message, str, "\""); + break; + + default: + break; + } +} + +static void +_rewriteAlterOwnerStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterOwnerStmt *node) +{ + delay_string_append_char(message, str, "ALTER "); + + switch (node->objectType) + { + case OBJECT_AGGREGATE: + delay_string_append_char(message, str, "AGGREGATE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, "("); + if (lfirst(list_head(node->objarg)) == NULL) + delay_string_append_char(message, str, "*"); + else + _rewriteNode(BaseSelect, message, dblink, str, lfirst(list_head(node->objarg))); + delay_string_append_char(message, str, ") OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_CONVERSION: + delay_string_append_char(message, str, "CONVERSION "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_DATABASE: + delay_string_append_char(message, str, "DATABASE \""); + _rewriteIdList(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, "\" OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_DOMAIN: + delay_string_append_char(message, str, "DOMAIN "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_FUNCTION: + delay_string_append_char(message, str, "FUNCTION "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->objarg); + delay_string_append_char(message, str, ") OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_OPERATOR: + delay_string_append_char(message, str, "OPERATOR "); + _rewriteOperatorName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, "("); + _rewriteOperatorArgTypes(BaseSelect, message, dblink, str, node->objarg); + delay_string_append_char(message, str, ") OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_OPCLASS: + delay_string_append_char(message, str, "OPERATOR CLASS "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " USING "); + delay_string_append_char(message, str, node->addname); + delay_string_append_char(message, str, " OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_SCHEMA: + delay_string_append_char(message, str, "SCHEMA \""); + delay_string_append_char(message, str, linitial(node->object)); + delay_string_append_char(message, str, "\" OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TYPE: + delay_string_append_char(message, str, "TYPE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->object); + delay_string_append_char(message, str, " OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + case OBJECT_TABLESPACE: + delay_string_append_char(message, str, "TABLESPACE \""); + delay_string_append_char(message, str, linitial(node->object)); + delay_string_append_char(message, str, "\" OWNER TO \""); + delay_string_append_char(message, str, node->newowner); + delay_string_append_char(message, str, "\""); + break; + + default: + break; + } +} + +static void +_rewriteRuleStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RuleStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + if (node->replace) + delay_string_append_char(message, str, "OR REPLACE "); + delay_string_append_char(message, str, "RULE \""); + delay_string_append_char(message, str, node->rulename); + delay_string_append_char(message, str, "\" AS ON "); + + switch (node->event) + { + case CMD_SELECT: + delay_string_append_char(message, str, "SELECT"); + break; + + case CMD_UPDATE: + delay_string_append_char(message, str, "UPDATE"); + break; + + case CMD_DELETE: + delay_string_append_char(message, str, "DELETE"); + break; + + case CMD_INSERT: + delay_string_append_char(message, str, "INSERT"); + break; + + default: + break; + } + + delay_string_append_char(message, str, " TO "); + _rewriteNode(BaseSelect, message, dblink, str, node->relation); + + if (node->whereClause) + { + delay_string_append_char(message, str, " WHERE "); + _rewriteNode(BaseSelect, message, dblink, str, node->whereClause); + } + + delay_string_append_char(message, str, " DO "); + + if (node->instead) + delay_string_append_char(message, str, "INSTEAD "); + + if (node->actions == NIL) + delay_string_append_char(message, str, "NOTHING"); + else if (list_length(node->actions) == 1) + _rewriteNode(BaseSelect, message, dblink, str, linitial(node->actions)); + else + { + ListCell *lc; + char semi = 0; + + delay_string_append_char(message, str, "("); + + foreach (lc, node->actions) + { + if (semi == 0) + semi = 1; + else + delay_string_append_char(message, str, ";"); + + _rewriteNode(BaseSelect, message, dblink, str, lfirst(lc)); + } + + delay_string_append_char(message, str, ")"); + } +} + +static void +_rewriteViewStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ViewStmt *node) +{ + if (node->replace) + delay_string_append_char(message, str, "CREATE OR REPLACE "); + else + delay_string_append_char(message, str, "CREATE "); + + if (node->view->istemp == TRUE) + delay_string_append_char(message, str, "TEMP "); + + delay_string_append_char(message, str, "VIEW "); + _rewriteNode(BaseSelect, message, dblink, str, node->view); + + if (node->aliases) + { + delay_string_append_char(message, str, "("); + _rewriteIdList(BaseSelect, message, dblink, str, node->aliases); + delay_string_append_char(message, str, ")"); + } + + delay_string_append_char(message, str, " AS"); + _rewriteNode(BaseSelect, message, dblink, str, node->query); +} + +static void +_rewriteCreatedbOptList(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *options) +{ + ListCell *lc; + + foreach (lc, options) + { + DefElem *e = lfirst(lc); + Value *v = (Value *) e->arg; + int sconst = false; + + /* keyword */ + if (strcmp(e->defname, "template") == 0) + delay_string_append_char(message, str, " TEMPLATE "); + else if (strcmp(e->defname, "location") == 0) + { + delay_string_append_char(message, str, " LOCATION "); + sconst = true; + } + else if (strcmp(e->defname, "tablespace") == 0) + delay_string_append_char(message, str, " TABLESPACE "); + else if (strcmp(e->defname, "encoding") == 0) + { + delay_string_append_char(message, str, " ENCODING "); + sconst = true; + } + else if (strcmp(e->defname, "owner") == 0) + delay_string_append_char(message, str, " OWNER "); + else if (strcmp(e->defname, "connectionlimit") == 0) + delay_string_append_char(message, str, " CONNECTION LIMIT "); + + /* value */ + if (v == NULL) + delay_string_append_char(message, str, "DEFAULT"); + else if (IsA((Node *)v, String)) + { + delay_string_append_char(message, str, sconst ? "'" : "'"); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, sconst ? "'" : "'"); + } + else + { + char buf[16]; + snprintf(buf, 16, "%ld", v->val.ival); + delay_string_append_char(message, str, buf); + } + } +} + +static void +_rewriteCreatedbStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreatedbStmt *node) +{ + delay_string_append_char(message, str, "CREATE DATABASE \""); + delay_string_append_char(message, str, node->dbname); + delay_string_append_char(message, str, "\""); + + _rewriteCreatedbOptList(BaseSelect, message, dblink, str, node->options); +} + +static void +_rewriteAlterDatabaseStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterDatabaseStmt *node) +{ + delay_string_append_char(message, str, "ALTER DATABASE \""); + delay_string_append_char(message, str, node->dbname); + delay_string_append_char(message, str, "\" "); + + _rewriteCreatedbOptList(BaseSelect, message, dblink, str, node->options); +} + +static void +_rewriteAlterDatabaseSetStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterDatabaseSetStmt *node) +{ + delay_string_append_char(message, str, "ALTER DATABASE \""); + delay_string_append_char(message, str, node->dbname); + delay_string_append_char(message, str, "\" "); + + _rewriteNode(BaseSelect, message, dblink, str, node->setstmt); +} + +static void +_rewriteDropdbStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, DropdbStmt *node) +{ + delay_string_append_char(message, str, "DROP DATABASE \""); + delay_string_append_char(message, str, node->dbname); + delay_string_append_char(message, str, "\""); +} + +static void +_rewriteCreateDomainStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateDomainStmt *node) +{ + ListCell *lc; + + delay_string_append_char(message, str, "CREATE DOMAIN "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->domainname); + delay_string_append_char(message, str, " "); + _rewriteNode(BaseSelect, message, dblink, str, node->typename); + + + foreach (lc, node->constraints) + { + delay_string_append_char(message, str, " "); + _rewriteNode(BaseSelect, message, dblink, str, lfirst(lc)); + } +} + +static void +_rewriteAlterDomainStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, AlterDomainStmt *node) +{ + delay_string_append_char(message, str, "ALTER DOMAIN "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->typename); + + switch (node->subtype) + { + case 'T': + if (node->def) + { + delay_string_append_char(message, str, " SET DEFAULT "); + _rewriteNode(BaseSelect, message, dblink, str, node->def); + } + else + delay_string_append_char(message, str, " DROP DEFAULT"); + break; + + case 'N': + delay_string_append_char(message, str, " DROP NOT NULL"); + break; + + case 'O': + delay_string_append_char(message, str, " SET NOT NULL"); + break; + + case 'C': + delay_string_append_char(message, str, " ADD "); + _rewriteNode(BaseSelect, message, dblink, str, node->def); + break; + + case 'X': + delay_string_append_char(message, str, " DROP CONSTRAINT \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\""); + if (node->behavior == DROP_CASCADE) + delay_string_append_char(message, str, " CASCADE"); + break; + } +} + +static void +_rewriteCreateConversionStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CreateConversionStmt *node) +{ + delay_string_append_char(message, str, "CREATE "); + + if (node->def == TRUE) + delay_string_append_char(message, str, "DEFAULT "); + + delay_string_append_char(message, str, "CONVERSION "); + + _rewriteFuncName(BaseSelect, message, dblink, str, node->conversion_name); + + delay_string_append_char(message, str, " FOR '"); + delay_string_append_char(message, str, node->for_encoding_name); + delay_string_append_char(message, str, "' TO '"); + delay_string_append_char(message, str, node->to_encoding_name); + delay_string_append_char(message, str, " FROM "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->func_name); +} + +static void +_rewritePrepareStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, PrepareStmt *node) +{ + delay_string_append_char(message, str, "PREPARE \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" "); + + if (node->argtypes != NIL) + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->argtypes); + delay_string_append_char(message, str, ") "); + } + + delay_string_append_char(message, str, "AS "); + _rewriteNode(BaseSelect, message, dblink, str, node->query); +} + +static void +_rewriteExecuteStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, ExecuteStmt *node) +{ + if (node->into) + { + IntoClause *into = node->into; + RangeVar *rel = into->rel; + + delay_string_append_char(message, str, "CREATE "); + if (rel->istemp == TRUE) + delay_string_append_char(message, str, "TEMP "); + delay_string_append_char(message, str, "TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, into->rel); + delay_string_append_char(message, str, " AS "); + } + + delay_string_append_char(message, str, "EXECUTE \""); + delay_string_append_char(message, str, node->name); + delay_string_append_char(message, str, "\" "); + + if (node->params != NIL) + { + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->params); + delay_string_append_char(message, str, ")"); + } +} + +static void +_rewriteLockStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, LockStmt *node) +{ + delay_string_append_char(message, str, "LOCK TABLE "); + _rewriteNode(BaseSelect, message, dblink, str, node->relations); + + delay_string_append_char(message, str, " IN "); + switch (node->mode) + { + case AccessShareLock: + delay_string_append_char(message, str, "ACCESS SHARE "); + break; + + case RowShareLock: + delay_string_append_char(message, str, "ROW SHARE "); + break; + + case RowExclusiveLock: + delay_string_append_char(message, str, "ROW EXCLUSIVE "); + break; + + case ShareUpdateExclusiveLock: + delay_string_append_char(message, str, "SHARE UPDATE EXCLUSIVE "); + break; + + case ShareLock: + delay_string_append_char(message, str, "SHARE "); + break; + + case ShareRowExclusiveLock: + delay_string_append_char(message, str, "SHARE ROW EXCLUSIVE "); + break; + + case ExclusiveLock: + delay_string_append_char(message, str, "EXCLUSIVE "); + break; + + case AccessExclusiveLock: + delay_string_append_char(message, str, "ACCESS EXCLUSIVE "); + break; + } + delay_string_append_char(message, str, "MODE"); + + if (node->nowait == TRUE) + delay_string_append_char(message, str, " NOWAIT"); +} + +static void +_rewriteOperatorArgTypes(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *args) +{ + TypeName *left, *right; + + left = linitial(args); + right = lsecond(args); + + if (left) + _rewriteNode(BaseSelect, message, dblink, str, left); + else + delay_string_append_char(message, str, "NONE"); + delay_string_append_char(message, str, ", "); + if (right) + _rewriteNode(BaseSelect, message, dblink, str, right); + else + delay_string_append_char(message, str, "NONE"); +} + +static void +_rewriteCommentStmt(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CommentStmt *node) +{ + TypeName *t; + Value *v; + char buf[16]; + + delay_string_append_char(message, str, "COMMENT ON "); + + switch (node->objtype) + { + case OBJECT_AGGREGATE: + delay_string_append_char(message, str, "AGGREGATE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->objname); + delay_string_append_char(message, str, "("); + + t = linitial(node->objargs); + if (t) + _rewriteNode(BaseSelect, message, dblink, str, t); + else + delay_string_append_char(message, str, "*"); + delay_string_append_char(message, str, ")"); + break; + + case OBJECT_FUNCTION: + delay_string_append_char(message, str, "FUNCTION "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->objname); + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->objargs); + delay_string_append_char(message, str, ")"); + break; + + case OBJECT_OPERATOR: + delay_string_append_char(message, str, "OPERATOR "); + _rewriteOperatorName(BaseSelect, message, dblink, str, node->objname); + delay_string_append_char(message, str, "("); + _rewriteOperatorArgTypes(BaseSelect, message, dblink, str, node->objargs); + delay_string_append_char(message, str, ")"); + break; + + case OBJECT_CONSTRAINT: + delay_string_append_char(message, str, "CONSTRAINT \""); + v = lsecond(node->objname); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "\" ON "); + _rewriteFuncName(BaseSelect, message, dblink, str, linitial(node->objargs)); + break; + + case OBJECT_RULE: + delay_string_append_char(message, str, "RULE \""); + v = lsecond(node->objname); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "\" ON "); + _rewriteFuncName(BaseSelect, message, dblink, str, linitial(node->objargs)); + break; + + case OBJECT_TRIGGER: + delay_string_append_char(message, str, "TRIGGER \""); + v = lsecond(node->objname); + delay_string_append_char(message, str, v->val.str); + delay_string_append_char(message, str, "\" ON "); + _rewriteFuncName(BaseSelect, message, dblink, str, linitial(node->objargs)); + break; + + case OBJECT_OPCLASS: + delay_string_append_char(message, str, "OPERATOR CLASS "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->objname); + delay_string_append_char(message, str, " USING "); + v = linitial(node->objargs); + delay_string_append_char(message, str, v->val.str); + break; + + case OBJECT_LARGEOBJECT: + delay_string_append_char(message, str, "LARGE OBJECT "); + v = linitial(node->objname); + if (IsA(v, String)) + delay_string_append_char(message, str, v->val.str); + else if (IsA(v, Integer)) + { + snprintf(buf, 16, "%ld", v->val.ival); + delay_string_append_char(message, str, buf); + } + + case OBJECT_CAST: + delay_string_append_char(message, str, "CAST ("); + _rewriteNode(BaseSelect, message, dblink, str, linitial(node->objname)); + delay_string_append_char(message, str, " AS "); + _rewriteNode(BaseSelect, message, dblink, str, linitial(node->objargs)); + delay_string_append_char(message, str, ")"); + break; + + case OBJECT_LANGUAGE: + delay_string_append_char(message, str, "LANGUAGE "); + _rewriteFuncName(BaseSelect, message, dblink, str, node->objname); + break; + + default: + switch (node->objtype) + { + case OBJECT_COLUMN: + delay_string_append_char(message, str, "COLUMN "); + break; + case OBJECT_DATABASE: + delay_string_append_char(message, str, "DATABASE "); + break; + case OBJECT_SCHEMA: + delay_string_append_char(message, str, "SCHEMA "); + break; + case OBJECT_INDEX: + delay_string_append_char(message, str, "INDEX "); + break; + case OBJECT_SEQUENCE: + delay_string_append_char(message, str, "SEQUENCE "); + break; + case OBJECT_TABLE: + delay_string_append_char(message, str, "TABLE "); + break; + case OBJECT_DOMAIN: + delay_string_append_char(message, str, "DOMAIN "); + break; + case OBJECT_TYPE: + delay_string_append_char(message, str, "TYPE "); + break; + case OBJECT_VIEW: + delay_string_append_char(message, str, "VIEW "); + break; + default: + break; + } + _rewriteFuncName(BaseSelect, message, dblink, str, node->objname); + break; + } + + delay_string_append_char(message, str, " IS "); + if (node->comment) + { + delay_string_append_char(message, str, "'"); + delay_string_append_char(message, str, node->comment); + delay_string_append_char(message, str, "'"); + } + else + delay_string_append_char(message, str, "NULL"); +} + +static void +_rewriteRangeSubselect(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeSubselect *node) +{ + int last = message->current_select; + Alias *alias = node->alias; + char *table_name = alias->aliasname; + int sub_no = message->analyze_num; + int CallFromClause = 0; + int next = message->analyze_num; + + if(message->r_code == SELECT_AEXPR) + { + KeepRewriteQueryReturnCode(message, SELECT_AEXPR_FALSE); + return; + } + + if(message->r_code == SELECT_ANALYZE && message->fromClause) + CallFromClause = 1; + + delay_string_append_char(message, str, "("); + _rewriteNode(BaseSelect, message, dblink, str, node->subquery); + delay_string_append_char(message, str, ")"); + + if(message->r_code == SELECT_ANALYZE) + { + AnalyzeSelect *analyze; + analyze=message->analyze[sub_no]; + + if(node->alias && node->alias->colnames) + { + ListCell *lc; + int num = list_length(node->alias->colnames); + int ret_num = message->analyze[last + 1]->select_ret->col_num; + if(num == ret_num) + { + char **col_list; + int i = 0; + col_list = (char **) palloc(sizeof(char *) * num); + + foreach(lc,node->alias->colnames) + { + Node *n = lfirst(lc); + Value *value = (Value *) n; + col_list[i] = value->val.str; + i++; + } + message->analyze[last+1]->select_ret->col_list = col_list; + } + } + + message->analyze[last]->select_range = true; + + pool_debug("_rewriteRangeSubSelect: select range ture %d",sub_no); + build_range_info(message,NULL,NULL,analyze->select_ret,table_name,last,sub_no); + + /*2009/07/27*/ + if(CallFromClause) + { + int temp = message->current_select; + /* now Subquery's current_select is set + * change the current_select + */ + message->current_select = last; + build_virtual_table(message,node,next); + message->current_select = temp; + } + } + else if(message->r_code == SELECT_DEFAULT && message->ignore_rewrite == -1) + { + Alias *alias = (Alias *) node->alias; + delay_string_append_char(message, str, " AS "); + delay_string_append_char(message, str, alias->aliasname); + delay_string_append_char(message, str, " "); + + if (alias->colnames) + { + AnalyzeSelect *analyze; + int ret_num; + int i; + analyze = message->analyze[last + 1]; + ret_num = analyze->select_ret->col_num; + delay_string_append_char(message, str, "("); + + for (i = 0; i< ret_num; i++) + { + char buf[16]; + snprintf(buf, 16, "%d", analyze->select_ret->return_list[i]); + delay_string_append_char(message, str," \"pool_c$"); + delay_string_append_char(message, str,buf); + delay_string_append_char(message, str,"\""); + if(i != ret_num -1) + delay_string_append_char(message, str,","); + } + delay_string_append_char(message, str, ")"); + } + } else { + _rewriteNode(BaseSelect, message, dblink, str, node->alias); + } + +} + +static void +_rewriteRangeFunction(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, RangeFunction *node) +{ + _rewriteNode(BaseSelect, message, dblink, str, node->funccallnode); + if (node->alias) + { + _rewriteNode(BaseSelect, message, dblink, str, node->alias); + } + + if (node->coldeflist) + { + delay_string_append_char(message, str, " ("); + _rewriteNode(BaseSelect, message, dblink, str, node->coldeflist); + delay_string_append_char(message, str, ")"); + } +} + +static void +_rewriteWithDefinition(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, List *def_list) +{ + int oid = 0; + + if (list_length(def_list) == 1) + { + DefElem *elem; + Value *v; + + elem = linitial(def_list); + v = (Value *)elem->arg; + if (strcmp(elem->defname, "oids") == 0) + { + Value *v = (Value *)elem->arg; + if (v->val.ival == 1) + delay_string_append_char(message, str, " WITH OIDS "); + else + delay_string_append_char(message, str, " WITHOUT OIDS "); + oid = 1; + } + } + + if (oid == 1) + return; + + delay_string_append_char(message, str, " WITH "); + _rewriteDefinition(BaseSelect, message, dblink, str, def_list); +} + +static void +_rewriteCurrentOfExpr(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, CurrentOfExpr *node) +{ + delay_string_append_char(message, str, "CURRENT OF "); + if (node->cursor_name == NULL) + { + char n[10]; + snprintf(n, sizeof(n), "$%d", node->cursor_param); + delay_string_append_char(message, str, n); + } + else + delay_string_append_char(message, str, node->cursor_name); +} + +/* + * _rewriteNode - + * converts a Node into ascii string and append it to 'str' + */ +static void +_rewriteNode(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dblink, String *str, void *obj) +{ + if(!obj) + return; + else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList)) + _rewriteList(BaseSelect, message, dblink, str, obj); + else if (IsA(obj, Integer) || + IsA(obj, Float) || + IsA(obj, String) || + IsA(obj, BitString)) + { + /* nodeRead does not want to see { } around these! */ + _rewriteValue(BaseSelect, message, dblink, str, obj); + } + else + { + switch (nodeTag(obj)) + { + case T_Alias: + _rewriteAlias(BaseSelect, message, dblink, str, obj); + break; + case T_RangeVar: + _rewriteRangeVar(BaseSelect, message, dblink, str, obj); + break; + case T_Var: + _rewriteVar(BaseSelect, message, dblink, str, obj); + break; + case T_Const: + _rewriteConst(BaseSelect, message, dblink, str, obj); + break; + case T_Param: + _rewriteParam(BaseSelect, message, dblink, str, obj); + break; + case T_Aggref: + _rewriteAggref(BaseSelect, message, dblink, str, obj); + break; + case T_ArrayRef: + _rewriteArrayRef(BaseSelect, message, dblink, str, obj); + break; + case T_FuncExpr: + _rewriteFuncExpr(BaseSelect, message, dblink, str, obj); + break; + case T_OpExpr: + _rewriteOpExpr(BaseSelect, message, dblink, str, obj); + break; + case T_DistinctExpr: + _rewriteDistinctExpr(BaseSelect, message, dblink, str, obj); + break; + case T_ScalarArrayOpExpr: + _rewriteScalarArrayOpExpr(BaseSelect, message, dblink, str, obj); + break; + case T_BoolExpr: + _rewriteBoolExpr(BaseSelect, message, dblink, str, obj); + break; + case T_SubLink: + _rewriteSubLink(BaseSelect, message, dblink, str, obj); + break; + case T_SubPlan: + _rewriteSubPlan(BaseSelect, message, dblink, str, obj); + break; + case T_FieldSelect: + _rewriteFieldSelect(BaseSelect, message, dblink, str, obj); + break; + case T_FieldStore: + _rewriteFieldStore(BaseSelect, message, dblink, str, obj); + break; + case T_RelabelType: + _rewriteRelabelType(BaseSelect, message, dblink, str, obj); + break; + case T_ConvertRowtypeExpr: + _rewriteConvertRowtypeExpr(BaseSelect, message, dblink, str, obj); + break; + case T_CaseExpr: + _rewriteCaseExpr(BaseSelect, message, dblink, str, obj); + break; + case T_CaseWhen: + _rewriteCaseWhen(BaseSelect, message, dblink, str, obj); + break; + case T_CaseTestExpr: + _rewriteCaseTestExpr(BaseSelect, message, dblink, str, obj); + break; + case T_ArrayExpr: + _rewriteArrayExpr(BaseSelect, message, dblink, str, obj); + break; + case T_RowExpr: + _rewriteRowExpr(BaseSelect, message, dblink, str, obj); + break; + case T_CoalesceExpr: + _rewriteCoalesceExpr(BaseSelect, message, dblink, str, obj); + break; + case T_MinMaxExpr: + _rewriteMinMaxExpr(BaseSelect, message, dblink, str, obj); + break; + case T_NullIfExpr: + _rewriteNullIfExpr(BaseSelect, message, dblink, str, obj); + break; + case T_NullTest: + _rewriteNullTest(BaseSelect, message, dblink, str, obj); + break; + case T_BooleanTest: + _rewriteBooleanTest(BaseSelect, message, dblink, str, obj); + break; + case T_CoerceToDomain: + _rewriteCoerceToDomain(BaseSelect, message, dblink, str, obj); + break; + case T_CoerceToDomainValue: + _rewriteCoerceToDomainValue(BaseSelect, message, dblink, str, obj); + break; + case T_SetToDefault: + _rewriteSetToDefault(BaseSelect, message, dblink, str, obj); + break; + case T_TargetEntry: + _rewriteTargetEntry(BaseSelect, message, dblink, str, obj); + break; + case T_RangeTblRef: + _rewriteRangeTblRef(BaseSelect, message, dblink, str, obj); + break; + case T_JoinExpr: + _rewriteJoinExpr(BaseSelect, message, dblink, str, obj); + break; + case T_FromExpr: + _rewriteFromExpr(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateStmt: + _rewriteCreateStmt(BaseSelect, message, dblink, str, obj); + break; + case T_IndexStmt: + _rewriteIndexStmt(BaseSelect, message, dblink, str, obj); + break; + case T_NotifyStmt: + _rewriteNotifyStmt(BaseSelect, message, dblink, str, obj); + break; + case T_DeclareCursorStmt: + _rewriteDeclareCursorStmt(BaseSelect, message, dblink, str, obj); + break; + case T_SelectStmt: + _rewriteSelectStmt(BaseSelect, message, dblink, str, obj); + break; + case T_ColumnDef: + _rewriteColumnDef(BaseSelect, message, dblink, str, obj); + break; + case T_TypeName: + _rewriteTypeName(BaseSelect, message, dblink, str, obj); + break; + case T_TypeCast: + _rewriteTypeCast(BaseSelect, message, dblink, str, obj); + break; + case T_IndexElem: + _rewriteIndexElem(BaseSelect, message, dblink, str, obj); + break; + case T_SortClause: + _rewriteSortClause(BaseSelect, message, dblink, str, obj); + break; + case T_GroupClause: + _rewriteGroupClause(BaseSelect, message, dblink, str, obj); + break; + case T_SetOperationStmt: + _rewriteSetOperationStmt(BaseSelect, message, dblink, str, obj); + break; +/* case T_RangeTblEntry: + _rewriteRangeTblEntry(BaseSelect, message, dblink, str, obj); + break;*/ + case T_A_Expr: + _rewriteAExpr(BaseSelect, message, dblink, str, obj); + break; + case T_ColumnRef: + _rewriteColumnRef(BaseSelect, message, dblink, str, obj); + break; + case T_ParamRef: + _rewriteParamRef(BaseSelect, message, dblink, str, obj); + break; + case T_A_Const: + _rewriteAConst(BaseSelect, message, dblink, str, obj); + break; + case T_A_Indices: + _rewriteA_Indices(BaseSelect, message, dblink, str, obj); + break; + case T_A_Indirection: + _rewriteA_Indirection(BaseSelect, message, dblink, str, obj); + break; + case T_ResTarget: + _rewriteResTarget(BaseSelect, message, dblink, str, obj); + break; + case T_Constraint: + _rewriteConstraint(BaseSelect, message, dblink, str, obj); + break; + case T_FkConstraint: + _rewriteFkConstraint(BaseSelect, message, dblink, str, obj); + break; + case T_FuncCall: + _rewriteFuncCall(BaseSelect, message, dblink, str, obj); + break; + case T_DefElem: + _rewriteDefElem(BaseSelect, message, dblink, str, obj); + break; + case T_LockingClause: + _rewriteLockingClause(BaseSelect, message, dblink, str, obj); + break; + + case T_SortBy: + _rewriteSortBy(BaseSelect, message, dblink, str, obj); + break; + + case T_InsertStmt: + _rewriteInsertStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_UpdateStmt: + _rewriteUpdateStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DeleteStmt: + _rewriteDeleteStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_TransactionStmt: + _rewriteTransactionStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_TruncateStmt: + _rewriteTruncateStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_VacuumStmt: + _rewriteVacuumStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ExplainStmt: + _rewriteExplainStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ClusterStmt: + _rewriteClusterStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CheckPointStmt: + _rewriteCheckPointStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ClosePortalStmt: + _rewriteClosePortalStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ListenStmt: + _rewriteListenStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_UnlistenStmt: + _rewriteUnlistenStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_LoadStmt: + _rewriteLoadStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CopyStmt: + _rewriteCopyStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DeallocateStmt: + _rewriteDeallocateStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_RenameStmt: + _rewriteRenameStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateRoleStmt: + _rewriteCreateRoleStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterRoleStmt: + _rewriteAlterRoleStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterRoleSetStmt: + _rewriteAlterRoleSetStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropRoleStmt: + _rewriteDropRoleStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateSchemaStmt: + _rewriteCreateSchemaStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_VariableSetStmt: + _rewriteVariableSetStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_VariableShowStmt: + _rewriteVariableShowStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ConstraintsSetStmt: + _rewriteConstraintsSetStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterTableStmt: + _rewriteAlterTableStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterTableCmd: + _rewriteAlterTableCmd(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateSeqStmt: + _rewriteCreateSeqStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterSeqStmt: + _rewriteAlterSeqStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreatePLangStmt: + _rewriteCreatePLangStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropPLangStmt: + _rewriteDropPLangStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateTableSpaceStmt: + _rewriteCreateTableSpaceStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropTableSpaceStmt: + _rewriteDropTableSpaceStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateTrigStmt: + _rewriteCreateTrigStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropPropertyStmt: + _rewriteDropPropertyStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DefineStmt: + _rewriteDefineStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateOpClassStmt: + _rewriteCreateOpClassStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateOpClassItem: + _rewriteCreateOpClassItem(BaseSelect, message, dblink, str, obj); + break; + + case T_RemoveOpClassStmt: + _rewriteRemoveOpClassStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropStmt: + _rewriteDropStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_FetchStmt: + _rewriteFetchStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_GrantStmt: + _rewriteGrantStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_PrivTarget: + _rewritePrivTarget(BaseSelect, message, dblink, str, obj); + break; + + case T_FuncWithArgs: + _rewriteFuncWithArgs(BaseSelect, message, dblink, str, obj); + break; + + case T_FunctionParameter: + _rewriteFunctionParameter(BaseSelect, message, dblink, str, obj); + break; + + case T_PrivGrantee: + _rewritePrivGrantee(BaseSelect, message, dblink, str, obj); + break; + + case T_GrantRoleStmt: + _rewriteGrantRoleStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateFunctionStmt: + _rewriteCreateFunctionStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterFunctionStmt: + _rewriteAlterFunctionStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_RemoveFuncStmt: + _rewriteRemoveFuncStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateCastStmt: + _rewriteCreateCastStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropCastStmt: + _rewriteDropCastStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ReindexStmt: + _rewriteReindexStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterObjectSchemaStmt: + _rewriteAlterObjectSchemaStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterOwnerStmt: + _rewriteAlterOwnerStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_RuleStmt: + _rewriteRuleStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ViewStmt: + _rewriteViewStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreatedbStmt: + _rewriteCreatedbStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterDatabaseStmt: + _rewriteAlterDatabaseStmt(BaseSelect, message, dblink, str, obj); + break; + + + case T_AlterDatabaseSetStmt: + _rewriteAlterDatabaseSetStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_DropdbStmt: + _rewriteDropdbStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateDomainStmt: + _rewriteCreateDomainStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_AlterDomainStmt: + _rewriteAlterDomainStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CreateConversionStmt: + _rewriteCreateConversionStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_PrepareStmt: + _rewritePrepareStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_ExecuteStmt: + _rewriteExecuteStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_LockStmt: + _rewriteLockStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_CommentStmt: + _rewriteCommentStmt(BaseSelect, message, dblink, str, obj); + break; + + case T_RangeSubselect: + _rewriteRangeSubselect(BaseSelect, message, dblink, str, obj); + break; + + case T_RangeFunction: + _rewriteRangeFunction(BaseSelect, message, dblink, str, obj); + break; + + case T_CurrentOfExpr: + _rewriteCurrentOfExpr(BaseSelect, message, dblink, str, obj); + break; + + case T_DiscardStmt: + case T_CreateOpFamilyStmt: + case T_AlterOpFamilyStmt: + case T_RemoveOpFamilyStmt: + case T_CreateEnumStmt: + case T_DropOwnedStmt: + case T_ReassignOwnedStmt: + case T_AlterTSDictionaryStmt: + case T_AlterTSConfigurationStmt: + case T_XmlSerialize: + case T_InhRelation: + break; + + default: + KeepRewriteQueryCode(message, SELECT_RELATION_ERROR); + break; + } + } +} + + +/* + * nodeToString - + * returns the ascii representation of the Node as a palloc'd string + */ +void +nodeToRewriteString(RewriteQuery *message, ConInfoTodblink *dblink, void *obj) +{ + String *str; + + str = init_string(""); + message->analyze_num = 0; + _rewriteNode(NULL, message, dblink, str, obj); + message->rewrite_query = str->data; +} diff --git a/pool_rewrite_query.c b/pool_rewrite_query.c new file mode 100644 index 0000000..5d2ecd3 --- /dev/null +++ b/pool_rewrite_query.c @@ -0,0 +1,655 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_rewrite_query.c,v 1.13.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_rewrite_query.c: rewrite_query + * + */ + +#include "pool.h" +#include +#include +#include +#include "pool_rewrite_query.h" + + +static int getInsertRule(ListCell *lc,List *list_t ,DistDefInfo *info, int div_key_num); +static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend,RewriteQuery *message); +static void examSelectStmt(Node *node,POOL_CONNECTION_POOL *backend,RewriteQuery *message); +static char *delimistr(char *str); +static int direct_parallel_query(RewriteQuery *message); +static void initMessage(RewriteQuery *message); +static void initdblink(ConInfoTodblink *dblink, POOL_CONNECTION_POOL *backend); +static void analyze_debug(RewriteQuery *message); + + +/* create error message */ +char *pool_error_message(char *message) +{ + String *str; + + str = init_string(""); + string_append_char(str,message); + return str->data; +} + +/* + * search DistDefInfo(this info is build in starting process + * and get node id where a query send. + */ +static int getInsertRule(ListCell *lc,List *list_t ,DistDefInfo *info,int div_key_num) +{ + int loop_counter = 0; + int node_number = -1; + ListCell *cell; + + if(list_t->length != 1) + return -1; + + cell = list_head(list_t); + + if(!cell && !IsA(cell,List)) + return 1; + + foreach(lc,lfirst(cell)) + { + A_Const *constant; + Value value; + void *obj = NULL; + + obj = lfirst(lc); + + if(obj && IsA(obj, TypeCast)) + { + TypeCast *type = (TypeCast *) obj; + obj = type->arg; + + if(!obj) + { + return -1; + } + } + + if(obj && !IsA(obj, A_Const)) + { + return -1; + } + + if (loop_counter == div_key_num) + { + constant = (A_Const *) obj; + value = constant->val; + if (value.type == T_Integer) + { + char temp[16]; + sprintf(temp,"%ld",value.val.ival); + node_number = pool_get_id(info,temp); + break; + } + else + { + if(value.val.str) + node_number = pool_get_id(info, value.val.str); + else + return -1; + break; + } + } + loop_counter++; + } + /* if node_number is -1, cannot get return value from pool_get_id() */ + return node_number; +} + +/* + * This function processes the decision whether to + * distribute the insert sentence to the node. + */ +static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuery *message) +{ + RangeVar *table; + int cell_num; + int node_number; + DistDefInfo *info = NULL; + ListCell *lc = NULL; + List *list_t = NULL; + int div_key_num = 0; + int dist_def_flag = 0; + InsertStmt *insert = (InsertStmt *) node; + + message->type = node->type; + + + /* insert target table */ + table = insert->relation; + if (!table) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot find table name"); + return; + } + + /* pool_debug("exam_InsertStmt insert table_name %s:",table->relname); */ + + info = pool_get_dist_def_info(MASTER_CONNECTION(backend)->sp->database, + table->schemaname, + table->relname); + + if (!info) + { + /* send error message to frontend */ + message->r_code = INSERT_DIST_NO_RULE; + return; + } + + /* the source SELECT ? */ + if (insert->selectStmt && ((SelectStmt *)insert->selectStmt)->targetList) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot use SelectStmt in InsertStmt"); + return; + } + + list_t = (List *)(((SelectStmt *)insert->selectStmt)->valuesLists); + + if (!list_t) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot find target List"); + return; + } + + /* number of target list */ + + if(list_t->length == 1 && IsA(lfirst(list_head(list_t)),List)) + { + cell_num = ((List *) lfirst(list_head(list_t)))->length; + } + else + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot analzye this InsertStmt"); + return; + } + + + /* Is the target columns ?*/ + if (!insert->cols) + { + div_key_num = info->dist_key_col_id; + dist_def_flag = 1; + + pool_debug("cell number %d, div key num %d, div_key columname %s",cell_num,div_key_num,info->col_list[div_key_num]); + + if (cell_num < div_key_num) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot find dividing key in InsertStmt"); + return; + } + + } + else + { + List *list_cols = (List *) insert->cols; + + foreach(lc, list_cols) + { + Node *n; + ResTarget *target; + n = lfirst(lc); + target = (ResTarget *) n; + if (strcmp(target->name,info->dist_key_col_name) == 0) + { + dist_def_flag = 1; + break; + } + div_key_num++; + } + + if (cell_num < div_key_num) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot find dividing key in InsertStmt"); + return; + } + } + + if (dist_def_flag != 1) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot find dividing key in InsertStmt"); + return; + } + + /* this loop get insert one args of divide rule */ + node_number = getInsertRule(lc, list_t, info, div_key_num); + + if (node_number < 0) + { + /* send error message to frontend */ + message->r_code = INSERT_SQL_RESTRICTION; + message->r_node = -1; + message->rewrite_query = pool_error_message("cannot get node_id from system db"); + return; + } + + pool_debug("insert node_number =%d",node_number); + message->r_code = 0; + message->r_node = node_number; + message->rewrite_query = nodeToString(node); +} + +/* start of rewriting query */ +static void examSelectStmt(Node *node,POOL_CONNECTION_POOL *backend,RewriteQuery *message) +{ + static ConInfoTodblink dblink; + + /* initialize dblink info */ + initdblink(&dblink,backend); + + /* initialize message */ + initMessage(message); + message->type = node->type; + message->r_code = SELECT_DEFAULT; + + /* do rewrite query */ + nodeToRewriteString(message,&dblink,node); +} + +/* initialize Message */ +static void initMessage(RewriteQuery *message) +{ + message->r_code = 0; + message->r_node = 0; + message->column = 0; + message->virtual_num = 0; + message->is_pg_catalog = false; + message->is_loadbalance = false; + message->is_parallel = false; + message->table_relname = NULL; + message->table_alias = NULL; + message->dbname = NULL; + message->schemaname = NULL; + message->rewrite_query = NULL; + message->rewritelock = -1; + message->ignore_rewrite = -1; + message->ret_num = 0; +} + +/* set dblink info */ +static void initdblink(ConInfoTodblink *dblink,POOL_CONNECTION_POOL *backend) +{ + dblink->dbname = MASTER_CONNECTION(backend)->sp->database; + dblink->hostaddr = pool_config->pgpool2_hostname; + dblink->user = MASTER_CONNECTION(backend)->sp->user; + dblink->port = pool_config->port; + dblink->password = MASTER_CONNECTION(backend)->con->password; +} + +/* reference of pg_catalog or not */ +int IsSelectpgcatalog(Node *node,POOL_CONNECTION_POOL *backend) +{ + static ConInfoTodblink dblink; + static RewriteQuery message; + + /* initialize dblink info */ + initdblink(&dblink,backend); + + /* initialize message */ + initMessage(&message); + + message.type = node->type; + + initdblink(&dblink,backend); + + if(message.is_pg_catalog) + { + pool_debug("Isselectpgcatalog %d",message.is_pg_catalog); + return 1; + } + else + { + return 0; + } +} + +/* + * SELECT statement or INSERT statement is special, + * peculiar process is needed in parallel mode. + */ +RewriteQuery *rewrite_query_stmt(Node *node,POOL_CONNECTION *frontend,POOL_CONNECTION_POOL *backend,RewriteQuery *message) +{ + switch(node->type) + { + case T_SelectStmt: + { + SelectStmt *stmt = (SelectStmt *)node; + + /* Because "SELECT INTO" cannot be used in a parallel mode, + * the error message is generated and send "ready for query" to frontend. + */ + if(stmt->intoClause) + { + pool_send_error_message(frontend, MAJOR(backend), "XX000", + "pgpool2 sql restriction", + "cannot use select into ...", "", __FILE__, + __LINE__); + + + pool_send_readyforquery(frontend); + message->status=POOL_CONTINUE; + break; + } + + /* + * The Query is actually rewritten based on analytical information on the Query. + */ + examSelectStmt(node,backend,message); + + if (message->r_code != SELECT_PGCATALOG && + message->r_code != SELECT_RELATION_ERROR) + { + /* + * The rewritten Query is transmitted to system db, + * and execution status is received. + */ + POOL_CONNECTION_POOL_SLOT *system_db = pool_system_db_connection(); + message->status = OneNode_do_command(frontend, + system_db->con, + message->rewrite_query, + backend->info->database); + } + else + { + if(TSTATE(backend) == 'T' && + message->r_code == SELECT_RELATION_ERROR) + { + /* + * In the case of message->r_code == SELECT_RELATION_ERROR and in the transaction, + * Transmit the Query to all back ends, and to abort transaction. + */ + pool_debug("pool_rewrite_stmt(select): Inside transaction. abort transaction"); + message->rewrite_query = nodeToString(node); + message->status = pool_parallel_exec(frontend,backend,message->rewrite_query,node,true); + } + else + { + /* + * Ohter cases of message->r_code == SELECT_RELATION_ERROR + * or SELECT_PG_CATALOG, + * Transmit the Query to Master node and receive status. + */ + pool_debug("pool_rewrite_stmt: executed by Master"); + message->rewrite_query = nodeToString(node); + message->status = OneNode_do_command(frontend, + MASTER(backend), + message->rewrite_query, + backend->info->database); + } + } + pool_debug("pool_rewrite_stmt: select message_code %d",message->r_code); + } + break; + + case T_InsertStmt: + + /* The distribution of the INSERT sentence. */ + examInsertStmt(node,backend,message); + + if(message->r_code == 0 ) + { + /* send the INSERT sentence */ + message->status = OneNode_do_command(frontend, + CONNECTION(backend,message->r_node), + message->rewrite_query, + backend->info->database); + } + else if (message->r_code == INSERT_SQL_RESTRICTION) + { + /* Restriction case of INSERT sentence */ + pool_send_error_message(frontend, MAJOR(backend), "XX000", + "pgpool2 sql restriction", + message->rewrite_query, "", __FILE__, + __LINE__); + + if(TSTATE(backend) == 'T') + { + /* In Transaction, send the invalid message to backend to abort this transaction */ + pool_debug("rewrite_query_stmt(insert): Inside transaction. Abort transaction"); + message->status = pool_parallel_exec(frontend,backend, "POOL_RESET_TSTATE",node,false); + } + else + { + /* return "ready for query" to frontend */ + pool_send_readyforquery(frontend); + message->status=POOL_CONTINUE; + } + } + break; +#if 0 + case T_UpdateStmt: + /* Improve UpdateStmt for complex query */ + break; +#endif + default: + message->type = node->type; + message->status = POOL_CONTINUE; + break; + } + + pool_debug("pool_rewrite_stmt: query rule %d",node->type); + + return message; +} + +#define POOL_PARALLEL "pool_parallel" +#define POOL_LOADBALANCE "pool_loadbalance" + +/* + * After analyzing query, check the analyze[0]->state. + * if the analyze[0]->state ==`P`, this query can be executed + * on parallel engine. + */ +static int direct_parallel_query(RewriteQuery *message) +{ + if(message && message->analyze[0] && message->analyze[0]->state == 'P') + return 1; + else + return 0; +} + + +/* escape delimiter character */ +static char *delimistr(char *str) +{ + char *result; + int i,j = 0; + int len = strlen(str); + + result = palloc(len -1); + + for(i = 0; i < len; i++) + { + char c = (unsigned char) str[i]; + if((i != 0) && (i != len -1)) + { + if(c=='\'' && (char) str[i+1]=='\'') + i++; + result[j] = c; + j++; + } + } + + result[j] = '\0'; + + return result; +} + +/* for debug */ +void analyze_debug(RewriteQuery *message) +{ + int analyze_num,i; + analyze_num = message->analyze_num; + + for(i = 0; i< analyze_num; i++) + { + AnalyzeSelect *analyze = message->analyze[i]; + pool_debug("analyze_debug :select no(%d), last select(%d), last_part(%d), state(%c)", + analyze->now_select,analyze->last_select,analyze->call_part,analyze->state); + } +} + +/* + * This function checks the KEYWORD(POOL_PARALLEL,POOL_LOADBALANCE) + * if the special function(like pool_parallel() or pool_loadbalance()) + * is used, mark the r_code,is_parallel and is_loadbalance. + * In othe cases, It is necessary to analyze the Query. + */ +RewriteQuery *is_parallel_query(Node *node, POOL_CONNECTION_POOL *backend) +{ + static RewriteQuery message; + static ConInfoTodblink dblink; + + initMessage(&message); + + if (IsA(node, SelectStmt)) + { + SelectStmt *stmt; + Node *n; + int direct_ok; + + stmt = (SelectStmt *) node; + + /* Check the special function is used in this query*/ + if (!(stmt->distinctClause || stmt->intoClause || + stmt->fromClause || stmt->groupClause || stmt->havingClause || + stmt->sortClause || stmt->limitOffset || stmt->limitCount || + stmt->lockingClause || stmt->larg || stmt->rarg) && + (n = lfirst(list_head(stmt->targetList))) && IsA(n, ResTarget)) + { + ResTarget *target = (ResTarget *) n; + + if (target->val && IsA(target->val, FuncCall)) + { + FuncCall *func = (FuncCall *) target->val; + if (list_length(func->funcname) == 1 && func->args) + { + Node *func_args = (Node *) lfirst(list_head(func->args)); + message.rewrite_query = delimistr(nodeToString(func_args)); + + /* pool_parallel() is used in this query */ + if(strcmp(strVal(lfirst(list_head(func->funcname))), + POOL_PARALLEL) == 0) + { + message.r_code = SEND_PARALLEL_ENGINE; + message.is_parallel = true; + message.is_loadbalance = false; + pool_debug("can pool_parallel_exec %s",message.rewrite_query); + return &message; + } + else /* pool_loadbalance() is used in this query */ + if(strcmp(strVal(lfirst(list_head(func->funcname))), + POOL_LOADBALANCE) == 0) + { + message.r_code = SEND_LOADBALANCE_ENGINE; + message.is_loadbalance = true; + message.is_parallel = false; + pool_debug("can loadbalance_mode %s",message.rewrite_query); + return &message; + } + } + } + } + + /* ANALYZE QUERY */ + message.r_code = SELECT_ANALYZE; + message.is_loadbalance = true; + + initdblink(&dblink,backend); + nodeToRewriteString(&message,&dblink,node); + + if(message.is_pg_catalog) + { + message.is_loadbalance = false; + message.is_parallel = false; + pool_debug("is_parallel_query: query is done by loadbalance(pgcatalog)"); + return &message; + } + + if(message.is_loadbalance) + { + message.is_parallel = false; + pool_debug("is_parallel_query: query is done by loadbalance"); + return &message; + } + + /* Analyzing Query Start */ + analyze_debug(&message); + + /* After the analyzing query, + * this query can be executed as parallel exec, is_parallel flag is turned on + */ + direct_ok = direct_parallel_query(&message); + if(direct_ok == 1) + { + message.rewrite_query = nodeToString(node); + message.is_parallel = true; + message.is_loadbalance = false; + pool_debug("can pool_parallel_exec %s",message.rewrite_query); + return &message; + } + } + else if (IsA(node, CopyStmt)) + { + /* For Copy Statement, check the table name, mark the is_parallel flag. */ + CopyStmt *stmt = (CopyStmt *)node; + + if (stmt->is_from == FALSE && stmt->filename == NULL) + { + RangeVar *relation = (RangeVar *)stmt->relation; + + /* check on distribution table or replicate table */ + + if(pool_get_dist_def_info (MASTER_CONNECTION(backend)->sp->database, relation->schemaname, relation->relname)) + { + message.rewrite_query = nodeToString(stmt); + message.is_parallel = true; + message.is_loadbalance = false; + message.r_code = SEND_PARALLEL_ENGINE; + } + } + } + + return &message; +} diff --git a/pool_rewrite_query.h b/pool_rewrite_query.h new file mode 100644 index 0000000..83704bf --- /dev/null +++ b/pool_rewrite_query.h @@ -0,0 +1,183 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_rewrite_query.h,v 1.8 2009/01/30 00:06:53 y-mori Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_rewrite_query.h: rewrite_query + * + */ + +#include "parser/nodes.h" +#include "parser/parser.h" +#include "parser/pg_list.h" +#include "parser/parsenodes.h" +#include "parser/pool_memory.h" +#include "parser/pool_string.h" + +/* return code set */ +#define INSERT_SQL_RESTRICTION 1 +#define SELECT_INIT 2 +#define SELECT_BACKEND_CONNECT 3 +#define SELECT_NOT_BACKEND_CONNECT 4 +#define SELECT_PGCATALOG 5 +#define SELECT_CHECK_PGCATALOG_REPLICATION 6 +#define SELECT_DEFAULT 7 +#define SELECT_DEFAULT_INSIDE_DBLINK 8 +#define SELECT_AEXPR 9 +#define SELECT_AEXPR_FALSE 10 +#define SELECT_ONETABLE 11 +#define SELECT_ONETABLE_FALSE 12 +#define SELECT_RELATION_ERROR 13 +#define INSERT_DIST_NO_RULE 14 +#define SEND_PARALLEL_ENGINE 15 +#define SEND_LOADBALANCE_ENGINE 16 +#define SELECT_NOT_REPLICATION 17 +#define SELECT_REWRITE 18 +#define SELECT_ANALYZE 19 +#define SELECT_DEFAULT_PREP 20 + +/* build Sub-Select`s target List */ +typedef struct { + char **col_list; /* column list */ + char **type_list; /* type list */ + int *return_list; /* order of col_list */ + int col_num; /* column number */ + bool valid; /* return to frontend */ +} SelectDefInfo; + +/* This struct is used as each table/sub-select of FROM-CLUASE */ +typedef struct { + DistDefInfo *distinfo; /* distribution table into */ + RepliDefInfo *repliinfo; /* replication table info */ + SelectDefInfo *selectinfo; /* Sub-Select info */ + char *alias; /* alias name */ + char state; /* P = parallel, L = loadbarance S = systemdb(dblink) E = error*/ + int ret_num; /* build column number */ +} RangeInfo; + +/* build Virtual Table of FROM-Cluase */ +typedef struct { + char **col_list; /* column list */ + char **type_list; /* type list */ + char **table_list; /* table list */ + char *state_list; /* state of each column */ + int *column_no; /* order of column */ + int *valid; /* valid column is true */ + int col_num; /* virtual table column num */ +} VirtualTable; + +/* this struct is used by JOIN Expr */ +typedef struct { + char **col_list; /* column list */ + char **type_list; /* type list */ + char **table_list; /* table list */ + char state; /* P = parallel, L = loadbarance S = systemdb(dblink) E = error*/ + int *valid; /* valid column is true */ + int col_num; /* number of colum */ + char **using_list; /* if join expr has using-list, column name is listed up */ + int using_length; /* column number of using-list */ +} JoinTable; + +/* this struct is used in optimization of aggregate opr */ +typedef struct { + ColumnRef **usec_p; /* targetlist columns */ + FuncCall **tfunc_p; /* targetlist funcs */ + ColumnRef **col_p; /* group by columns */ + FuncCall **hfunc_p; /* having funcs */ + int *umapc; /* order of number */ + int u_num; /* targetlist columns num */ + int t_num; /* targetlist funcs num */ + int c_num; /* group by column num */ + int h_num; /* having funcs num */ + int hc_num; /* having column num */ + int s_num; /* sort funcs num */ + int sc_num; /* sort column num */ + bool opt; /* optimization flag */ +} Aggexpr; + +/* main struct of alanyzing query */ +typedef struct { + int now_select; /* rank of select */ + int part; /* the postion of analyzing select statement */ + int last_select; /* caller select rank */ + int call_part; /* caller's potion */ + int from_num; /* number for from-cluase */ + int larg_count; /* left arg count */ + int rarg_count; /* right arg count */ + int ret_count; /* return list count */ + char state; /* final state */ + char *table_name; /* table name or virtual table name */ + char partstate[8]; /* state of analyzing part */ + bool select_union; /* if UNION is used, this flag is true */ + bool select_range; /* RangeSubSelect is used */ + bool aggregate; /* aggregate optimaztion ? */ + bool retlock; /* this is used */ + Aggexpr *aggexpr; /* Aggexpr in this statement*/ + RangeInfo **range; /* RangeInfo in from cluase */ + int rangeinfo_num; /* RangeInfo's number in this select statement*/ + VirtualTable *virtual; /* Virtual Table in this select statment */ + JoinTable *join; /* sumary of join table */ + SelectDefInfo *select_ret; /* build return list */ +} AnalyzeSelect; + +/* + * This struct is used as Information that relates + * to distribution processing of parallel query + */ +typedef struct { + int r_code; /* analyze or rewrite */ + int r_node; /* which node, query is sent */ + int part; /* part of select statment */ + int rewritelock; /* dblink start postion and lock rewrite */ + int analyze_num; /* sum of AnalyzeSelect */ + int current_select; /* postion of analyze[] */ + int ignore_rewrite; /* dont rewrite */ + int column; /* column number */ + int virtual_num; /* Virtual table column number */ + int ret_num; /* expect return cloumn number */ + bool is_pg_catalog; /* reference of pg_catalog */ + bool is_loadbalance; /* load ballance ? */ + bool is_parallel; /* can paralle exec ? */ + bool fromClause; /* having FromCluase ? */ + char *table_relname; /* table name */ + char *table_alias; /* table alias name */ + char *schemaname; /* schema */ + char *dbname; /* connect dbname */ + char *rewrite_query; /* execute query */ + char table_state; /* final state */ + POOL_STATUS status; /* return POOL_STATUS */ + NodeTag type; /* Query Type */ + AnalyzeSelect **analyze; /* point to analyzing result */ +} RewriteQuery; + +/* This info is used in dblink */ +typedef struct { + char *hostaddr; /* hostname */ + char *dbname; /* data base name */ + char *user; /* access user name */ + int port; /* access port number */ + char *password; /* passward of connection */ +} ConInfoTodblink; + +extern RewriteQuery *rewrite_query_stmt(Node *node, POOL_CONNECTION *frontend,POOL_CONNECTION_POOL *backend,RewriteQuery *message); +extern void nodeToRewriteString(RewriteQuery *message, ConInfoTodblink *dblink,void *obj); +char *pool_error_message(char *message); +extern int IsSelectpgcatalog(Node *node,POOL_CONNECTION_POOL *backend); +extern RewriteQuery *is_parallel_query(Node *node,POOL_CONNECTION_POOL *backend); +extern POOL_STATUS pool_parallel_exec(POOL_CONNECTION *frontend,POOL_CONNECTION_POOL *backend, char *string,Node *node,bool send_to_frontend); + diff --git a/pool_sema.c b/pool_sema.c new file mode 100644 index 0000000..820a799 --- /dev/null +++ b/pool_sema.c @@ -0,0 +1,161 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_sema.c,v 1.5.2.2 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2009, PgPool Global Development Group + * Portions Copyright (c) 2003-2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + */ +#include "pool.h" + +#include +#include +#include + +#include "pool_ipc.h" + + +#ifndef HAVE_UNION_SEMUN +union semun +{ + int val; + struct semid_ds *buf; + unsigned short *array; +}; +#endif + + +static int semId; + + +/* + * Removes a semaphore set. + */ +static void +IpcSemaphoreKill(int status, Datum semId) +{ + union semun semun; + struct semid_ds seminfo; + + /* + * Is a previously-existing sema segment still existing and in use? + */ + semun.buf = &seminfo; + if (semctl(semId, 0, IPC_STAT, semun) < 0 + && (errno == EINVAL || errno == EACCES +#ifdef EIDRM + || errno == EIDRM +#endif + )) + return; + + semun.val = 0; /* unused, but keep compiler quiet */ + + if (semctl(semId, 0, IPC_RMID) < 0) + pool_log("semctl(%lu, 0, IPC_RMID, ...) failed: %s", semId, strerror(errno)); +} + +/* + * Create a semaphore set and initialize. + */ +int +pool_semaphore_create(int numSems) +{ + int i; + + /* Try to create new semaphore set */ + semId = semget(IPC_PRIVATE, numSems, IPC_CREAT | IPC_EXCL | IPCProtection); + + if (semId < 0) + { + pool_error("could not create %d semaphores: %s", numSems, strerror(errno)); + return -1; + } + + on_shmem_exit(IpcSemaphoreKill, semId); + + /* Initialize it to count 1 */ + for (i = 0; i < numSems; i++) + { + union semun semun; + + semun.val = 1; + if (semctl(semId, i, SETVAL, semun) < 0) + { + pool_error("semctl(%d, %d, SETVAL, %d) failed: %s", + semId, i, 1, strerror(errno)); + return -1; + } + } + + return 0; +} + +/* + * Lock a semaphore (decrement count), blocking if count would be < 0 + */ +void +pool_semaphore_lock(int semNum) +{ + int errStatus; + struct sembuf sops; + + sops.sem_op = -1; /* decrement */ + sops.sem_flg = 0; + sops.sem_num = semNum; + + /* + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. + */ + do + { + errStatus = semop(semId, &sops, 1); + } while (errStatus < 0 && errno == EINTR); + + if (errStatus < 0) + pool_error("semop(id=%d) failed: %s", semId, strerror(errno)); +} + +/* + * Unlock a semaphore (increment count) + */ +void +pool_semaphore_unlock(int semNum) +{ + int errStatus; + struct sembuf sops; + + sops.sem_op = 1; /* increment */ + sops.sem_flg = 0; + sops.sem_num = semNum; + + /* + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and unlock the semaphore again. Not clear this can really happen, + * but might as well cope. + */ + do + { + errStatus = semop(semId, &sops, 1); + } while (errStatus < 0 && errno == EINTR); + + if (errStatus < 0) + pool_error("semop(id=%d) failed: %s", semId, strerror(errno)); +} diff --git a/pool_shmem.c b/pool_shmem.c new file mode 100644 index 0000000..621f104 --- /dev/null +++ b/pool_shmem.c @@ -0,0 +1,181 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_shmem.c,v 1.3.2.2 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2009, PgPool Global Development Group + * Portions Copyright (c) 2003-2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + */ +#include "pool.h" + +#include +#include +#include + +#include "pool_ipc.h" + + +#ifdef SHM_SHARE_MMU /* use intimate shared memory on Solaris */ +#define PG_SHMAT_FLAGS SHM_SHARE_MMU +#else +#define PG_SHMAT_FLAGS 0 +#endif + + +#define MAX_ON_EXITS 20 + +static struct ONEXIT +{ + void (*function) (int code, Datum arg); + Datum arg; +} on_shmem_exit_list[MAX_ON_EXITS]; + +static int on_shmem_exit_index; + + +static void IpcMemoryDetach(int status, Datum shmaddr); +static void IpcMemoryDelete(int status, Datum shmId); + + +/* + * Create a shared memory segment of the given size and initialize. Also, + * register an on_shmem_exit callback to release the storage. + */ +void * +pool_shared_memory_create(size_t size) +{ + int shmid; + void *memAddress; + + /* Try to create new segment */ + shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | IPC_EXCL | IPCProtection); + + if (shmid < 0) + { + pool_error("could not create shared memory segment: %s", + strerror(errno)); + return NULL; + } + + /* Register on-exit routine to delete the new segment */ + on_shmem_exit(IpcMemoryDelete, shmid); + + /* OK, should be able to attach to the segment */ + memAddress = shmat(shmid, NULL, PG_SHMAT_FLAGS); + + if (memAddress == (void *) -1) + { + pool_error("shmat(id=%d) failed: %s", shmid, strerror(errno)); + return NULL; + } + + /* Register on-exit routine to detach new segment before deleting */ + on_shmem_exit(IpcMemoryDetach, (Datum) memAddress); + + return memAddress; +} + +/* + * Removes a shared memory segment from process' address spaceq (called as + * an on_shmem_exit callback, hence funny argument list) + */ +static void +IpcMemoryDetach(int status, Datum shmaddr) +{ + if (shmdt((void *) shmaddr) < 0) + pool_log("shmdt(%p) failed: %s", (void *) shmaddr, strerror(errno)); +} + +/* + * Deletes a shared memory segment (called as an on_shmem_exit callback, + * hence funny argument list) + */ +static void +IpcMemoryDelete(int status, Datum shmId) +{ + struct shmid_ds shmStat; + + /* + * Is a previously-existing shmem segment still existing and in use? + */ + if (shmctl(shmId, IPC_STAT, &shmStat) < 0 + && (errno == EINVAL || errno == EACCES)) + return; + else if (shmStat.shm_nattch != 0) + return; + + if (shmctl(shmId, IPC_RMID, NULL) < 0) + pool_log("shmctl(%lu, %d, 0) failed: %s", + shmId, IPC_RMID, strerror(errno)); +} + +void +pool_shmem_exit(int code) +{ + shmem_exit(code); +} + +/* + * Run all of the on_shmem_exit routines --- but don't actually exit. This + * is used by the postmaster to re-initialize shared memory and semaphores + * after a backend dies horribly. + */ +void +shmem_exit(int code) +{ + pool_debug("shmem_exit(%d)", code); + + /* + * Call all the registered callbacks. + * + * As with proc_exit(), we remove each callback from the list before + * calling it, to avoid infinite loop in case of error. + */ + while (--on_shmem_exit_index >= 0) + (*on_shmem_exit_list[on_shmem_exit_index].function) (code, + on_shmem_exit_list[on_shmem_exit_index].arg); + + on_shmem_exit_index = 0; +} + +/* + * This function adds a callback function to the list of functions invoked + * by shmem_exit(). + */ +void +on_shmem_exit(void (*function) (int code, Datum arg), Datum arg) +{ + if (on_shmem_exit_index >= MAX_ON_EXITS) + pool_error("out of on_shmem_exit slots"); + + on_shmem_exit_list[on_shmem_exit_index].function = function; + on_shmem_exit_list[on_shmem_exit_index].arg = arg; + + ++on_shmem_exit_index; +} + +/* + * This function clears all on_proc_exit() and on_shmem_exit() registered + * functions. This is used just after forking a backend, so that the + * backend doesn't believe it should call the postmaster's on-exit routines + * when it exits... + */ +void +on_exit_reset(void) +{ + on_shmem_exit_index = 0; +} diff --git a/pool_signal.c b/pool_signal.c new file mode 100644 index 0000000..2b3c09e --- /dev/null +++ b/pool_signal.c @@ -0,0 +1,158 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_signal.c,v 1.3.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 2003-2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + */ + +/* + * Signal stuff. Stolen from PostgreSQL source code. + */ + +#include "config.h" +#include "pool_signal.h" +#include + +#ifdef HAVE_SIGPROCMASK +sigset_t UnBlockSig, + BlockSig, + AuthBlockSig; + +#else +int UnBlockSig, + BlockSig, + AuthBlockSig; +#endif + +/* + * Initialize BlockSig, UnBlockSig, and AuthBlockSig. + * + * BlockSig is the set of signals to block when we are trying to block + * signals. This includes all signals we normally expect to get, but NOT + * signals that should never be turned off. + * + * AuthBlockSig is the set of signals to block during authentication; + * it's essentially BlockSig minus SIGTERM, SIGQUIT, SIGALRM. + * + * UnBlockSig is the set of signals to block when we don't want to block + * signals (is this ever nonzero??) + */ +void +poolinitmask(void) +{ +#ifdef HAVE_SIGPROCMASK + sigemptyset(&UnBlockSig); + sigfillset(&BlockSig); + sigfillset(&AuthBlockSig); + + /* + * Unmark those signals that should never be blocked. Some of these + * signal names don't exist on all platforms. Most do, but might as + * well ifdef them all for consistency... + */ +#ifdef SIGTRAP + sigdelset(&BlockSig, SIGTRAP); + sigdelset(&AuthBlockSig, SIGTRAP); +#endif +#ifdef SIGABRT + sigdelset(&BlockSig, SIGABRT); + sigdelset(&AuthBlockSig, SIGABRT); +#endif +#ifdef SIGILL + sigdelset(&BlockSig, SIGILL); + sigdelset(&AuthBlockSig, SIGILL); +#endif +#ifdef SIGFPE + sigdelset(&BlockSig, SIGFPE); + sigdelset(&AuthBlockSig, SIGFPE); +#endif +#ifdef SIGSEGV + sigdelset(&BlockSig, SIGSEGV); + sigdelset(&AuthBlockSig, SIGSEGV); +#endif +#ifdef SIGBUS + sigdelset(&BlockSig, SIGBUS); + sigdelset(&AuthBlockSig, SIGBUS); +#endif +#ifdef SIGSYS + sigdelset(&BlockSig, SIGSYS); + sigdelset(&AuthBlockSig, SIGSYS); +#endif +#ifdef SIGCONT + sigdelset(&BlockSig, SIGCONT); + sigdelset(&AuthBlockSig, SIGCONT); +#endif +#ifdef SIGTERM + sigdelset(&AuthBlockSig, SIGTERM); +#endif +#ifdef SIGQUIT + sigdelset(&AuthBlockSig, SIGQUIT); +#endif +#ifdef SIGALRM + sigdelset(&AuthBlockSig, SIGALRM); +#endif +#else + UnBlockSig = 0; + BlockSig = sigmask(SIGHUP) | sigmask(SIGQUIT) | + sigmask(SIGTERM) | sigmask(SIGALRM) | + sigmask(SIGINT) | sigmask(SIGUSR1) | + sigmask(SIGUSR2) | sigmask(SIGCHLD) | + sigmask(SIGWINCH) | sigmask(SIGFPE); + AuthBlockSig = sigmask(SIGHUP) | + sigmask(SIGINT) | sigmask(SIGUSR1) | + sigmask(SIGUSR2) | sigmask(SIGCHLD) | + sigmask(SIGWINCH) | sigmask(SIGFPE); +#endif +} + + +/* Win32 signal handling is in backend/port/win32/signal.c */ +#ifndef WIN32 + +/* + * We need to check actually the system has the posix signals or not, but... + */ +#define HAVE_POSIX_SIGNALS +/* + * Set up a signal handler + */ +pool_sighandler_t +pool_signal(int signo, pool_sighandler_t func) +{ +#if !defined(HAVE_POSIX_SIGNALS) + return signal(signo, func); +#else + struct sigaction act, + oact; + + act.sa_handler = func; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; + if (signo != SIGALRM) + act.sa_flags |= SA_RESTART; +#ifdef SA_NOCLDSTOP + if (signo == SIGCHLD) + act.sa_flags |= SA_NOCLDSTOP; +#endif + if (sigaction(signo, &act, &oact) < 0) + return SIG_ERR; + return oact.sa_handler; +#endif /* !HAVE_POSIX_SIGNALS */ +} + +#endif /* WIN32 */ diff --git a/pool_signal.h b/pool_signal.h new file mode 100644 index 0000000..8a518b2 --- /dev/null +++ b/pool_signal.h @@ -0,0 +1,61 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_signal.h,v 1.4 2008/01/29 01:56:36 y-asaba Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008, PgPool Global Development Group + * Portions Copyright (c) 2004, PostgreSQL Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool.h.: master definition header file + * + */ + +#ifndef POOL_SIGNAL_H +#define POOL_SIGNAL_H + +/* + * Signal stuff. Stolen from PostgreSQL source code. + */ +#include + +#ifdef HAVE_SIGPROCMASK +extern sigset_t UnBlockSig, + BlockSig, + AuthBlockSig; + +#define POOL_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL) +#define POOL_SETMASK2(mask, oldmask) sigprocmask(SIG_SETMASK, mask, oldmask) +#else +extern int UnBlockSig, + BlockSig, + AuthBlockSig; + +#ifndef WIN32 +#define POOL_SETMASK(mask) sigsetmask(*((int*)(mask))) +#define POOL_SETMASK2(mask, oldmask) do {oldmask = POOL_SETMASK(mask)} while (0) +#else +#define POOL_SETMASK(mask) pqsigsetmask(*((int*)(mask))) +#define POOL_SETMASK2(mask, oldmask) do {oldmask = POOL_SETMASK(mask)} while (0) +int pqsigsetmask(int mask); +#endif +#endif + +typedef void (*pool_sighandler_t) (int); +extern pool_sighandler_t pool_signal(int signo, pool_sighandler_t func); +extern void poolinitmask(void); + +#endif /* POOL_SIGNAL_H */ diff --git a/pool_stream.c b/pool_stream.c new file mode 100644 index 0000000..efb496f --- /dev/null +++ b/pool_stream.c @@ -0,0 +1,790 @@ +/* -*-pgsql-c-*- */ +/* +* $Header: /cvsroot/pgpool/pgpool-II/pool_stream.c,v 1.14.2.2 2009/08/22 04:19:49 t-ishii Exp $ +* +* pgpool: a language independent connection pool server for PostgreSQL +* written by Tatsuo Ishii +* +* Copyright (c) 2003-2009 PgPool Global Development Group +* +* Permission to use, copy, modify, and distribute this software and +* its documentation for any purpose and without fee is hereby +* granted, provided that the above copyright notice appear in all +* copies and that both that copyright notice and this permission +* notice appear in supporting documentation, and that the name of the +* author not be used in advertising or publicity pertaining to +* distribution of the software without specific, written prior +* permission. The author makes no representations about the +* suitability of this software for any purpose. It is provided "as +* is" without express or implied warranty. +* +* pool_stream.c: stream I/O modules +* +*/ + +#include "config.h" + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "pool.h" + +#define READBUFSZ 1024 +#define WRITEBUFSZ 8192 + +static int mystrlen(char *str, int upper, int *flag); +static int mystrlinelen(char *str, int upper, int *flag); +static int save_pending_data(POOL_CONNECTION *cp, void *data, int len); +static int consume_pending_data(POOL_CONNECTION *cp, void *data, int len); + +/* +* open read/write file descriptors. +* returns POOL_CONNECTION on success otherwise NULL. +*/ +POOL_CONNECTION *pool_open(int fd) +{ + POOL_CONNECTION *cp; + + cp = (POOL_CONNECTION *)malloc(sizeof(POOL_CONNECTION)); + if (cp == NULL) + { + pool_error("pool_open: malloc failed: %s", strerror(errno)); + return NULL; + } + + memset(cp, 0, sizeof(*cp)); + + /* initialize write buffer */ + cp->wbuf = malloc(WRITEBUFSZ); + if (cp->wbuf == NULL) + { + pool_error("pool_open: malloc failed"); + return NULL; + } + cp->wbufsz = WRITEBUFSZ; + cp->wbufpo = 0; + + /* initialize pending data buffer */ + cp->hp = malloc(READBUFSZ); + if (cp->hp == NULL) + { + pool_error("pool_open: malloc failed"); + return NULL; + } + cp->bufsz = READBUFSZ; + cp->po = 0; + cp->len = 0; + cp->sbuf = NULL; + cp->sbufsz = 0; + cp->buf2 = NULL; + cp->sbufsz = 0; + + cp->fd = fd; + return cp; +} + +/* +* close read/write file descriptors. +*/ +void pool_close(POOL_CONNECTION *cp) +{ + /* + * shutdown connection to the client so that pgpool is not blocked + */ + if (!cp->isbackend) + shutdown(cp->fd, 1); + close(cp->fd); + + free(cp->wbuf); + free(cp->hp); + if (cp->sbuf) + free(cp->sbuf); + if (cp->buf2) + free(cp->buf2); + pool_discard_params(&cp->params); + free(cp); +} + +/* +* read len bytes from cp +* returns 0 on success otherwise -1. +*/ +int pool_read(POOL_CONNECTION *cp, void *buf, int len) +{ + static char readbuf[READBUFSZ]; + + int consume_size; + int readlen; + + consume_size = consume_pending_data(cp, buf, len); + len -= consume_size; + buf += consume_size; + + while (len > 0) + { + if (pool_check_fd(cp)) + { + if (!IS_MASTER_NODE_ID(cp->db_node_id)) + { + pool_log("pool_read: data is not ready in DB node: %d. abort this session", + cp->db_node_id); + exit(1); + } + else + { + pool_error("pool_read: pool_check_fd failed (%s)", strerror(errno)); + return -1; + } + } + + readlen = read(cp->fd, readbuf, READBUFSZ); + if (readlen == -1) + { + if (errno == EINTR || errno == EAGAIN) + { + pool_debug("pool_read: retrying due to %s", strerror(errno)); + continue; + } + + pool_error("pool_read: read failed (%s)", strerror(errno)); + + if (cp->isbackend) + { + /* fatal error, notice to parent and exit */ + notice_backend_error(cp->db_node_id); + child_exit(1); + } + else + { + return -1; + } + } + else if (readlen == 0) + { + if (cp->isbackend) + { + pool_error("pool_read: EOF encountered with backend"); + return -1; + +#ifdef NOT_USED + /* fatal error, notice to parent and exit */ + notice_backend_error(IS_MASTER_NODE_ID(cp->db_node_id)); + child_exit(1); +#endif + } + else + { + /* + * if backend offers authentication method, frontend could close connection + */ + return -1; + } + } + + if (len < readlen) + { + /* overrun. we need to save remaining data to pending buffer */ + if (save_pending_data(cp, readbuf+len, readlen-len)) + return -1; + memmove(buf, readbuf, len); + break; + } + + memmove(buf, readbuf, readlen); + buf += readlen; + len -= readlen; + } + + return 0; +} + +/* +* read exactly len bytes from cp +* returns buffer address on success otherwise NULL. +*/ +char *pool_read2(POOL_CONNECTION *cp, int len) +{ + char *buf; + int req_size; + int alloc_size; + int consume_size; + int readlen; + + req_size = cp->len + len; + + if (req_size > cp->bufsz2) + { + alloc_size = ((req_size+1)/READBUFSZ+1)*READBUFSZ; + cp->buf2 = realloc(cp->buf2, alloc_size); + if (cp->buf2 == NULL) + { + pool_error("pool_read2: failed to realloc"); + exit(1); + } + cp->bufsz2 = alloc_size; + } + + buf = cp->buf2; + + consume_size = consume_pending_data(cp, buf, len); + len -= consume_size; + buf += consume_size; + + while (len > 0) + { + if (pool_check_fd(cp)) + { + if (!IS_MASTER_NODE_ID(cp->db_node_id)) + { + pool_log("pool_read2: data is not ready in DB node:%d. abort this session", + cp->db_node_id); + exit(1); + } + else + { + pool_error("pool_read2: pool_check_fd failed (%s)", strerror(errno)); + return NULL; + } + } + + readlen = read(cp->fd, buf, len); + if (readlen == -1) + { + if (errno == EINTR || errno == EAGAIN) + { + pool_debug("pool_read2: retrying due to %s", strerror(errno)); + continue; + } + + pool_error("pool_read2: read failed (%s)", strerror(errno)); + + if (cp->isbackend) + { + /* fatal error, notice to parent and exit */ + notice_backend_error(cp->db_node_id); + child_exit(1); + } + else + { + return NULL; + } + } + else if (readlen == 0) + { + if (cp->isbackend) + { + pool_error("pool_read2: EOF encountered with backend"); + return NULL; + +#ifdef NOT_USED + /* fatal error, notice to parent and exit */ + notice_backend_error(IS_MASTER_NODE_ID(cp->db_node_id)); + child_exit(1); +#endif + } + else + { + /* + * if backend offers authentication method, frontend could close connection + */ + return NULL; + } + } + + buf += readlen; + len -= readlen; + } + + return cp->buf2; +} + +/* +* write len bytes to cp the write buffer. +* returns 0 on success otherwise -1. +*/ +int pool_write(POOL_CONNECTION *cp, void *buf, int len) +{ + if (len < 0) + { + pool_error("pool_write: invalid request size: %d", len); + return -1; + } + + if (cp->no_forward) + return 0; + + while (len > 0) + { + int remainder = WRITEBUFSZ - cp->wbufpo; + + if (cp->wbufpo >= WRITEBUFSZ) + { + /* + * Write buffer is full. so flush buffer. + * wbufpo is reset in pool_flush_it(). + */ + if (pool_flush_it(cp) == -1) + return -1; + remainder = WRITEBUFSZ; + } + + /* check buffer size */ + if (remainder >= len) + { + /* OK, buffer size is enough. */ + remainder = len; + } + memcpy(cp->wbuf+cp->wbufpo, buf, remainder); + cp->wbufpo += remainder; + buf += remainder; + len -= remainder; + } + + return 0; +} + +/* + * flush write buffer + */ +int pool_flush_it(POOL_CONNECTION *cp) +{ + int sts; + int wlen; + int offset; + wlen = cp->wbufpo; + + if (wlen == 0) + { + return 0; + } + + offset = 0; + + for (;;) + { + errno = 0; + +#ifdef NOT_USED + if (!cp->isbackend) + { + fd_set writemask; + fd_set exceptmask; + + FD_ZERO(&writemask); + FD_ZERO(&exceptmask); + FD_SET(cp->fd, &writemask); + FD_SET(cp->fd, &exceptmask); + + sts = select(cp->fd+1, NULL, &writemask, &exceptmask, NULL); + if (sts == -1) + { + if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK) + continue; + + pool_error("pool_flush_it: select() failed. reason: %s", strerror(errno)); + cp->wbufpo = 0; + return -1; + } + else if (sts == 0) + { + continue; + } + else if (FD_ISSET(cp->fd, &exceptmask)) + { + pool_log("pool_flush_it: exception occured"); + cp->wbufpo = 0; + return -1; + } + } +#endif + sts = write(cp->fd, cp->wbuf + offset, wlen); + + if (sts > 0) + { + wlen -= sts; + + if (wlen == 0) + { + /* write completed */ + break; + } + + else if (wlen < 0) + { + pool_error("pool_flush_it: invalid write size %d", sts); + cp->wbufpo = 0; + return -1; + } + + else + { + /* need to write remaining data */ + offset += sts; + continue; + } + } + + else if (errno == EAGAIN || errno == EINTR) + { + continue; + } + + else + { + pool_error("pool_flush_it: write failed (%s) offset: %d wlen: %d", + strerror(errno), offset, wlen); + cp->wbufpo = 0; + return -1; + } + } + + cp->wbufpo = 0; + + return 0; +} + +/* +* flush write buffer and degenerate/failover if error occurs +*/ +int pool_flush(POOL_CONNECTION *cp) +{ + if (pool_flush_it(cp) == -1) + { + if (cp->isbackend) + { + notice_backend_error(cp->db_node_id); + child_exit(1); + } + else + { + /* + * ignore error on frontend. we need to continue the + * processing with backends + */ + return 0; + } + } + return 0; +} + +/* +* combo of pool_write and pool_flush +*/ +int pool_write_and_flush(POOL_CONNECTION *cp, void *buf, int len) +{ + if (pool_write(cp, buf, len)) + return -1; + return pool_flush(cp); +} + +/* + * read a string until EOF or NULL is encountered. + * if line is not 0, read until new line is encountered. +*/ +char *pool_read_string(POOL_CONNECTION *cp, int *len, int line) +{ + int readp; + int readsize; + int readlen; + int strlength; + int flag; + int consume_size; + +#ifdef DEBUG + static char pbuf[READBUFSZ]; +#endif + + *len = 0; + readp = 0; + + /* initialize read buffer */ + if (cp->sbufsz == 0) + { + cp->sbuf = malloc(READBUFSZ); + if (cp->sbuf == NULL) + { + pool_error("pool_read_string: malloc failed"); + return NULL; + } + cp->sbufsz = READBUFSZ; + *cp->sbuf = '\0'; + } + + /* any pending data? */ + if (cp->len) + { + if (line) + strlength = mystrlinelen(cp->hp+cp->po, cp->len, &flag); + else + strlength = mystrlen(cp->hp+cp->po, cp->len, &flag); + + /* buffer is too small? */ + if ((strlength + 1) > cp->sbufsz) + { + cp->sbufsz = ((strlength+1)/READBUFSZ+1)*READBUFSZ; + cp->sbuf = realloc(cp->sbuf, cp->sbufsz); + if (cp->sbuf == NULL) + { + pool_error("pool_read_string: realloc failed"); + return NULL; + } + } + + /* consume pending and save to read string buffer */ + consume_size = consume_pending_data(cp, cp->sbuf, strlength); + + *len = strlength; + + /* is the string null terminated? */ + if (consume_size == strlength && !flag) + { + /* not null or line terminated. + * we need to read more since we have not encountered NULL or new line yet + */ + readsize = cp->sbufsz - strlength; + readp = strlength; + } + else + { + pool_debug("pool_read_string: read all from pending data. po:%d len:%d", + cp->po, cp->len); + return cp->sbuf; + } + } else + { + readsize = cp->sbufsz; + } + + for (;;) + { + if (pool_check_fd(cp)) + { + if (!IS_MASTER_NODE_ID(cp->db_node_id)) + { + pool_log("pool_read_string: data is not ready in DB node:%d. abort this session", + cp->db_node_id); + exit(1); + } + else + { + pool_error("pool_read_string: pool_check_fd failed (%s)", strerror(errno)); + return NULL; + } + } + + readlen = read(cp->fd, cp->sbuf+readp, readsize); + if (readlen == -1) + { + pool_error("pool_read_string: read() failed. reason:%s", strerror(errno)); + + if (cp->isbackend) + { + notice_backend_error(cp->db_node_id); + child_exit(1); + } + else + { + return NULL; + } + } + else if (readlen == 0) /* EOF detected */ + { + /* + * just returns an error, not trigger failover or degeneration + */ + pool_error("pool_read_string: read () EOF detected"); + return NULL; + } + + /* check overrun */ + if (line) + strlength = mystrlinelen(cp->sbuf+readp, readlen, &flag); + else + strlength = mystrlen(cp->sbuf+readp, readlen, &flag); + + if (strlength < readlen) + { + save_pending_data(cp, cp->sbuf+readp+strlength, readlen-strlength); + *len += strlength; + pool_debug("pool_read_string: total result %d with pending data po:%d len:%d", *len, cp->po, cp->len); + return cp->sbuf; + } + + *len += readlen; + + /* encountered null or newline? */ + if (flag) + { + /* ok we have read all data */ + pool_debug("pool_read_string: total result %d ", *len); + break; + } + + readp += readlen; + readsize = READBUFSZ; + + if ((*len+readsize) > cp->sbufsz) + { + cp->sbufsz += READBUFSZ; + + cp->sbuf = realloc(cp->sbuf, cp->sbufsz); + if (cp->sbuf == NULL) + { + pool_error("pool_read_string: realloc failed"); + return NULL; + } + } + } + return cp->sbuf; +} + +/* + * returns the byte length of str, including \0, no more than upper. + * if encountered \0, flag is set to non 0. + * example: + * mystrlen("abc", 2) returns 2 + * mystrlen("abc", 3) returns 3 + * mystrlen("abc", 4) returns 4 + * mystrlen("abc", 5) returns 4 + */ +static int mystrlen(char *str, int upper, int *flag) +{ + int len; + + *flag = 0; + + for (len = 0;len < upper; len++, str++) + { + if (!*str) + { + len++; + *flag = 1; + break; + } + } + return len; +} + +/* + * returns the byte length of str terminated by \n or \0 (including \n or \0), no more than upper. + * if encountered \0 or \n, flag is set to non 0. + * example: + * mystrlinelen("abc", 2) returns 2 + * mystrlinelen("abc", 3) returns 3 + * mystrlinelen("abc", 4) returns 4 + * mystrlinelen("abc", 5) returns 4 + * mystrlinelen("abcd\nefg", 4) returns 4 + * mystrlinelen("abcd\nefg", 5) returns 5 + * mystrlinelen("abcd\nefg", 6) returns 5 + */ +static int mystrlinelen(char *str, int upper, int *flag) +{ + int len; + + *flag = 0; + + for (len = 0;len < upper; len++, str++) + { + if (!*str || *str == '\n') + { + len++; + *flag = 1; + break; + } + } + return len; +} + +/* + * save pending data + */ +static int save_pending_data(POOL_CONNECTION *cp, void *data, int len) +{ + int reqlen; + size_t realloc_size; + char *p; + + /* to be safe */ + if (cp->len == 0) + cp->po = 0; + + reqlen = cp->po + cp->len + len; + + /* pending buffer is enough? */ + if (reqlen > cp->bufsz) + { + /* too small, enlarge it */ + realloc_size = (reqlen/READBUFSZ+1)*READBUFSZ; + p = realloc(cp->hp, realloc_size); + if (p == NULL) + { + pool_error("save_pending_data: realloc failed"); + return -1; + } + + cp->bufsz = realloc_size; + cp->hp = p; + } + + memmove(cp->hp + cp->po + cp->len, data, len); + cp->len += len; + + return 0; +} + +/* + * consume pending data. returns actually consumed data length. + */ +static int consume_pending_data(POOL_CONNECTION *cp, void *data, int len) +{ + int consume_size; + + if (cp->len <= 0) + return 0; + + consume_size = Min(len, cp->len); + memmove(data, cp->hp + cp->po, consume_size); + cp->len -= consume_size; + + if (cp->len <= 0) + cp->po = 0; + else + cp->po += consume_size; + + return consume_size; +} + +/* + * pool_unread: Put back data to input buffer + */ +int pool_unread(POOL_CONNECTION *cp, void *data, int len) +{ + void *p = cp->hp; + int n = cp->len + len; + int realloc_size; + + if (cp->bufsz < n) + { + realloc_size = (n/READBUFSZ+1)*READBUFSZ; + p = realloc(cp->hp, realloc_size); + if (p == NULL) + { + pool_error("pool_unread: realloc failed"); + return -1; + } + cp->hp = p; + } + if (cp->len != 0) + memmove(p + len, cp->hp + cp->po, cp->len); + memmove(p, data, len); + cp->len = n; + cp->po = 0; + return 0; +} diff --git a/pool_system.c b/pool_system.c new file mode 100644 index 0000000..e940bc4 --- /dev/null +++ b/pool_system.c @@ -0,0 +1,658 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/pool_system.c,v 1.5.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_system.c: systemdb + * + */ + +#include +#include +#include +#include "pool.h" + +static int create_prepared_statement(DistDefInfo *dist_info); +static int get_col_list(DistDefInfo *info); +static int get_col_list2(RepliDefInfo *info); + +static +int get_col_list(DistDefInfo *info) +{ + int i; + static char sql[1024]; + PGresult *result; + + if (!system_db_info->pgconn || + (PQstatus(system_db_info->pgconn) != CONNECTION_OK)) + { + if (system_db_connect()) + return -1; + } + + for (i = 0; i < info->col_num; i++) + { + snprintf(sql, + sizeof(sql), + "SELECT col_list[%d],type_list[%d] FROM %s.dist_def where dbname = '%s' and schema_name = '%s' and table_name = '%s'", + i + 1, + i + 1, + pool_config->system_db_schema, + info->dbname,info->schema_name, + info->table_name); + + result = PQexec(system_db_info->pgconn, sql); + + if (!result || PQresultStatus(result) != PGRES_TUPLES_OK) + { + pool_error("get_col_list :PQexec failed: %s", + PQerrorMessage(system_db_info->pgconn)); + return -1; + } + else + { + info->col_list[i] = malloc(strlen(PQgetvalue(result,0,0)) + 1); + info->type_list[i] = malloc(strlen(PQgetvalue(result,0,1)) + 1); + + if (info->col_list[i] == NULL || info->type_list[i] == NULL) + { + pool_error("get_col_list: malloc failed: %s", strerror(errno)); + PQclear(result); + return -1; + } + strcpy(info->col_list[i],PQgetvalue(result,0,0)); + strcpy(info->type_list[i],PQgetvalue(result,0,1)); + if (strcmp(info->col_list[i], info->dist_key_col_name) == 0) + info->dist_key_col_id = i; + PQclear(result); + } + } + return 0; +} + +static +int get_col_list2(RepliDefInfo *info) +{ + int i; + static char sql[1024]; + PGresult *result; + + if (!system_db_info->pgconn || + (PQstatus(system_db_info->pgconn) != CONNECTION_OK)) + { + if (system_db_connect()) + return -1; + } + + for (i = 0; i < info->col_num; i++) + { + snprintf(sql, + sizeof(sql), + "SELECT col_list[%d],type_list[%d] FROM %s.replicate_def where dbname = '%s' and schema_name = '%s' and table_name = '%s'", + i + 1, + i + 1, + pool_config->system_db_schema, + info->dbname,info->schema_name, + info->table_name); + + result = PQexec(system_db_info->pgconn, sql); + + if (!result || PQresultStatus(result) != PGRES_TUPLES_OK) + { + pool_error("get_col_list2: PQexec failed: %s", + PQerrorMessage(system_db_info->pgconn)); + return -1; + } + else + { + info->col_list[i] = malloc(strlen(PQgetvalue(result,0,0)) + 1); + info->type_list[i] = malloc(strlen(PQgetvalue(result,0,1)) + 1); + + if (info->col_list[i] == NULL || info->type_list[i] == NULL) + { + pool_error("get_col_list2: malloc failed: %s", strerror(errno)); + PQclear(result); + return -1; + } + strcpy(info->col_list[i],PQgetvalue(result,0,0)); + strcpy(info->type_list[i],PQgetvalue(result,0,1)); + PQclear(result); + } + } + return 0; +} + +/* + * system_db_connect: + * Connects System DB by PQconnectdb(). + */ +int system_db_connect (void) +{ + static char conninfo[1024]; + int i; + + snprintf(conninfo, + sizeof(conninfo), + "host='%s' port=%d dbname='%s' user='%s' password='%s'", + system_db_info->info->hostname, + system_db_info->info->port, + system_db_info->info->database_name, + system_db_info->info->user, + system_db_info->info->password); + + system_db_info->pgconn = PQconnectdb(conninfo); + + if (PQstatus(system_db_info->pgconn) != CONNECTION_OK) + { + pool_error("Connection to database failed: %s", + PQerrorMessage(system_db_info->pgconn)); + PQfinish(system_db_info->pgconn); + system_db_info->pgconn = NULL; + return 1; + } + + for (i = 0; i < system_db_info->info->dist_def_num; i++) + { + DistDefInfo *info = &system_db_info->info->dist_def_slot[i]; + info->is_created_prepare = 0; + } + + system_db_info->info->query_cache_table_info.has_prepared_statement = 0; + + return 0; +} + +/* + * pool_memset_system_db_info: + * Initializes distribution rules. Distribution rules are stored in + * System DB. So we have to execute query, and expand results on + * memory. + */ +int pool_memset_system_db_info (SystemDBInfo *info) +{ + int i; + static char sql[1024],sql2[1024]; + PGresult *result; + DistDefInfo *dist_info = NULL; + RepliDefInfo *repli_info = NULL; + + if (!system_db_info->pgconn || + (PQstatus(system_db_info->pgconn) != CONNECTION_OK)) + { + if (system_db_connect()) + return -1; + } + + /* get distribution rules */ + snprintf(sql, + sizeof(sql), + "SELECT dbname, schema_name, table_name,col_name,array_upper(col_list,1),col_list,type_list, dist_def_func FROM %s.dist_def", + pool_config->system_db_schema); + + result = PQexec(system_db_info->pgconn, sql); + if (!result || PQresultStatus(result) != PGRES_TUPLES_OK) + { + pool_error("PQexec failed: %s", PQerrorMessage(system_db_info->pgconn)); + return -1; + } + else + { + info->dist_def_num = PQntuples(result); + if (info->dist_def_num != 0) + { + dist_info = malloc(sizeof(DistDefInfo) * info->dist_def_num); + } + + if (dist_info == NULL && info->dist_def_num != 0) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + + info->dist_def_slot = dist_info; + + for (i = 0; i < PQntuples(result); ++i) + { + char *t_dbname; + char *t_schema_name; + char *t_table_name; + char *t_dist_key_col_name; + char *t_dist_def_func; + int num; + int len; + + num = atol(PQgetvalue(result, i ,4)); + t_dbname = malloc(strlen(PQgetvalue(result,i,0)) + 1); + if (t_dbname == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_dbname, PQgetvalue(result,i,0)); + dist_info[i].dbname = t_dbname; + + t_schema_name = malloc(strlen(PQgetvalue(result,i,1)) + 1); + if (t_schema_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_schema_name, PQgetvalue(result,i,1)); + dist_info[i].schema_name = t_schema_name; + + t_table_name = malloc(strlen(PQgetvalue(result,i,2)) + 1); + if (t_table_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_table_name, PQgetvalue(result,i,2)); + dist_info[i].table_name = t_table_name; + + t_dist_key_col_name = malloc(strlen(PQgetvalue(result,i,3)) + 1); + if (t_dist_key_col_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_dist_key_col_name, PQgetvalue(result,i,3)); + dist_info[i].dist_key_col_name = t_dist_key_col_name; + + t_dist_def_func = malloc(strlen(PQgetvalue(result,i,7)) + 1); + if (t_dist_def_func == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_dist_def_func, PQgetvalue(result,i,7)); + dist_info[i].dist_def_func = t_dist_def_func; + + dist_info[i].col_num = num; + + dist_info[i].col_list = calloc(num, sizeof(char *)); + dist_info[i].type_list = calloc(num, sizeof(char *)); + if (dist_info[i].col_list == NULL || dist_info[i].type_list == NULL) + { + pool_error("pool_memset_system_db_info: calloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + + if (get_col_list(&dist_info[i]) < 0) + { + pool_error("get_col_list() failed"); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + + /* create PREPARE statement */ + len = strlen(t_dbname) + strlen(t_schema_name) + + strlen(t_table_name) + strlen("pgpool_"); + + dist_info[i].prepare_name = malloc(len + 1); + if (dist_info[i].prepare_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + return -1; + } + + snprintf(dist_info[i].prepare_name, len+1, "pgpool_%s%s%s", + t_dbname, t_schema_name, t_table_name); + dist_info[i].prepare_name[len] = '\0'; + } + } + + PQclear(result); + + /* get replication rules */ + snprintf(sql2, + sizeof(sql2), + "SELECT dbname, schema_name, table_name, array_upper(col_list,1),col_list,type_list FROM %s.replicate_def", + pool_config->system_db_schema); + + result = PQexec(system_db_info->pgconn, sql2); + + if (!result) + { + pool_error("PQexec failed: %s", PQerrorMessage(system_db_info->pgconn)); + return -1; + } + else if (PQresultStatus(result) != PGRES_TUPLES_OK) + { + info->repli_def_num = 0; + info->repli_def_slot = NULL; + } + else + { + info->repli_def_num = PQntuples(result); + if (info->repli_def_num != 0) + { + repli_info = malloc(sizeof(RepliDefInfo) * info->repli_def_num); + } + + if (repli_info == NULL && info->repli_def_num != 0) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + + info->repli_def_slot = repli_info; + + for (i = 0; i < PQntuples(result); ++i) + { + char *t_dbname; + char *t_schema_name; + char *t_table_name; + int num; + int len; + + num = atol(PQgetvalue(result, i ,3)); + t_dbname = malloc(strlen(PQgetvalue(result,i,0)) + 1); + if (t_dbname == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_dbname, PQgetvalue(result,i,0)); + repli_info[i].dbname = t_dbname; + + t_schema_name = malloc(strlen(PQgetvalue(result,i,1)) + 1); + if (t_schema_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_schema_name, PQgetvalue(result,i,1)); + repli_info[i].schema_name = t_schema_name; + + t_table_name = malloc(strlen(PQgetvalue(result,i,2)) + 1); + if (t_table_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + strcpy(t_table_name, PQgetvalue(result,i,2)); + repli_info[i].table_name = t_table_name; + + repli_info[i].col_num = num; + + repli_info[i].col_list = calloc(num, sizeof(char *)); + repli_info[i].type_list = calloc(num, sizeof(char *)); + if (repli_info[i].col_list == NULL || repli_info[i].type_list == NULL) + { + pool_error("pool_memset_system_db_info: calloc failed: %s", + strerror(errno)); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + + if (get_col_list2(&repli_info[i]) < 0) + { + pool_error("get_col_list() failed"); + PQclear(result); + pool_close_libpq_connection(); + return -1; + } + + /* create PREPARE statement */ + len = strlen(t_dbname) + strlen(t_schema_name) + + strlen(t_table_name) + strlen("pgpool_"); + + repli_info[i].prepare_name = malloc(len + 1); + if (repli_info[i].prepare_name == NULL) + { + pool_error("pool_memset_system_db_info: malloc failed: %s", + strerror(errno)); + return -1; + } + + snprintf(repli_info[i].prepare_name, len+1, "pgpool_%s%s%s", + t_dbname, t_schema_name, t_table_name); + repli_info[i].prepare_name[len] = '\0'; + } + } + + PQclear(result); + + pool_close_libpq_connection(); + return i; +} + +/* + * pool_get_dist_def_info: + * Looks up distribution rule with dbname, schema_name and table_name. + */ +DistDefInfo *pool_get_dist_def_info (char *dbname, char *schema_name, char *table_name) +{ + int i; + int dist_def_num = system_db_info->info->dist_def_num; + char *public ="public"; + + if (!dbname || !table_name) + { + return NULL; + } + + if (!schema_name) + { + schema_name = public; + } + + for (i = 0; i < dist_def_num; i++) + { + char *mem_dbname; + char *mem_schema_name; + char *mem_table_name; + + mem_dbname = system_db_info->info->dist_def_slot[i].dbname; + mem_schema_name = system_db_info->info->dist_def_slot[i].schema_name; + mem_table_name = system_db_info->info->dist_def_slot[i].table_name; + + if ((strcmp(mem_dbname, dbname) == 0) && + (strcmp(mem_schema_name, schema_name) == 0) && + (strcmp(mem_table_name, table_name) ==0)) + { + return &system_db_info->info->dist_def_slot[i]; + } + } + return NULL; +} + +/* + * pool_get_repli_def_info: + * Looks up replication rule with dbname, schema_name and table_name. + */ +RepliDefInfo *pool_get_repli_def_info (char *dbname, char *schema_name, char *table_name) +{ + int i; + int repli_def_num = system_db_info->info->repli_def_num; + char *public ="public"; + + if (!dbname || !table_name) + { + return NULL; + } + + if (!schema_name) + { + schema_name = public; + } + + for (i = 0; i < repli_def_num; i++) + { + char *mem_dbname; + char *mem_schema_name; + char *mem_table_name; + + mem_dbname = system_db_info->info->repli_def_slot[i].dbname; + mem_schema_name = system_db_info->info->repli_def_slot[i].schema_name; + mem_table_name = system_db_info->info->repli_def_slot[i].table_name; + + if ((strcmp(mem_dbname, dbname) == 0) && + (strcmp(mem_schema_name, schema_name) == 0) && + (strcmp(mem_table_name, table_name) ==0)) + { + return &system_db_info->info->repli_def_slot[i]; + } + } + return NULL; +} + +/* + * pool_get_id: + * Returns the backend node id from value. + */ +int pool_get_id (DistDefInfo *info, const char *value) +{ + int num; + PGresult *result; + char *type; + int length; + + if (!system_db_info->pgconn || + (PQstatus(system_db_info->pgconn) != CONNECTION_OK)) + { + if (system_db_connect()) + return -1; + } + + if (info->is_created_prepare == 0) + { + if (create_prepared_statement(info) != 0) + return -1; + } + + type=info->type_list[info->dist_key_col_id]; + length = strlen(value); + result = PQexecPrepared(system_db_info->pgconn, info->prepare_name, + 1, &value, &length, NULL, 0); + + if (!result || PQresultStatus(result) != PGRES_TUPLES_OK || + PQgetisnull(result, 0, 0)) + { + pool_error("PQexecPrepared failed: %s", PQerrorMessage(system_db_info->pgconn)); + return -1; + } + else + { + char *id; + id = PQgetvalue(result, 0 ,0); + + if(strlen(id)) + { + num = atoi(id); + PQclear(result); + + if(num < NUM_BACKENDS) + { + return num; + } else { + return -1; + } + } + return -1; + } +} + +/* + * pool_close_libpq_connection: + * Closes libpq's connection. + */ +void pool_close_libpq_connection(void) +{ + PQfinish(system_db_info->pgconn); + system_db_info->pgconn = NULL; +} + +/* + * pool_system_db_connection: + * Returns persistent connection to the system DB + */ +POOL_CONNECTION_POOL_SLOT *pool_system_db_connection(void) +{ + return system_db_info->connection; +} + +/* + * create_prepared_statement: + * Returns 0 if prepared statement is created. + * Returns 1 if prepared statement can't created. + */ +static int create_prepared_statement(DistDefInfo *dist_info) +{ + static char sql[1024]; + PGresult *result; + +#ifdef HAVE_PQPREPARE + snprintf(sql, 1024, "SELECT %s($1::%s)", dist_info->dist_def_func, + dist_info->type_list[dist_info->dist_key_col_id]); + result = PQprepare(system_db_info->pgconn, + dist_info->prepare_name, + sql, 1, NULL); +#else + snprintf(sql, 1024, "PREPARE %s (%s) AS SELECT %s($1::%s)", + dist_info->prepare_name, + dist_info->type_list[dist_info->dist_key_col_id], + dist_info->dist_def_func, + dist_info->type_list[dist_info->dist_key_col_id]); + result = PQexec(system_db_info->pgconn, sql); +#endif /* HAVE_PQPREPARE */ + + if (!result || PQresultStatus(result) != PGRES_COMMAND_OK) + { + pool_error("PQprepare failed: %s", PQerrorMessage(system_db_info->pgconn)); + return 1; + } + dist_info->is_created_prepare = 1; + return 0; +} diff --git a/pool_type.h b/pool_type.h new file mode 100644 index 0000000..e722434 --- /dev/null +++ b/pool_type.h @@ -0,0 +1,257 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/pool_type.h,v 1.9 2008/12/30 00:59:35 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * pool_type.h.: type definition header file + * + */ + +#ifndef POOL_TYPE_H +#define POOL_TYPE_H + +#include "config.h" +#include +#include + +/* Define common boolean type. C++ and BEOS already has it so exclude them. */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif /* __cplusplus */ +#endif /* c_plusplus */ + +#ifndef __BEOS__ +#ifndef __cplusplus +#ifndef bool +typedef char bool; +#endif +#ifndef true +#define true ((bool) 1) +#endif +#ifndef TRUE +#define TRUE ((bool) 1) +#endif +#ifndef false +#define false ((bool) 0) +#endif +#ifndef FALSE +#define FALSE ((bool) 0) +#endif +#endif /* not C++ */ +#endif /* __BEOS__ */ + +/* + * startup packet definitions (v2) stolen from PostgreSQL + */ +#define SM_DATABASE 64 +#define SM_USER 32 +#define SM_OPTIONS 64 +#define SM_UNUSED 64 +#define SM_TTY 64 + +#define MAX_NUM_BACKENDS 128 +#define MAX_CONNECTION_SLOTS 128 +#define MAX_DB_HOST_NAMELEN 128 +#define MAX_PATH_LENGTH 256 + +typedef enum { + CON_UNUSED, /* unused slot */ + CON_CONNECT_WAIT, /* waiting for connection starting */ + CON_UP, /* up and running */ + CON_DOWN /* down, disconnected */ +} BACKEND_STATUS; + +typedef enum { + LOAD_UNSELECTED = 0, + LOAD_SELECTED +} LOAD_BALANCE_STATUS; + +/* + * PostgreSQL backend descriptor. Placed on shared memory area. + */ +typedef struct { + char backend_hostname[MAX_DB_HOST_NAMELEN]; /* backend host name */ + int backend_port; /* backend port numbers */ + BACKEND_STATUS backend_status; /* backend status */ + double backend_weight; /* normalized backend load balance ratio */ + double unnormalized_weight; /* descripted parameter */ + char backend_data_directory[MAX_PATH_LENGTH]; +} BackendInfo; + +typedef struct { + int num_backends; /* number of used PostgreSQL backends */ + BackendInfo backend_info[MAX_NUM_BACKENDS]; +} BackendDesc; + +/* + * Connection pool information. Placed on shared memory area. + */ +typedef struct { + char database[SM_DATABASE]; /* Database name */ + char user[SM_USER]; /* User name */ + int major; /* protocol major version */ + int minor; /* protocol minor version */ + int pid; /* backend process id */ + int key; /* cancel key */ + int counter; /* used counter */ + time_t create_time; /* connection creation time */ + int load_balancing_node; /* load balancing node */ +} ConnectionInfo; + + +/* + * process information + * This object put on shared memory. + */ +typedef struct { + pid_t pid; /* OS's process id */ + time_t start_time; /* fork() time */ + ConnectionInfo *connection_info; /* head of the connection info for this process */ +} ProcessInfo; + +/* + * + * system db structure + */ +typedef struct { + char *dbname; /* database name */ + char *schema_name; /* schema name */ + char *table_name; /* table name */ + char *dist_key_col_name;/* column name for dist key */ + int dist_key_col_id; /* column index id for dist key */ + int col_num; /* number of clumn*/ + char **col_list; /* column list */ + char **type_list; /* type list */ + char *dist_def_func; /* function name of distribution rule */ + char *prepare_name; /* prepared statement name */ + int is_created_prepare; /* is prepare statement created? */ +} DistDefInfo; + +typedef struct { + char *dbname; /* database name */ + char *schema_name; /* schema name */ + char *table_name; /* table name */ + int col_num; /* number of clumn*/ + char **col_list; /* column list */ + char **type_list; /* type list */ + char *prepare_name; /* prepared statement name */ + int is_created_prepare; /* is prepare statement created? */ +} RepliDefInfo; + +typedef struct { + int has_prepared_statement; /* true if the current session has prepared statement created */ + char *register_prepared_statement; /* prepared statement name for cache register */ +} QueryCacheTableInfo; + +typedef struct { + char *hostname; /* host name */ + int port; /* port number */ + char *user; /* login user name */ + char *password; /* login password */ + char *schema_name; /* schema name */ + char *database_name; /* database name */ + int repli_def_num; /* number of replication table */ + int dist_def_num; /* number of distribution table */ + RepliDefInfo *repli_def_slot; /* replication rule list */ + DistDefInfo *dist_def_slot; /* distribution rule list */ + QueryCacheTableInfo query_cache_table_info; /* query cache db session info */ + BACKEND_STATUS system_db_status; +} SystemDBInfo; + +/* + * It seems that sockaddr_storage is now commonly used in place of sockaddr. + * So, define it if it is not define yet, and create new SockAddr structure + * that uses sockaddr_storage. + */ +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE + +#ifndef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY +#define ss_family __ss_family +#else +#error struct sockaddr_storage does not provide an ss_family member +#endif /* HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ +#endif /* HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY */ + +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN +#define ss_len __ss_len +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1 +#endif /* HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN */ + +#else /* !HAVE_STRUCT_SOCKADDR_STORAGE */ + +/* Define a struct sockaddr_storage if we don't have one. */ +struct sockaddr_storage +{ + union + { + struct sockaddr sa; /* get the system-dependent fields */ + long int ss_align; /* ensures struct is properly aligned. original uses int64 */ + char ss_pad[128]; /* ensures struct has desired size */ + } + ss_stuff; +}; + +#define ss_family ss_stuff.sa.sa_family +/* It should have an ss_len field if sockaddr has sa_len. */ +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN +#define ss_len ss_stuff.sa.sa_len +#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1 +#endif +#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ + +typedef struct +{ + struct sockaddr_storage addr; + /* ACCEPT_TYPE_ARG3 - Third argument type of accept(). + * It is defined in ac_func_accept_argtypes.m4 + */ + ACCEPT_TYPE_ARG3 salen; +} +SockAddr; + +/* UserAuth type used for HBA which indicates the authentication method */ +typedef enum UserAuth +{ + uaReject, + /* uaKrb4, */ + /* uaKrb5, */ + uaTrust + /* uaIdent, */ + /* uaPassword, */ + /* uaCrypt, */ + /* uaMD5 */ +#ifdef USE_PAM + ,uaPAM +#endif /* USE_PAM */ +} +UserAuth; + +#define AUTH_REQ_OK 0 /* User is authenticated */ +#define AUTH_REQ_KRB4 1 /* Kerberos V4 */ +#define AUTH_REQ_KRB5 2 /* Kerberos V5 */ +#define AUTH_REQ_PASSWORD 3 /* Password */ +#define AUTH_REQ_CRYPT 4 /* crypt password */ +#define AUTH_REQ_MD5 5 /* md5 password */ +#define AUTH_REQ_SCM_CREDS 6 /* transfer SCM credentials */ + +typedef unsigned int AuthRequest; + +#endif /* POOL_TYPE_H */ diff --git a/ps_status.c b/ps_status.c new file mode 100644 index 0000000..8eb2c00 --- /dev/null +++ b/ps_status.c @@ -0,0 +1,386 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/ps_status.c,v 1.3.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * This file was imported from PostgreSQL source code. + * See below for the copyright and description. + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2009 PgPool Global Development Group + * + */ +/*-------------------------------------------------------------------- + * ps_status.c + * + * Routines to support changing the ps display of PostgreSQL backends + * to contain some useful information. Mechanism differs wildly across + * platforms. + * + * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.33 2006/10/04 00:30:04 momjian Exp $ + * + * Copyright (c) 2000-2006, PostgreSQL Global Development Group + * various details abducted from various places + *-------------------------------------------------------------------- + */ + +#include +#ifdef HAVE_SYS_PSTAT_H +#include /* for HP-UX */ +#endif +#ifdef HAVE_PS_STRINGS +#include /* for old BSD */ +#include +#endif +#if defined(__darwin__) +#include +#endif + +#include "pool.h" +#include +#include + +extern char **environ; +bool update_process_title = true; + + +/* + * Alternative ways of updating ps display: + * + * PS_USE_SETPROCTITLE + * use the function setproctitle(const char *, ...) + * (newer BSD systems) + * PS_USE_PSTAT + * use the pstat(PSTAT_SETCMD, ) + * (HPUX) + * PS_USE_PS_STRINGS + * assign PS_STRINGS->ps_argvstr = "string" + * (some BSD systems) + * PS_USE_CHANGE_ARGV + * assign argv[0] = "string" + * (some other BSD systems) + * PS_USE_CLOBBER_ARGV + * write over the argv and environment area + * (most SysV-like systems) + * PS_USE_WIN32 + * push the string out as the name of a Windows event + * PS_USE_NONE + * don't update ps display + * (This is the default, as it is safest.) + */ +#if defined(HAVE_SETPROCTITLE) +#define PS_USE_SETPROCTITLE +#elif defined(HAVE_PSTAT) && defined(PSTAT_SETCMD) +#define PS_USE_PSTAT +#elif defined(HAVE_PS_STRINGS) +#define PS_USE_PS_STRINGS +#elif (defined(BSD) || defined(__bsdi__) || defined(__hurd__)) && !defined(__darwin__) +#define PS_USE_CHANGE_ARGV +#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__) +#define PS_USE_CLOBBER_ARGV +#elif defined(WIN32) +#define PS_USE_WIN32 +#else +#define PS_USE_NONE +#endif + + +/* Different systems want the buffer padded differently */ +#if defined(_AIX) || defined(__linux__) || defined(__svr4__) +#define PS_PADDING '\0' +#else +#define PS_PADDING ' ' +#endif + + +#ifndef PS_USE_CLOBBER_ARGV +/* all but one options need a buffer to write their ps line in */ +#define PS_BUFFER_SIZE 256 +static char ps_buffer[PS_BUFFER_SIZE]; +static const size_t ps_buffer_size = PS_BUFFER_SIZE; +#else /* PS_USE_CLOBBER_ARGV */ +static char *ps_buffer; /* will point to argv area */ +static size_t ps_buffer_size; /* space determined at run time */ +#endif /* PS_USE_CLOBBER_ARGV */ + +static size_t ps_buffer_fixed_size; /* size of the constant prefix */ + +/* save the original argv[] location here */ +static int save_argc; +static char **save_argv; + + +/* + * Call this early in startup to save the original argc/argv values. + * If needed, we make a copy of the original argv[] array to preserve it + * from being clobbered by subsequent ps_display actions. + * + * (The original argv[] will not be overwritten by this routine, but may be + * overwritten during init_ps_display. Also, the physical location of the + * environment strings may be moved, so this should be called before any code + * that might try to hang onto a getenv() result.) + */ +char ** +save_ps_display_args(int argc, char **argv) +{ + save_argc = argc; + save_argv = argv; + +#if defined(PS_USE_CLOBBER_ARGV) + + /* + * If we're going to overwrite the argv area, count the available space. + * Also move the environment to make additional room. + */ + { + char *end_of_area = NULL; + char **new_environ; + int i; + + /* + * check for contiguous argv strings + */ + for (i = 0; i < argc; i++) + { + if (i == 0 || end_of_area + 1 == argv[i]) + end_of_area = argv[i] + strlen(argv[i]); + } + + if (end_of_area == NULL) /* probably can't happen? */ + { + ps_buffer = NULL; + ps_buffer_size = 0; + return argv; + } + + /* + * check for contiguous environ strings following argv + */ + for (i = 0; environ[i] != NULL; i++) + { + if (end_of_area + 1 == environ[i]) + end_of_area = environ[i] + strlen(environ[i]); + } + + ps_buffer = argv[0]; + ps_buffer_size = end_of_area - argv[0]; + + /* + * move the environment out of the way + */ + new_environ = (char **) malloc((i + 1) * sizeof(char *)); + for (i = 0; environ[i] != NULL; i++) + new_environ[i] = strdup(environ[i]); + new_environ[i] = NULL; + environ = new_environ; + } +#endif /* PS_USE_CLOBBER_ARGV */ + +#if defined(PS_USE_CHANGE_ARGV) || defined(PS_USE_CLOBBER_ARGV) + + /* + * If we're going to change the original argv[] then make a copy for + * argument parsing purposes. + * + * (NB: do NOT think to remove the copying of argv[], even though + * postmaster.c finishes looking at argv[] long before we ever consider + * changing the ps display. On some platforms, getopt() keeps pointers + * into the argv array, and will get horribly confused when it is + * re-called to analyze a subprocess' argument string if the argv storage + * has been clobbered meanwhile. Other platforms have other dependencies + * on argv[]. + */ + { + char **new_argv; + int i; + + new_argv = (char **) malloc((argc + 1) * sizeof(char *)); + for (i = 0; i < argc; i++) + new_argv[i] = strdup(argv[i]); + new_argv[argc] = NULL; + +#if defined(__darwin__) + + /* + * Darwin (and perhaps other NeXT-derived platforms?) has a static + * copy of the argv pointer, which we may fix like so: + */ + *_NSGetArgv() = new_argv; +#endif + + argv = new_argv; + } +#endif /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */ + + return argv; +} + +/* + * Call this once during subprocess startup to set the identification + * values. At this point, the original argv[] array may be overwritten. + */ +void +init_ps_display(const char *username, const char *dbname, + const char *host_info, const char *initial_str) +{ +#ifndef PS_USE_NONE + /* no ps display if you didn't call save_ps_display_args() */ + if (!save_argv) + return; +#ifdef PS_USE_CLOBBER_ARGV + /* If ps_buffer is a pointer, it might still be null */ + if (!ps_buffer) + return; +#endif + + /* + * Overwrite argv[] to point at appropriate space, if needed + */ + +#ifdef PS_USE_CHANGE_ARGV + save_argv[0] = ps_buffer; + save_argv[1] = NULL; +#endif /* PS_USE_CHANGE_ARGV */ + +#ifdef PS_USE_CLOBBER_ARGV + { + int i; + + /* make extra argv slots point at end_of_area (a NUL) */ + for (i = 1; i < save_argc; i++) + save_argv[i] = ps_buffer + ps_buffer_size; + } +#endif /* PS_USE_CLOBBER_ARGV */ + + /* + * Make fixed prefix of ps display. + */ + +#ifdef PS_USE_SETPROCTITLE + + /* + * apparently setproctitle() already adds a `progname: ' prefix to the + * ps line + */ + snprintf(ps_buffer, ps_buffer_size, ""); +#else + snprintf(ps_buffer, ps_buffer_size, + "pgpool: "); +#endif + + ps_buffer_fixed_size = strlen(ps_buffer); + + set_ps_display(initial_str, true); +#endif /* not PS_USE_NONE */ +} + + + +/* + * Call this to update the ps status display to a fixed prefix plus an + * indication of what you're currently doing passed in the argument. + */ +void +set_ps_display(const char *activity, bool force) +{ + + if (!force && !update_process_title) + return; + +#ifndef PS_USE_NONE + +#ifdef PS_USE_CLOBBER_ARGV + /* If ps_buffer is a pointer, it might still be null */ + if (!ps_buffer) + return; +#endif + + /* Update ps_buffer to contain both fixed part and activity */ + strlcpy(ps_buffer + ps_buffer_fixed_size, activity, + ps_buffer_size - ps_buffer_fixed_size); + + /* Transmit new setting to kernel, if necessary */ + +#ifdef PS_USE_SETPROCTITLE + setproctitle("%s", ps_buffer); +#endif + +#ifdef PS_USE_PSTAT + { + union pstun pst; + + pst.pst_command = ps_buffer; + pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0); + } +#endif /* PS_USE_PSTAT */ + +#ifdef PS_USE_PS_STRINGS + PS_STRINGS->ps_nargvstr = 1; + PS_STRINGS->ps_argvstr = ps_buffer; +#endif /* PS_USE_PS_STRINGS */ + +#ifdef PS_USE_CLOBBER_ARGV + { + int buflen; + + /* pad unused memory */ + buflen = strlen(ps_buffer); + memset(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen); + } +#endif /* PS_USE_CLOBBER_ARGV */ + +#ifdef PS_USE_WIN32 + { + /* + * Win32 does not support showing any changed arguments. To make it at + * all possible to track which backend is doing what, we create a + * named object that can be viewed with for example Process Explorer. + */ + static HANDLE ident_handle = INVALID_HANDLE_VALUE; + char name[PS_BUFFER_SIZE + 32]; + + if (ident_handle != INVALID_HANDLE_VALUE) + CloseHandle(ident_handle); + + sprintf(name, "pgident: %s", ps_buffer); + + ident_handle = CreateEvent(NULL, TRUE, FALSE, name); + } +#endif /* PS_USE_WIN32 */ +#endif /* not PS_USE_NONE */ +} + + +/* + * Returns what's currently in the ps display, in case someone needs + * it. Note that only the activity part is returned. On some platforms + * the string will not be null-terminated, so return the effective + * length into *displen. + */ +const char * +get_ps_display(int *displen) +{ +#ifdef PS_USE_CLOBBER_ARGV + size_t offset; + + /* If ps_buffer is a pointer, it might still be null */ + if (!ps_buffer) + { + *displen = 0; + return ""; + } + + /* Remove any trailing spaces to offset the effect of PS_PADDING */ + offset = ps_buffer_size; + while (offset > ps_buffer_fixed_size && ps_buffer[offset - 1] == PS_PADDING) + offset--; + + *displen = offset - ps_buffer_fixed_size; +#else + *displen = strlen(ps_buffer + ps_buffer_fixed_size); +#endif + + return ps_buffer + ps_buffer_fixed_size; +} diff --git a/recovery.c b/recovery.c new file mode 100644 index 0000000..176d085 --- /dev/null +++ b/recovery.c @@ -0,0 +1,337 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/recovery.c,v 1.12.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Copyright (c) 2003-2008 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * recovery.c: online recovery process + * + */ + +#include "config.h" + +#include +#include + +#include "pool.h" +#include "libpq-fe.h" + +#define WAIT_RETRY_COUNT (pool_config->recovery_timeout / 3) + +#define FIRST_STAGE 0 +#define SECOND_STAGE 1 + +static int exec_checkpoint(PGconn *conn); +static int exec_recovery(PGconn *conn, BackendInfo *backend, char stage); +static int exec_remote_start(PGconn *conn, BackendInfo *backend); +static PGconn *connect_backend_libpq(BackendInfo *backend); +static int wait_connection_closed(void); +static int check_postmaster_started(BackendInfo *backend); + +static char recovery_command[1024]; + +extern volatile sig_atomic_t pcp_wakeup_request; + +int start_recovery(int recovery_node) +{ + BackendInfo *backend; + BackendInfo *recovery_backend; + PGconn *conn; + + pool_log("starting recovering node %d", recovery_node); + + if (VALID_BACKEND(recovery_node)) + { + pool_error("start_recovery: backend node %d is alive", recovery_node); + return 1; + } + + Req_info->kind = NODE_RECOVERY_REQUEST; + + backend = &pool_config->backend_desc->backend_info[MASTER_NODE_ID]; + recovery_backend = &pool_config->backend_desc->backend_info[recovery_node]; + + conn = connect_backend_libpq(backend); + if (conn == NULL) + { + PQfinish(conn); + pool_error("start_recover: could not connect master node."); + return 1; + } + + /* 1st stage */ + if (exec_checkpoint(conn) != 0) + { + PQfinish(conn); + pool_error("start_recovery: CHECKPOINT failed"); + return 1; + } + + pool_log("CHECKPOINT in the 1st stage done"); + + if (exec_recovery(conn, recovery_backend, FIRST_STAGE) != 0) + { + PQfinish(conn); + return 1; + } + + pool_log("1st stage is done"); + + pool_log("starting 2nd stage"); + + /* 2nd stage */ + *InRecovery = 1; + if (wait_connection_closed() != 0) + { + PQfinish(conn); + pool_error("start_recovery: timeover for waiting connection closed"); + return 1; + } + + pool_log("all connections from clients have been closed"); + + if (exec_checkpoint(conn) != 0) + { + PQfinish(conn); + pool_error("start_recovery: CHECKPOINT failed"); + return 1; + } + + pool_log("CHECKPOINT in the 2nd stage done"); + + if (exec_recovery(conn, recovery_backend, SECOND_STAGE) != 0) + { + PQfinish(conn); + return 1; + } + if (exec_remote_start(conn, recovery_backend) != 0) + { + PQfinish(conn); + pool_error("start_recovery: remote start failed"); + return 1; + } + + if (check_postmaster_started(recovery_backend)) + { + PQfinish(conn); + pool_error("start_recovery: check start failed"); + return 1; + } + + pool_log("%d node restarted", recovery_node); + + /* + * reset failover completion flag. this is necessary since + * previous failover/failback will set the flag to 1. + */ + pcp_wakeup_request = 0; + + /* send failback request to pgpool parent */ + send_failback_request(recovery_node); + + /* wait for failback */ + while (!pcp_wakeup_request) + { + struct timeval t = {1, 0}; + /* polling SIGUSR2 signal every 1 sec */ + select(0, NULL, NULL, NULL, &t); + } + pcp_wakeup_request = 0; + + PQfinish(conn); + + pool_log("recovery done"); + + return 0; +} + +/* + * Notice all children finishing recovery. + */ +void finish_recovery(void) +{ + *InRecovery = 0; + kill(getppid(), SIGUSR2); +} + +/* + * Execute CHECKPOINT + */ +static int exec_checkpoint(PGconn *conn) +{ + PGresult *result; + int r; + + pool_debug("exec_checkpoint: start checkpoint"); + result = PQexec(conn, "CHECKPOINT"); + r = (PQresultStatus(result) != PGRES_COMMAND_OK); + PQclear(result); + pool_debug("exec_checkpoint: finish checkpoint"); + return r; +} + +/* + * Call pgpool_recovery() function. + */ +static int exec_recovery(PGconn *conn, BackendInfo *backend, char stage) +{ + PGresult *result; + char *hostname; + char *script; + int r; + + if (strlen(backend->backend_hostname) == 0) + hostname = "localhost"; + else + hostname = backend->backend_hostname; + + script = (stage == FIRST_STAGE) ? + pool_config->recovery_1st_stage_command : pool_config->recovery_2nd_stage_command; + + if (script == NULL || strlen(script) == 0) + { + /* do not execute script */ + return 0; + } + + snprintf(recovery_command, + sizeof(recovery_command), + "SELECT pgpool_recovery('%s', '%s', '%s')", + script, + hostname, + backend->backend_data_directory); + + pool_log("starting recovery command: \"%s\"", recovery_command); + + pool_debug("exec_recovery: start recovery"); + result = PQexec(conn, recovery_command); + r = (PQresultStatus(result) != PGRES_TUPLES_OK); + if (r != 0) + { + pool_error("exec_recovery: %s command failed at %s", + script, + (stage == FIRST_STAGE) ? "1st stage" : "2nd stage"); + } + PQclear(result); + pool_debug("exec_recovery: finish recovery"); + return r; +} + +/* + * Call pgpool_remote_start() function. + */ +static int exec_remote_start(PGconn *conn, BackendInfo *backend) +{ + PGresult *result; + char *hostname; + int r; + + if (strlen(backend->backend_hostname) == 0) + hostname = "localhost"; + else + hostname = backend->backend_hostname; + + snprintf(recovery_command, sizeof(recovery_command), + "SELECT pgpool_remote_start('%s', '%s')", + hostname, + backend->backend_data_directory); + + pool_debug("exec_remote_start: start pgpool_remote_start"); + result = PQexec(conn, recovery_command); + r = (PQresultStatus(result) != PGRES_TUPLES_OK); + if (r != 0) + pool_error("exec_remote_start: pgpool_remote_start failed: %s", PQresultErrorMessage(result)); + PQclear(result); + pool_debug("exec_remote_start: finish pgpool_remote_start"); + return r; +} + +/* + * Check postmaster is started. + */ +static int check_postmaster_started(BackendInfo *backend) +{ + int i = 0; + char port_str[16]; + PGconn *conn; + + snprintf(port_str, sizeof(port_str), + "%d", backend->backend_port); + do { + ConnStatusType r; + conn = PQsetdbLogin(backend->backend_hostname, + port_str, + NULL, + NULL, + "template1", + pool_config->recovery_user, + pool_config->recovery_password); + r = PQstatus(conn); + PQfinish(conn); + if (r == CONNECTION_OK) + return 0; + + if (WAIT_RETRY_COUNT != 0) + sleep(3); + } while (i++ < WAIT_RETRY_COUNT); + + pool_error("check_postmaster_started: remote host start up did not finish in %d sec.", pool_config->recovery_timeout); + return 1; +} + +static PGconn *connect_backend_libpq(BackendInfo *backend) +{ + char port_str[16]; + PGconn *conn; + + snprintf(port_str, sizeof(port_str), + "%d", backend->backend_port); + conn = PQsetdbLogin(backend->backend_hostname, + port_str, + NULL, + NULL, + "template1", + pool_config->recovery_user, + pool_config->recovery_password); + + if (PQstatus(conn) != CONNECTION_OK) + { + PQfinish(conn); + return NULL; + } + return conn; +} + +/* + * Wait all connections are closed. + */ +static int wait_connection_closed(void) +{ + int i = 0; + + do { + + if (Req_info->conn_counter == 0) + return 0; + + if (WAIT_RETRY_COUNT != 0) + sleep(3); + } while (i++ < WAIT_RETRY_COUNT); + + pool_error("wait_connection_closed: existing connections did not close in %d sec.", pool_config->recovery_timeout); + return 1; +} diff --git a/redhat/pgpool.init b/redhat/pgpool.init new file mode 100755 index 0000000..ee791c7 --- /dev/null +++ b/redhat/pgpool.init @@ -0,0 +1,190 @@ +#!/bin/sh +# pgpool This is the init script for starting up pgpool-II +# +# chkconfig: - 64 36 +# description: Starts and stops the pgpool daemon +# processname: pgpool +# pidfile: /var/run/pgpool.pid +# +# v1.0.0 Devrim GUNDUZ +# - Initial version of Red Hat / Fedora init script +# +# v2.2 Devrim GUNDUZ +# - New and improved version which has some fixes. + +if [ -r /etc/sysconfig/pgpool ]; then + . /etc/sysconfig/pgpool +fi + +# Source function library. +INITD=/etc/rc.d/init.d +. $INITD/functions + +# Get function listing for cross-distribution logic. +TYPESET=`typeset -f|grep "declare"` + +# Get config. +. /etc/sysconfig/network + +# Check that networking is up. +# We need it for pgpool +[ "${NETWORKING}" = "no" ] && exit 0 + +# Find the name of the script +NAME=`basename $0` +if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ] +then + NAME=${NAME:3} +fi + +# Set defaults for configuration variables +PGPOOLENGINE=/usr/bin +PGPOOLDAEMON=$PGPOOLENGINE/pgpool +PGPOOLCONF=/etc/pgpool-II/pgpool.conf +PGPOOLPIDDIR=/var/run/pgpool +PGPOOLLOG=/var/log/pgpool.log + +test -x $PGPOOLDAEMON || exit 5 + +# Check whether the config file exists or not +if [ ! -r $PGPOOLCONF ] +then + echo "$PGPOOLCONF not found" + RETVAL=1 + failure + exit +fi + +# Create the log file if it does not exist +if [ ! -x $PGPOOLLOG ] +then + touch $PGPOOLLOG + chown postgres: $PGPOOLLOG +fi + +if [ ! -d $PGPOOLPIDDIR ] +then + mkdir $PGPOOLPIDDIR + chown postgres: $PGPOOLPIDDIR +fi + +script_result=0 + +start(){ + pid=`pidof -s "$PGPOOLDAEMON"` + if [ $pid ] + then + echo "pgpool is already running with pid $pid" + failure "$PGPOQL_START" + echo + script_result=1 + exit 1 + fi + + PGPOOL_START=$"Starting ${NAME} service: " + + echo -n "$PGPOOL_START" + + $PGPOOLDAEMON -f $PGPOOLCONF $OPTS & >> "$PGPOOLLOG" 2>&1 < /dev/null + sleep 2 + + pid=`pidof -s "$PGPOOLDAEMON"` + if [ $pid ] + then + success "$PGPOOL_START" + touch /var/lock/subsys/${NAME} + echo + else + failure "$PGPOQL_START" + echo + script_result=1 + fi +} + +stop(){ + echo -n $"Stopping ${NAME} service: " + if [ $UID -ne 0 ]; then + RETVAL=1 + failure + else + killproc /usr/bin/pgpool +# $PGPOOLDAEMON stop & >> "$PGPOOLLOG" 2>&1 < /dev/null + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${NAME} + fi; + echo + return $RETVAL +} + +switch() { + echo -n $"Sending switchover request to $NAME " + $PGPOOLDAEMON -f $PGPOOLCONF switch >> "$PGPOOLLOG" 2>&1 < /dev/null + RETVAL=$? + echo + if [ $RETVAL -eq 0 ] + then + echo_success + else + echo_failure + fi + echo +} + +restart(){ + stop + start +} + +reload(){ + echo -n $"Reloading ${NAME}: " + + if [ -n "`pidfileofproc $PGPOOLDAEMON`" ] ; then + killproc $PGPOOLDAEMON -HUP + else + failure $"Reloading ${NAME}" + fi + RETVAL=$? + echo +} + +condrestart(){ + [ -e /var/lock/subsys/${NAME} ] && restart +} + +condstop(){ + [ -e /var/lock/subsys/${NAME} ] && stop +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + switch) + switch + ;; + status) + status pgpool + script_result=$? + ;; + restart) + restart + ;; + reload|force-reload) + reload + ;; + condrestart) + condrestart + ;; + condstop) + condstop + ;; + *) + echo $"Usage: $0 {start|stop|switch|status|restart|condrestart|condstop|reload|force-reload}" + exit 1 +esac + +exit $script_result diff --git a/redhat/pgpool.sysconfig b/redhat/pgpool.sysconfig new file mode 100644 index 0000000..ef8e2e1 --- /dev/null +++ b/redhat/pgpool.sysconfig @@ -0,0 +1,6 @@ +# Options for pgpool + +# -n: don't run in daemon mode. does not detatch control tty +# -d: debug mode. lots of debug information will be printed + +#OPTS=" -d -n" diff --git a/sample/dist_def_pgbench.sql b/sample/dist_def_pgbench.sql new file mode 100644 index 0000000..b98046f --- /dev/null +++ b/sample/dist_def_pgbench.sql @@ -0,0 +1,73 @@ +-- $Header: /cvsroot/pgpool/pgpool-II/sample/dist_def_pgbench.sql,v 1.1.1.1 2006/09/08 03:36:17 t-ishii Exp $ + +INSERT INTO pgpool_catalog.dist_def VALUES ( + 'bench_parallel', + 'public', + 'branches', + 'bid', + ARRAY['bid', 'bbalance', 'filler'], + ARRAY['integer', 'integer', 'character(88)'], + 'pgpool_catalog.dist_def_branches' +); + +INSERT INTO pgpool_catalog.dist_def VALUES ( + 'bench_parallel', + 'public', + 'tellers', + 'tid', + ARRAY['tid', 'bid', 'tbalance', 'filler'], + ARRAY['integer', 'integer', 'integer', 'character(84)'], + 'pgpool_catalog.dist_def_tellers' +); + +INSERT INTO pgpool_catalog.dist_def VALUES ( + 'bench_parallel', + 'public', + 'accounts', + 'aid', + ARRAY['aid', 'bid', 'abalance', 'filler'], + ARRAY['integer', 'integer', 'integer', 'character(84)'], + 'pgpool_catalog.dist_def_accounts' +); + +INSERT INTO pgpool_catalog.dist_def VALUES ( + 'bench_parallel', + 'public', + 'history', + 'tid', + ARRAY['tid', 'bid', 'aid', 'delta', 'mtime', 'filler'], + ARRAY['integer', 'integer', 'integer', 'integer', 'timestamp without time zone', 'character(22)'], + 'pgpool_catalog.dist_def_history' +); + +CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_branches(anyelement) +RETURNS integer AS $$ + SELECT CASE WHEN $1 > 0 AND $1 <= 1 THEN 0 + WHEN $1 > 1 AND $1 <= 2 THEN 1 + ELSE 2 + END; +$$ LANGUAGE sql; + +CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_tellers(anyelement) +RETURNS integer AS $$ + SELECT CASE WHEN $1 > 0 AND $1 <= 10 THEN 0 + WHEN $1 > 10 AND $1 <= 20 THEN 1 + ELSE 2 + END; +$$ LANGUAGE sql; + +CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_accounts(anyelement) +RETURNS integer AS $$ + SELECT CASE WHEN $1 > 0 AND $1 <= 100000 THEN 0 + WHEN $1 > 100000 AND $1 <= 200000 THEN 1 + ELSE 2 + END; +$$ LANGUAGE sql; + +CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_history(anyelement) +RETURNS integer AS $$ + SELECT CASE WHEN $1 > 0 AND $1 <= 10 THEN 0 + WHEN $1 > 10 AND $1 <= 20 THEN 1 + ELSE 2 + END; +$$ LANGUAGE sql; diff --git a/sample/pgpool.pam b/sample/pgpool.pam new file mode 100644 index 0000000..320f086 --- /dev/null +++ b/sample/pgpool.pam @@ -0,0 +1,3 @@ +#%PAM-1.0 +auth required pam_permit.so +account required pam_permit.so diff --git a/sample/pgpool_recovery b/sample/pgpool_recovery new file mode 100644 index 0000000..6f845e1 --- /dev/null +++ b/sample/pgpool_recovery @@ -0,0 +1,20 @@ +#! /bin/sh + +if [ $# -ne 3 ] +then + echo "pgpool_recovery datadir remote_host remote_datadir" + exit 1 +fi + +datadir=$1 +DEST=$2 +DESTDIR=$3 + +rsync -aurz --delete -e ssh $datadir/global/ $DEST:$DESTDIR/global/ & +rsync -aurz --delete -e ssh $datadir/base/ $DEST:$DESTDIR/base/ & +rsync -aurz --delete -e ssh $datadir/pg_multixact/ $DEST:$DESTDIR/pg_multixact/ & +rsync -aurz --delete -e ssh $datadir/pg_subtrans/ $DEST:$DESTDIR/pg_subtrans/ & +rsync -aurz --delete -e ssh $datadir/pg_clog/ $DEST:$DESTDIR/pg_clog/ & +rsync -aurz --delete -e ssh $datadir/pg_xlog/ $DEST:$DESTDIR/pg_xlog/ & +rsync -aurz --delete -e ssh $datadir/pg_twophase/ $DEST:$DESTDIR/pg_twophase/ & +wait diff --git a/sample/pgpool_recovery_pitr b/sample/pgpool_recovery_pitr new file mode 100644 index 0000000..670f491 --- /dev/null +++ b/sample/pgpool_recovery_pitr @@ -0,0 +1,18 @@ +#! /bin/sh +# Online recovery 2nd stage script +# +datadir=$1 # master dabatase cluster +DEST=$2 # hostname of the DB node to be recovered +DESTDIR=$3 # database cluster of the DB node to be recovered +port=5432 # PostgreSQL port number + +# Force to flush current value of sequences to xlog +psql -p $port -t -c 'SELECT datname FROM pg_database WHERE NOT datistemplate AND datallowconn' template1| +while read i +do + if [ "$i" != "" ];then + psql -p $port -c "SELECT setval(oid, nextval(oid)) FROM pg_class WHERE relkind = 'S'" $i + fi +done + +psql -p $port -c 'SELECT pg_switch_xlog()' postgres diff --git a/sample/pgpool_remote_start b/sample/pgpool_remote_start new file mode 100644 index 0000000..afd0e61 --- /dev/null +++ b/sample/pgpool_remote_start @@ -0,0 +1,13 @@ +#! /bin/sh + +if [ $# -ne 2 ] +then + echo "pgpool_remote_start remote_host remote_datadir" + exit 1 +fi + +DEST=$1 +DESTDIR=$2 +PGCTL=/usr/local/pgsql/bin/pg_ctl + +ssh -T $DEST $PGCTL -w -D $DESTDIR start 2>/dev/null 1>/dev/null < /dev/null & diff --git a/sample/replicate_def_pgbench.sql b/sample/replicate_def_pgbench.sql new file mode 100644 index 0000000..1d71370 --- /dev/null +++ b/sample/replicate_def_pgbench.sql @@ -0,0 +1,18 @@ +-- $Header: /cvsroot/pgpool/pgpool-II/sample/replicate_def_pgbench.sql,v 1.2 2008/04/09 07:03:15 y-asaba Exp $ + +INSERT INTO pgpool_catalog.replicate_def VALUES ( + 'bench_parallel', + 'public', + 'branches', + ARRAY['bid', 'bbalance', 'filler'], + ARRAY['integer', 'integer', 'character(88)'] +); + +INSERT INTO pgpool_catalog.replicate_def VALUES ( + 'bench_parallel', + 'public', + 'tellers', + ARRAY['tid', 'bid', 'tbalance', 'filler'], + ARRAY['integer', 'integer', 'integer', 'character(84)'] +); + diff --git a/sql/pgpool-recovery/Makefile b/sql/pgpool-recovery/Makefile new file mode 100644 index 0000000..9422666 --- /dev/null +++ b/sql/pgpool-recovery/Makefile @@ -0,0 +1,20 @@ +MODULES = pgpool-recovery +DATA_built = pgpool-recovery.sql + +# if you are using PostgreSQL 8.0 or later, +# using pg_config is recommended. +# if you are not, comment out following line and... +USE_PGXS = true +# set top_builddir to the PostgreSQL build source tree top. +# (for example /usr/local/src/postgresql-8.4) +top_builddir = ../.. + +ifdef USE_PGXS +PGXS = $(shell pg_config --pgxs) +include $(PGXS) +else +subdir = contrib/pgpool-recovery +#top_builddir = ../.. +include $(top_builddir)/src/Makefile.global +include $(top_srcdir)/contrib/contrib-global.mk +endif diff --git a/sql/pgpool-recovery/pgpool-recovery.c b/sql/pgpool-recovery/pgpool-recovery.c new file mode 100644 index 0000000..7a079b8 --- /dev/null +++ b/sql/pgpool-recovery/pgpool-recovery.c @@ -0,0 +1,102 @@ +/* -*-pgsql-c-*- */ +/* + * $Header: /cvsroot/pgpool/pgpool-II/sql/pgpool-recovery/pgpool-recovery.c,v 1.6.2.2 2009/07/14 08:42:24 t-ishii Exp $ + * + * pgpool-recovery: exec online recovery script from SELECT statement. + * + * Copyright (c) 2003-2009 PgPool Global Development Group + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. The author makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + */ + +#include "postgres.h" +#include "fmgr.h" +#include "miscadmin.h" +#include "executor/spi.h" +#include "funcapi.h" +#include "utils/builtins.h" /* PostgreSQL 8.4 needs this for textout */ + +#define REMOTE_START_FILE "pgpool_remote_start" + +#include + +#ifdef PG_MODULE_MAGIC +PG_MODULE_MAGIC; +#endif + +PG_FUNCTION_INFO_V1(pgpool_recovery); +PG_FUNCTION_INFO_V1(pgpool_remote_start); + +extern Datum pgpool_recovery(PG_FUNCTION_ARGS); +extern Datum pgpool_remote_start(PG_FUNCTION_ARGS); + +static char recovery_script[1024]; + +Datum +pgpool_recovery(PG_FUNCTION_ARGS) +{ + int r; + char *script = DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(PG_GETARG_TEXT_P(0)))); + + char *remote_host = DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(PG_GETARG_TEXT_P(1)))); + char *remote_data_directory = DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(PG_GETARG_TEXT_P(2)))); + + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("must be superuser to use pgpool_recovery function")))); + + snprintf(recovery_script, sizeof(recovery_script), "%s/%s %s %s %s", + DataDir, script, DataDir, remote_host, + remote_data_directory); + elog(DEBUG1, "recovery_script: %s", recovery_script); + r = system(recovery_script); + + if (r != 0) + { + elog(ERROR, "pgpool_recovery failed"); + } + + PG_RETURN_BOOL(true); +} + + +Datum +pgpool_remote_start(PG_FUNCTION_ARGS) +{ + int r; + char *remote_host = DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(PG_GETARG_TEXT_P(0)))); + char *remote_data_directory = DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(PG_GETARG_TEXT_P(1)))); + + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("must be superuser to use pgpool_remote_start function")))); + + snprintf(recovery_script, sizeof(recovery_script), + "%s/%s %s %s", DataDir, REMOTE_START_FILE, + remote_host, remote_data_directory); + elog(DEBUG1, "recovery_script: %s", recovery_script); + r = system(recovery_script); + + if (r != 0) + { + elog(ERROR, "pgpool_remote_start failed"); + } + + PG_RETURN_BOOL(true); +} diff --git a/sql/pgpool-recovery/pgpool-recovery.sql.in b/sql/pgpool-recovery/pgpool-recovery.sql.in new file mode 100644 index 0000000..68b36b2 --- /dev/null +++ b/sql/pgpool-recovery/pgpool-recovery.sql.in @@ -0,0 +1,10 @@ +CREATE OR REPLACE FUNCTION pgpool_recovery(text, text, text) +RETURNS bool +AS 'MODULE_PATHNAME', 'pgpool_recovery' +LANGUAGE C STRICT; + + +CREATE OR REPLACE FUNCTION pgpool_remote_start(text, text) +RETURNS bool +AS 'MODULE_PATHNAME', 'pgpool_remote_start' +LANGUAGE C STRICT; diff --git a/sql/system_db.sql b/sql/system_db.sql new file mode 100644 index 0000000..6ffdb68 --- /dev/null +++ b/sql/system_db.sql @@ -0,0 +1,38 @@ +-- $Header: /cvsroot/pgpool/pgpool-II/sql/system_db.sql,v 1.3 2008/04/09 07:01:27 y-asaba Exp $ + +DROP TABLE pgpool_catalog.dist_def; +DROP TABLE pgpool_catalog.replicate_def; +DROP TABLE pgpool_catalog.query_cache; +DROP SCHEMA pgpool_catalog; + + +CREATE SCHEMA pgpool_catalog; + +CREATE TABLE pgpool_catalog.dist_def( + dbname TEXT, + schema_name TEXT, + table_name TEXT, + col_name TEXT NOT NULL CHECK (col_name = ANY (col_list)), + col_list TEXT[] NOT NULL, + type_list TEXT[] NOT NULL, + dist_def_func TEXT NOT NULL, + PRIMARY KEY (dbname,schema_name,table_name) +); + +CREATE TABLE pgpool_catalog.replicate_def( + dbname TEXT, + schema_name TEXT, + table_name TEXT, + col_list TEXT[] NOT NULL, + type_list TEXT[] NOT NULL, + PRIMARY KEY (dbname,schema_name,table_name) +); + +CREATE TABLE pgpool_catalog.query_cache ( + hash TEXT, + query TEXT, + value bytea, + dbname TEXT, + create_time TIMESTAMP WITH TIME ZONE, + PRIMARY KEY(hash, dbname) +); diff --git a/strlcpy.c b/strlcpy.c new file mode 100644 index 0000000..b455e1a --- /dev/null +++ b/strlcpy.c @@ -0,0 +1,85 @@ +/* -*-pgsql-c-*- */ +/* + * + * $Header: /cvsroot/pgpool/pgpool-II/strlcpy.c,v 1.2.2.1 2009/08/22 04:19:49 t-ishii Exp $ + * + * This file was imported from PostgreSQL source code. + * See below for the copyright and description. + * + * pgpool: a language independent connection pool server for PostgreSQL + * written by Tatsuo Ishii + * + * Portions Copyright (c) 2003-2008 PgPool Global Development Group + * + */ +/*------------------------------------------------------------------------- + * + * strlcpy.c + * strncpy done right + * + * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group + * + * + * IDENTIFICATION + * $PostgreSQL: pgsql/src/port/strlcpy.c,v 1.3 2006/10/04 00:30:14 momjian Exp $ + * + * This file was taken from OpenBSD and is used on platforms that don't + * provide strlcpy(). The OpenBSD copyright terms follow. + *------------------------------------------------------------------------- + */ + +/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include "pool.h" + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + * Function creation history: http://www.gratisoft.us/todd/papers/strlcpy.html + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0) + { + while (--n != 0) + { + if ((*d++ = *s++) == '\0') + break; + } + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) + { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return (s - src - 1); /* count does not include NUL */ +} diff --git a/test/jdbc/AutoCommitTest.java b/test/jdbc/AutoCommitTest.java new file mode 100644 index 0000000..5b8194f --- /dev/null +++ b/test/jdbc/AutoCommitTest.java @@ -0,0 +1,45 @@ +import java.util.*; +import java.io.*; +import java.sql.*; + +public class AutoCommitTest extends PgpoolTest{ + public String sql = "select * from autocommit where a = ?"; + + public static void main(String[] args) throws SQLException { + AutoCommitTest test = new AutoCommitTest(); + test.do_test(); + } + + public void do_test() throws SQLException + { + connection.setAutoCommit(true); + + PreparedStatement stmt = null; + ResultSet rs = null; + + try { + for(int i = 0; i < 10; i++) { + stmt = connection.prepareStatement(sql); + try { + stmt.setInt(1, i + 1); + rs = stmt.executeQuery(); + + while(rs.next()){ + logwriter.print(rs.getInt(1) + " "); + } + logwriter.println(); + } finally { + if(rs != null) rs.close(); + if(stmt != null) stmt.close(); + } + } + } finally { + connection.close(); + logwriter.close(); + } + } + + public String getTestName() { + return "autocommit"; + } +} diff --git a/test/jdbc/BatchTest.java b/test/jdbc/BatchTest.java new file mode 100644 index 0000000..664f439 --- /dev/null +++ b/test/jdbc/BatchTest.java @@ -0,0 +1,55 @@ +import java.util.*; +import java.io.*; +import java.sql.*; + +public class BatchTest extends PgpoolTest { + public String [] batchSqls = new String[] { + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + "INSERT INTO batch VALUES (1)", + }; + + public void do_test() throws SQLException { + connection.setAutoCommit(false); + + Statement stmt = null; + ResultSet rs = null; + + try { + try { + stmt = connection.createStatement(); + for(int i=0; i100 ))) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c")) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") MATCH FULL) +syntax error: CREATE TABLE foo (a int references b(c) MATCH PARTIAL) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c")) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON UPDATE RESTRICT) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON UPDATE CASCADE) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON UPDATE SET NULL) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON UPDATE SET DEFAULT) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON DELETE RESTRICT) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON DELETE CASCADE) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON DELETE SET NULL) +CREATE TABLE "foo" ("a" "int4" REFERENCES "b"("c") ON DELETE SET DEFAULT) +CREATE TYPE "enum_test" AS ENUM ('label1','label2') +syntax error: CREATE TYPE enum_test AS ENUM (); +syntax error: CREATE TYPE enum_test AS ENUM; +CREATE TEXT SEARCH PARSER "foo"("a"='b') +CREATE TEXT SEARCH DICTIONARY "foo"("a"='b') +CREATE TEXT SEARCH CONFIGURATION "foo"("a"='b') +CREATE INDEX "foo" ON "a"("b") +CREATE INDEX "foo" ON "a"("b","c") +CREATE UNIQUE INDEX "foo" ON "a"("b") +CREATE UNIQUE INDEX CONCURRENTLY "foo" ON "a"("b") +CREATE SEQUENCE "a_seq" +CREATE TEMP SEQUENCE "a_seq" +CREATE TEMP SEQUENCE "a_seq" +CREATE SEQUENCE "a_seq" INCREMENT 1 +CREATE SEQUENCE "a_seq" INCREMENT 1 +CREATE SEQUENCE "a_seq" MINVALUE 1 +CREATE SEQUENCE "a_seq" NO MINVALUE +CREATE SEQUENCE "a_seq" MAXVALUE 1 +CREATE SEQUENCE "a_seq" NO MAXVALUE +CREATE SEQUENCE "a_seq" START 1 +CREATE SEQUENCE "a_seq" START 1 +CREATE SEQUENCE "a_seq" CACHE 1 +CREATE SEQUENCE "a_seq" CYCLE +CREATE SEQUENCE "a_seq" NO CYCLE +CREATE SEQUENCE "a_seq" OWNED BY "a", "b" +CREATE SEQUENCE "a_seq" OWNED BY "none" diff --git a/test/parser/expected/cursor.out b/test/parser/expected/cursor.out new file mode 100644 index 0000000..d4a344b --- /dev/null +++ b/test/parser/expected/cursor.out @@ -0,0 +1,37 @@ +DECLARE "xx" CURSOR FOR SELECT "*" FROM "t" +DECLARE "xx" BINARY CURSOR FOR SELECT "*" FROM "t" +DECLARE "xx" INSENSITIVE CURSOR FOR SELECT "*" FROM "t" +DECLARE "xx" SCROLL CURSOR FOR SELECT "*" FROM "t" +DECLARE "xx" CURSOR WITH HOLD FOR SELECT "*" FROM "t" +DECLARE "xx" CURSOR FOR SELECT "*" FROM "t" +CLOSE "xx" +FETCH FORWARD 1 IN "xx" +FETCH FORWARD 1 IN "xx" +FETCH BACKWARD 1 IN "xx" +FETCH LAST IN "xx" +FETCH ABSOLUTE 2 IN "xx" +FETCH RELATIVE 2 IN "xx" +FETCH FORWARD 1 IN "xx" +FETCH FORWARD ALL IN "xx" +FETCH FORWARD 1 IN "xx" +FETCH FORWARD 2 IN "xx" +FETCH FORWARD ALL IN "xx" +FETCH BACKWARD 1 IN "xx" +FETCH BACKWARD 3 IN "xx" +FETCH BACKWARD ALL IN "xx" +FETCH BACKWARD ALL IN "xx" +MOVE FORWARD 1 IN "xx" +MOVE FORWARD 1 IN "xx" +MOVE BACKWARD 1 IN "xx" +MOVE LAST IN "xx" +MOVE ABSOLUTE 2 IN "xx" +MOVE RELATIVE 2 IN "xx" +MOVE FORWARD 1 IN "xx" +MOVE FORWARD ALL IN "xx" +MOVE FORWARD 1 IN "xx" +MOVE FORWARD 2 IN "xx" +MOVE FORWARD ALL IN "xx" +MOVE BACKWARD 1 IN "xx" +MOVE BACKWARD 3 IN "xx" +MOVE BACKWARD ALL IN "xx" +MOVE BACKWARD ALL IN "xx" diff --git a/test/parser/expected/delete.out b/test/parser/expected/delete.out new file mode 100644 index 0000000..5f59db3 --- /dev/null +++ b/test/parser/expected/delete.out @@ -0,0 +1,10 @@ +DELETE FROM "t" +syntax error: DELETE ; +DELETE FROM "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +DELETE FROM "t" WHERE ("x"=3 ) +DELETE FROM "t" WHERE "x" IN ( SELECT "*" FROM "t1") +DELETE FROM "foo" WHERE ("a"=1 ) RETURNING "*" +DELETE FROM "foo" WHERE ("a"=1 ) RETURNING "a" +DELETE FROM "foo" WHERE ("a"=1 ) RETURNING "a","b" +DELETE FROM "foo" WHERE CURRENT OF $1 +DELETE FROM "foo" WHERE CURRENT OF cur diff --git a/test/parser/expected/drop.out b/test/parser/expected/drop.out new file mode 100644 index 0000000..f5d230e --- /dev/null +++ b/test/parser/expected/drop.out @@ -0,0 +1,12 @@ +DROP TABLE "foo" +DROP OWNED BY "role_a" +DROP OWNED BY "role_a" CASCADE +DROP OWNED BY "role_a" +DROP OWNED BY "role_a", "role_b", "role_c" +REASSIGN OWNED BY "role_a" TO "role_b" +REASSIGN OWNED BY "role_a", "role1" TO "role_b" +DROP OPERATOR FAMILY "foo" USING "bar" +DROP OPERATOR FAMILY IF EXISTS "foo" USING "bar" +syntax error: DROP OPERATOR FAMILY foo USING +DROP ROLE "foo" +DROP ROLE IF EXISTS "foo" diff --git a/test/parser/expected/insert.out b/test/parser/expected/insert.out new file mode 100644 index 0000000..1665ce4 --- /dev/null +++ b/test/parser/expected/insert.out @@ -0,0 +1,12 @@ +INSERT INTO "t" VALUES (1) +INSERT INTO "t"("a") VALUES (2) +INSERT INTO "t"("a", "b", "c") VALUES (2,2) +INSERT INTO "t"("a", "b", "c") VALUES (2,2,3) +INSERT INTO "t"("a", "b", "c") VALUES (2,DEFAULT,'3') +INSERT INTO "t" DEFAULT VALUES +INSERT INTO "t" SELECT "*" FROM "t" +INSERT INTO "t" VALUES ("func"("x","y")) +INSERT INTO "t"("a", "b", "c") VALUES (2,DEFAULT,'''\\') +INSERT INTO "foo"("a", "b") VALUES (1,2) RETURNING "*" +INSERT INTO "foo"("a", "b") VALUES (1,2) RETURNING "a" +INSERT INTO "foo"("a", "b") VALUES (1,2) RETURNING "a","b" diff --git a/test/parser/expected/misc.out b/test/parser/expected/misc.out new file mode 100644 index 0000000..668af47 --- /dev/null +++ b/test/parser/expected/misc.out @@ -0,0 +1,28 @@ +VACUUM +VACUUM FULL +VACUUM FULL FREEZE +VACUUM FULL FREEZE VERBOSE +VACUUM FULL FREEZE VERBOSE ANALYZE +VACUUM FULL "t" +ANALYZE ANALYZE +ANALYZE VERBOSE ANALYZE +ANALYZE VERBOSE ANALYZE "x" +ANALYZE VERBOSE ANALYZE "x"("a", "b", "c") +EXPLAIN SELECT "*" FROM "t" +EXPLAIN ANALYZE SELECT "*" FROM "t" +EXPLAIN ANALYZE VERBOSE SELECT "*" FROM "t" +REINDEX INDEX "x" +REINDEX INDEX "x" +REINDEX TABLE "x" +REINDEX TABLE "x" +REINDEX DATABASE "x" +REINDEX DATABASE "x" +REINDEX SYSTEM "x" +REINDEX SYSTEM "x" +LISTEN "x" +NOTIFY "x" +DISCARD ALL +DISCARD TEMP +DISCARD TEMP +DISCARD PLANS +syntax error: DISCARD xxx diff --git a/test/parser/expected/prepare.out b/test/parser/expected/prepare.out new file mode 100644 index 0000000..32772cc --- /dev/null +++ b/test/parser/expected/prepare.out @@ -0,0 +1,4 @@ +PREPARE "xx" ("int4","text") AS INSERT INTO "foo" VALUES ($1,$2) +EXECUTE "xx" (1,'xxx') +DEALLOCATE "xx" +DEALLOCATE "xx" diff --git a/test/parser/expected/privileges.out b/test/parser/expected/privileges.out new file mode 100644 index 0000000..63c1b24 --- /dev/null +++ b/test/parser/expected/privileges.out @@ -0,0 +1,31 @@ +GRANT select, insert, update, delete, rule, references, trigger ON "t1","t2" TO "x" +GRANT select, insert, update, delete, rule, references, trigger ON "t1","t2" TO "x" WITH GRANT OPTION +GRANT select, insert, update, delete, rule, references, trigger ON "t1","t2" TO "x" WITH GRANT OPTION +GRANT select, insert, update, delete, rule, references, trigger ON "t1","t2" TO PUBLIC +GRANT ALL ON "t1","t2" TO "x" +GRANT create ON DATABASE "db1", "db2" TO "x","y" +GRANT temporary ON DATABASE "db1", "db2" TO "x","y" +GRANT temp ON DATABASE "db1", "db2" TO "x","y" +GRANT execute ON FUNCTION "func"("int4","text") TO "x","y" +GRANT usage ON LANGUAGE "lang" TO "x","y" +GRANT create ON SCHEMA "s" TO "x","y" +GRANT usage ON SCHEMA "s" TO "x","y" +GRANT create ON TABLESPACE "tblspc" TO "x","y" +GRANT "role1" TO "role2" +REVOKE select, insert, update, delete, rule, references, trigger ON "t1","t2" FROM "x","y" +REVOKE select, insert, update, delete, rule, references, trigger ON "t1","t2" FROM "x","y" CASCADE +REVOKE select, insert, update, delete, rule, references, trigger ON "t1","t2" FROM "x","y" +REVOKE ALL ON "t1","t2" FROM "x","y" +REVOKE ALL ON "t1","t2" FROM PUBLIC +REVOKE GRANT OPTION FOR ALL ON "t1","t2" FROM PUBLIC +REVOKE GRANT OPTION FOR create ON DATABASE "db1", "db2" FROM "x","y" +REVOKE create ON DATABASE "db1", "db2" FROM "x","y" +REVOKE temporary ON DATABASE "db1", "db2" FROM "x","y" +REVOKE temp ON DATABASE "db1", "db2" FROM "x","y" +syntax error: REVOKE EXECUTE on FUNCTION foo(int,text) db1,db2 FROM x,y; +REVOKE usage ON LANGUAGE "lang" FROM "x","y" +REVOKE create ON SCHEMA "s1", "s2" FROM "x","y" +REVOKE usage ON SCHEMA "s1", "s2" FROM "x","y" +REVOKE create ON TABLESPACE "tblspc" FROM "x","y" +REVOKE ADMIN OPTION FOR "role1", "role2" FROM "x", "y" +REVOKE "role1", "role2" FROM "x", "y" diff --git a/test/parser/expected/select.out b/test/parser/expected/select.out new file mode 100644 index 0000000..29b4cae --- /dev/null +++ b/test/parser/expected/select.out @@ -0,0 +1,88 @@ + SELECT 1 + SELECT "*" FROM "t" + SELECT "x" FROM "a" + SELECT "x"."y" FROM "a" + SELECT "x" FROM "a"."b" + SELECT "foo"() + SELECT "y" FROM "foo"() +syntax error: SELECT * FROM (SELECT * FROM foo); + SELECT "a" AS "t" FROM "x" + SELECT "x" FROM "a" AS "b" + SELECT "a" AS "tttttttttttttttttttttttttttttttttttttttttttttttttttttttt" ,"b" AS "uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu" FROM "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" +syntax error: SELECT ; + SELECT "*" FROM "t" FOR UPDATE + SELECT "*" FROM "t" FOR SHARED + SELECT DISTINCT "*" FROM "t" + SELECT DISTINCT ON ("x" ) "x" FROM "t" + SELECT DISTINCT ON ("foo"("x") ) "x" FROM "t" + SELECT "*" FROM "t" + SELECT "x" FROM "t" WHERE ("x">3 ) + SELECT "count"(*) FROM "t" GROUP BY "x" HAVING ("x">111 ) + SELECT "count"(*) FROM "t" GROUP BY "x" HAVING ("x">111 ) ORDER BY "y" + SELECT "count"(*) FROM "t" GROUP BY "x" HAVING ("x">111 ) ORDER BY "y" DESC + SELECT "count"(*) FROM "t" GROUP BY "x" HAVING ("x">111 ) ORDER BY "y" + SELECT "x" FROM "t" LIMIT ALL + SELECT "x" FROM "t" LIMIT 1 + SELECT "*" FROM "t" OFFSET 1 + SELECT "*" FROM "t" OFFSET 1 LIMIT 2 + SELECT "*" FROM "t" OFFSET 1 LIMIT 2 + SELECT "*" FROM "t" LEFT OUTER JOIN "t1" ON ("x"="y" ) + SELECT "*" FROM "t" RIGHT OUTER JOIN "t1" ON ("x"="y" ) + SELECT "*" FROM "t" FULL OUTER JOIN "t1" ON ("x"="y" ) + SELECT "*" FROM "t" LEFT OUTER JOIN "t1" USING("x") + SELECT "*" FROM "t" RIGHT OUTER JOIN "t1" USING("x") + SELECT "*" FROM "t" FULL OUTER JOIN "t1" USING("x") + SELECT "*" FROM "t" JOIN "t1" ON "x" + SELECT "*" FROM "t" NATURAL LEFT OUTER JOIN "t1" + SELECT "*" FROM "t" NATURAL RIGHT OUTER JOIN "t1" + SELECT "*" FROM "t" NATURAL FULL OUTER JOIN "t1" + SELECT "*" FROM "t" WHERE "a" IS NULL + SELECT "*" FROM "t" WHERE "a" IS NOT NULL + SELECT "*" FROM "t" WHERE ("a"~~'abc' ) + SELECT "*" FROM "t" WHERE ("a"!~~'abc' ) + SELECT "*" FROM "t" WHERE ( ("a">=1 ) AND ("a"<=4 )) + SELECT "*" FROM "t" WHERE "a" IN (1,2,3,4) + SELECT "*" FROM "t" WHERE "a" NOT IN (1,2,3,4) + SELECT "*" FROM "t" WHERE EXISTS ( SELECT "*" FROM "tt") + SELECT "*" FROM "t" WHERE (NOT EXISTS ( SELECT "*" FROM "tt")) +( SELECT "*" FROM "t1") UNION ( SELECT "*" FROM "t2") +( SELECT "*" FROM "t1") UNION ALL ( SELECT "*" FROM "t2") +( SELECT "*" FROM "t1") INTERSECT ( SELECT "*" FROM "t2") +( SELECT "*" FROM "t1") INTERSECT ALL ( SELECT "*" FROM "t2") +( SELECT "*" FROM "t1") EXCEPT ( SELECT "*" FROM "t2") +( SELECT "*" FROM "t1") EXCEPT ALL ( SELECT "*" FROM "t2") +CREATE TABLE "x" AS SELECT "*" FROM "t" + SELECT "*" FROM "t1" WHERE "i"<> ALL ( SELECT "i" FROM "t2") +( SELECT "*" FROM "t1") UNION ALL ( SELECT "*" FROM "t2") ORDER BY "a" +( SELECT "*" FROM "t1") UNION ALL ( SELECT "*" FROM "t2" ORDER BY "a") + SELECT "max"("i")::"int4" FROM "test" + SELECT "max"("i")::"int4" FROM "test" WHERE ("a"='aaa''bbb\\ccc' ) + SELECT "max"("i")::"int4" FROM "test" WHERE ("a"='aaa''bbb\\ccc' ) + SELECT "*" FROM "t" WHERE 1=ANY("arr") + SELECT "*" FROM "t" WHERE 1=ALL("arr") + SELECT "*" FROM "t" WHERE 1 IS OF ("int4") + SELECT "*" FROM "t" WHERE 1 IS OF ("int4") + SELECT "*" FROM "t" WHERE "a" IN ('a','b',1) + SELECT "*" FROM "t" WHERE "a" NOT IN ('a','b',1) + SELECT "*" FROM "t" WHERE "a" IS DOCUMENT + SELECT "*" FROM "t" WHERE (NOT "a" IS DOCUMENT) + SELECT XMLCONCAT ("a","b") + SELECT XMLELEMENT (NAME "a") + SELECT XMLELEMENT (NAME "a","b","c") + SELECT XMLFOREST ("a") + SELECT XMLPARSE (DOCUMENT 1) + SELECT XMLPARSE (DOCUMENT 1 PRESERVE WHITESPACE) + SELECT "day" '1900-1-1' + SELECT "interval" '1 year' + SELECT "interval" '1 year' YEAR + SELECT "interval" '1 year' MONTH + SELECT "interval" '1 year' DAY + SELECT "interval" '1 year' HOUR + SELECT "interval" '1 year' MINUTE + SELECT "interval" '1 year' SECOND + SELECT "interval" '1 year' YEAR TO MONTH + SELECT "interval" '1 year' DAY TO HOUR + SELECT "interval" '1 year' DAY TO MINUTE + SELECT "interval" '1 year' DAY TO SECOND + SELECT "interval" '1 year' HOUR TO MINUTE + SELECT "interval" '1 year' HOUR TO SECOND diff --git a/test/parser/expected/transaction.out b/test/parser/expected/transaction.out new file mode 100644 index 0000000..cd99087 --- /dev/null +++ b/test/parser/expected/transaction.out @@ -0,0 +1,38 @@ +BEGIN +BEGIN +BEGIN +BEGIN ISOLATION LEVEL read committed +BEGIN ISOLATION LEVEL serializable +BEGIN READ WRITE +BEGIN READ ONLY +START TRANSACTION +COMMIT +COMMIT +COMMIT +COMMIT +COMMIT +COMMIT +ABORT +ABORT +ABORT +ABORT +ABORT +ABORT +SET TRANSACTION ISOLATION LEVEL read committed +SET TRANSACTION ISOLATION LEVEL serializable +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL read committed +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL serializable +SET CONSTRAINTS ALL DEFERRED +SET CONSTRAINTS ALL IMMEDIATE +SET CONSTRAINTS "x" DEFERRED +SET CONSTRAINTS "x" IMMEDIATE +LOCK TABLE "t1","t2" IN ACCESS EXCLUSIVE MODE +LOCK TABLE "t1","t2" IN ACCESS EXCLUSIVE MODE +LOCK TABLE "t1","t2" IN ACCESS SHARE MODE +LOCK TABLE "t1","t2" IN ROW SHARE MODE +LOCK TABLE "t1","t2" IN ROW EXCLUSIVE MODE +LOCK TABLE "t1","t2" IN SHARE UPDATE EXCLUSIVE MODE +LOCK TABLE "t1","t2" IN SHARE MODE +LOCK TABLE "t1","t2" IN SHARE ROW EXCLUSIVE MODE +LOCK TABLE "t1","t2" IN EXCLUSIVE MODE +LOCK TABLE "t1","t2" IN ACCESS EXCLUSIVE MODE diff --git a/test/parser/expected/update.out b/test/parser/expected/update.out new file mode 100644 index 0000000..8212834 --- /dev/null +++ b/test/parser/expected/update.out @@ -0,0 +1,11 @@ +UPDATE "t" SET "a" = 1 +UPDATE "t" SET "a" = 3, "b" = 'a', "c" = NULL, "d" = DEFAULT +UPDATE "t" SET "a" = 1 FROM "x" +UPDATE "t" SET "a" = 1 FROM "x","y","z" +UPDATE "t" SET "a" = 1 FROM "x" WHERE ( ("x"<100 ) AND ("y">200 )) +UPDATE "t" SET "a" = 1 +UPDATE "foo" SET "a" = 1 RETURNING "*" +UPDATE "foo" SET "a" = 1 RETURNING "a" +UPDATE "foo" SET "a" = 1 RETURNING "a","b" +UPDATE "foo" SET "a" = 1 WHERE CURRENT OF $1 +UPDATE "foo" SET "a" = 1 WHERE CURRENT OF cur diff --git a/test/parser/expected/var.out b/test/parser/expected/var.out new file mode 100644 index 0000000..5d6d1f1 --- /dev/null +++ b/test/parser/expected/var.out @@ -0,0 +1,22 @@ +SET var TO 'val' +SET var TO 'val' +SET var TO DEFAULT +SET var TO DEFAULT +SET TIME ZONE 'val' +SET TIME ZONE 'val' +SET TIME ZONE +SET TIME ZONE +SET LOCAL TIME ZONE +SET TIME ZONE +SET var FROM CURRENT +SET XML OPTOIN DOCUMENT +SET XML OPTOIN CONTENT +syntax error: show 'x'; +SHOW x +SHOW ALL +RESET x +RESET ALL +RESET TIME ZONE +RESET TRANSACTION ISOLATION LEVEL +RESET SESSION AUTHORIZATION +syntax error: reset 'x'; diff --git a/test/parser/input/alter.sql b/test/parser/input/alter.sql new file mode 100644 index 0000000..4a0806d --- /dev/null +++ b/test/parser/input/alter.sql @@ -0,0 +1,2 @@ +ALTER TABLE foo ; +ALTER TEXT SEARCH CONFIGURATION diff --git a/test/parser/input/copy.sql b/test/parser/input/copy.sql new file mode 100644 index 0000000..6693478 --- /dev/null +++ b/test/parser/input/copy.sql @@ -0,0 +1,15 @@ +COPY t FROM 'xxx'; +COPY t FROM stdin; +COPY t(x,y) FROM 'xxx'; +COPY t FROM 'xxx' BINARY; +COPY t FROM 'xxx' OIDS; +COPY t FROM 'xxx' DELIMITER ','; +COPY t FROM 'xxx' NULL 'x'; +COPY t TO 'yyy'; +COPY t TO stdout; +COPY t(x,y) TO 'yyy'; +COPY t TO 'yyy' BINARY; +COPY t TO 'yyy' OIDS; +COPY t TO 'yyy' DELIMITER ','; +COPY t TO 'yyy' NULL 'x'; +COPY (SELECT * FROM t) TO 'xxx'; diff --git a/test/parser/input/create.sql b/test/parser/input/create.sql new file mode 100644 index 0000000..7e33408 --- /dev/null +++ b/test/parser/input/create.sql @@ -0,0 +1,64 @@ +CREATE TABLE foo (a int, b text) +CREATE TABLE foo (a int, b text) INHERITS (bar) +CREATE TABLE foo (a int, b text) INHERITS (a,b,c,d) +CREATE TABLE foo (a int, b numeric) WITH OIDS +CREATE TABLE foo (a int, b numeric) WITHOUT OIDS +CREATE TABLE foo (a int, b numeric) WITH (fillfactor=10) +CREATE TABLE foo (a, b) AS SELECT 1, 2 +CREATE TABLE foo (a, b) WITH OIDS AS SELECT 1,2 +CREATE TABLE foo (a, b) WITHOUT OIDS AS SELECT 1,2 +CREATE TABLE foo (a, b) WITH (fillfactor=10) AS SELECT 1,2 +CREATE TABLE foo (a, b) ON COMMIT DROP +CREATE TABLE foo (a, b) ON COMMIT DELETE +CREATE TABLE foo (a, b) ON COMMIT PRESERVE +CREATE TABLE foo (a, b) ON COMMIT PRESERVE ROWS TABLESPACE data +CREATE TABLE foo (a, b) ON COMMIT DROP AS SELECT 1,2 +CREATE TABLE foo (a, b) ON COMMIT DELETE ROWS AS SELECT 1,2 +CREATE TABLE foo (a, b) ON COMMIT PRESERVE ROWS AS SELECT 1,2 +CREATE TABLE foo (a, b) ON COMMIT PRESERVE ROWS TABLESPACE data AS SELECT 1,2 +CREATE TABLE foo (a int, LIKE a INCLUDING DEFAULTS); +CREATE TABLE foo (a int, LIKE a INCLUDING CONSTRAINTS); +CREATE TABLE foo (a int, LIKE a EXCLUDING DEFAULTS); +CREATE TABLE foo (a int, LIKE a EXCLUDING CONSTRAINTS); +CREATE TABLE foo (a int unique); +CREATE TABLE foo (a int unique with(fillfactor=10)); +CREATE TABLE foo (a int primary key); +CREATE TABLE foo (a int check (a > 100)) +CREATE TABLE foo (a int references b(c)) +CREATE TABLE foo (a int references b(c) MATCH FULL) +CREATE TABLE foo (a int references b(c) MATCH PARTIAL) +CREATE TABLE foo (a int references b(c) MATCH SIMPLE) +CREATE TABLE foo (a int references b(c) ON UPDATE RESTRICT) +CREATE TABLE foo (a int references b(c) ON UPDATE CASCADE) +CREATE TABLE foo (a int references b(c) ON UPDATE SET NULL) +CREATE TABLE foo (a int references b(c) ON UPDATE SET DEFAULT) +CREATE TABLE foo (a int references b(c) ON DELETE RESTRICT) +CREATE TABLE foo (a int references b(c) ON DELETE CASCADE) +CREATE TABLE foo (a int references b(c) ON DELETE SET NULL) +CREATE TABLE foo (a int references b(c) ON DELETE SET DEFAULT) +CREATE TYPE enum_test AS ENUM ('label1', 'label2'); +CREATE TYPE enum_test AS ENUM (); +CREATE TYPE enum_test AS ENUM; +CREATE TEXT SEARCH PARSER foo (a='b') +CREATE TEXT SEARCH DICTIONARY foo (a='b') +CREATE TEXT SEARCH CONFIGURATION foo (a='b') +CREATE INDEX foo on a(b) +CREATE INDEX foo on a(b, c) +CREATE UNIQUE INDEX foo on a(b) +CREATE UNIQUE INDEX CONCURRENTLY foo on a(b) +CREATE SEQUENCE a_seq +CREATE TEMP SEQUENCE a_seq +CREATE TEMPORARY SEQUENCE a_seq +CREATE SEQUENCE a_seq INCREMENT 1 +CREATE SEQUENCE a_seq INCREMENT BY 1 +CREATE SEQUENCE a_seq minvalue 1 +CREATE SEQUENCE a_seq no minvalue +CREATE SEQUENCE a_seq maxvalue 1 +CREATE SEQUENCE a_seq no maxvalue +CREATE SEQUENCE a_seq start 1 +CREATE SEQUENCE a_seq start with 1 +CREATE SEQUENCE a_seq cache 1 +CREATE SEQUENCE a_seq cycle +CREATE SEQUENCE a_seq no cycle +CREATE SEQUENCE a_seq OWNED BY a.b +CREATE SEQUENCE a_seq OWNED BY NONE diff --git a/test/parser/input/cursor.sql b/test/parser/input/cursor.sql new file mode 100644 index 0000000..b155359 --- /dev/null +++ b/test/parser/input/cursor.sql @@ -0,0 +1,37 @@ +DECLARE xx CURSOR FOR SELECT * FROM t; +DECLARE xx BINARY CURSOR FOR SELECT * FROM t; +DECLARE xx INSENSITIVE CURSOR FOR SELECT * FROM t; +DECLARE xx SCROLL CURSOR FOR SELECT * FROM t; +DECLARE xx CURSOR WITH HOLD FOR SELECT * FROM t; +DECLARE xx CURSOR WITHOUT HOLD FOR SELECT * FROM t; +CLOSE xx; +FETCH IN xx; +FETCH NEXT IN xx; +FETCH PRIOR IN xx; +FETCH LAST IN xx; +FETCH ABSOLUTE 2 IN xx; +FETCH RELATIVE 2 IN xx; +FETCH 1 IN xx; +FETCH ALL IN xx; +FETCH FORWARD IN xx; +FETCH FORWARD 2 IN xx; +FETCH FORWARD ALL IN xx; +FETCH BACKWARD IN xx; +FETCH BACKWARD 3 IN xx; +FETCH BACKWARD ALL IN xx; +FETCH BACKWARD ALL FROM xx; +MOVE IN xx; +MOVE NEXT IN xx; +MOVE PRIOR IN xx; +MOVE LAST IN xx; +MOVE ABSOLUTE 2 IN xx; +MOVE RELATIVE 2 IN xx; +MOVE 1 IN xx; +MOVE ALL IN xx; +MOVE FORWARD IN xx; +MOVE FORWARD 2 IN xx; +MOVE FORWARD ALL IN xx; +MOVE BACKWARD IN xx; +MOVE BACKWARD 3 IN xx; +MOVE BACKWARD ALL IN xx; +MOVE BACKWARD ALL FROM xx; diff --git a/test/parser/input/delete.sql b/test/parser/input/delete.sql new file mode 100644 index 0000000..f2c63b1 --- /dev/null +++ b/test/parser/input/delete.sql @@ -0,0 +1,10 @@ +DELETE FROM t; +DELETE ; +DELETE FROM ONLY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; +DELETE FROM t WHERE x = 3; +DELETE FROM t WHERE x IN (select * from t1); +DELETE FROM foo WHERE a = 1 RETURNING *; +DELETE FROM foo WHERE a = 1 RETURNING a; +DELETE FROM foo WHERE a = 1 RETURNING a,b; +DELETE FROM foo WHERE CURRENT OF $1 +DELETE FROM foo WHERE CURRENT OF cur diff --git a/test/parser/input/drop.sql b/test/parser/input/drop.sql new file mode 100644 index 0000000..5f2c4df --- /dev/null +++ b/test/parser/input/drop.sql @@ -0,0 +1,12 @@ +DROP TABLE foo +DROP OWNED BY role_a +DROP OWNED BY role_a CASCADE +DROP OWNED BY role_a RESTRICT +DROP OWNED BY role_a, role_b, role_c +REASSIGN OWNED BY role_a TO role_b +REASSIGN OWNED BY role_a, role1 TO role_b +DROP OPERATOR FAMILY foo USING bar +DROP OPERATOR FAMILY IF EXISTS foo USING bar +DROP OPERATOR FAMILY foo USING +DROP ROLE foo +DROP ROLE IF EXISTS foo diff --git a/test/parser/input/insert.sql b/test/parser/input/insert.sql new file mode 100644 index 0000000..ac8eaad --- /dev/null +++ b/test/parser/input/insert.sql @@ -0,0 +1,12 @@ +INSERT INTO t values (1); +INSERT INTO t(a) VALUES (2); +INSERT INTO t(a,b,c) VALUES (2,2); +INSERT INTO t(a,b,c) VALUES (2,2,3); +INSERT INTO t(a,b,c) VALUES (2,DEFAULT,'3'); +INSERT INTO t DEFAULT VALUES; +INSERT INTO t SELECT * FROM t; +INSERT INTO t values (func(x, y)); +INSERT INTO t(a,b,c) VALUES (2,DEFAULT,'\'\\'); +INSERT INTO foo(a,b) VALUES (1, 2) RETURNING *; +INSERT INTO foo(a,b) VALUES (1, 2) RETURNING a; +INSERT INTO foo(a,b) VALUES (1, 2) RETURNING a,b; diff --git a/test/parser/input/misc.sql b/test/parser/input/misc.sql new file mode 100644 index 0000000..cfd013b --- /dev/null +++ b/test/parser/input/misc.sql @@ -0,0 +1,28 @@ +VACUUM; +VACUUM FULL; +VACUUM FULL FREEZE; +VACUUM FULL FREEZE VERBOSE; +VACUUM FULL FREEZE VERBOSE ANALYZE; +VACUUM FULL t; +ANALYZE +ANALYZE VERBOSE +ANALYZE VERBOSE x +ANALYZE VERBOSE x(a,b,c); +EXPLAIN SELECT * FROM t; +EXPLAIN ANALYZE SELECT * FROM t; +EXPLAIN ANALYZE VERBOSE SELECT * FROM t; +REINDEX INDEX x +REINDEX INDEX x force +REINDEX TABLE x +REINDEX TABLE x force +REINDEX DATABASE x +REINDEX DATABASE x force +REINDEX SYSTEM x +REINDEX SYSTEM x force +LISTEN x +NOTIFY x +DISCARD ALL +DISCARD TEMP +DISCARD TEMPORARY +DISCARD PLANS +DISCARD xxx diff --git a/test/parser/input/prepare.sql b/test/parser/input/prepare.sql new file mode 100644 index 0000000..51945dc --- /dev/null +++ b/test/parser/input/prepare.sql @@ -0,0 +1,4 @@ +PREPARE xx(integer, text) AS INSERT INTO foo VALUES ($1, $2); +EXECUTE xx(1, 'xxx'); +DEALLOCATE xx; +DEALLOCATE PREPARE xx; diff --git a/test/parser/input/privileges.sql b/test/parser/input/privileges.sql new file mode 100644 index 0000000..470cc33 --- /dev/null +++ b/test/parser/input/privileges.sql @@ -0,0 +1,31 @@ +GRANT SELECT, INSERT, UPDATE, DELETE, RULE, REFERENCES, TRIGGER on t1, t2 to x; +GRANT SELECT, INSERT, UPDATE, DELETE, RULE, REFERENCES, TRIGGER on t1, t2 to x WITH GRANT OPTION; +GRANT SELECT, INSERT, UPDATE, DELETE, RULE, REFERENCES, TRIGGER on t1, t2 to GROUP x WITH GRANT OPTION; +GRANT SELECT, INSERT, UPDATE, DELETE, RULE, REFERENCES, TRIGGER on t1, t2 to PUBLIC; +GRANT ALL on t1, t2 to x; +GRANT CREATE on DATABASE db1, db2 TO x,y; +GRANT TEMPORARY on DATABASE db1, db2 TO x,y; +GRANT TEMP on DATABASE db1, db2 TO x,y; +GRANT EXECUTE on FUNCTION func(int, text) TO x,y; +GRANT USAGE ON LANGUAGE lang TO x, y; +GRANT CREATE ON SCHEMA s TO x, y; +GRANT USAGE ON SCHEMA s TO x, y; +GRANT CREATE ON TABLESPACE tblspc TO x, y; +GRANT role1 to role2; +REVOKE SELECT,INSERT,UPDATE,DELETE,RULE,REFERENCES,TRIGGER on t1, t2 FROM x, y; +REVOKE SELECT,INSERT,UPDATE,DELETE,RULE,REFERENCES,TRIGGER on t1, t2 FROM x, y CASCADE; +REVOKE SELECT,INSERT,UPDATE,DELETE,RULE,REFERENCES,TRIGGER on t1, t2 FROM x, y RESTRICT; +REVOKE ALL on t1, t2 FROM x, y; +REVOKE ALL on t1, t2 FROM PUBLIC; +REVOKE GRANT OPTION FOR ALL on t1, t2 FROM PUBLIC; +REVOKE GRANT OPTION FOR CREATE on DATABASE db1,db2 FROM x,y; +REVOKE CREATE on DATABASE db1,db2 FROM x,y; +REVOKE TEMPORARY on DATABASE db1,db2 FROM x,y; +REVOKE TEMP on DATABASE db1,db2 FROM x,y; +REVOKE EXECUTE on FUNCTION foo(int,text) db1,db2 FROM x,y; +REVOKE USAGE ON LANGUAGE lang FROM x,y; +REVOKE CREATE ON SCHEMA s1,s2 FROM x,y; +REVOKE USAGE ON SCHEMA s1,s2 FROM x,y; +REVOKE CREATE ON TABLESPACE tblspc FROM x,y; +REVOKE ADMIN OPTION FOR role1, role2 FROM x,y; +REVOKE role1, role2 FROM x,y; diff --git a/test/parser/input/select.sql b/test/parser/input/select.sql new file mode 100644 index 0000000..87082d3 --- /dev/null +++ b/test/parser/input/select.sql @@ -0,0 +1,88 @@ +SELECT 1; +SELECT * FROM t; +SELECT x FROM a; +SELECT x.y FROM a; +SELECT x FROM a.b; +SeLeCt foo(); +SELECT y FROM foo(); +SELECT * FROM (SELECT * FROM foo); +select a as t from x; +SELECT x FROM a as b; +SELECT a as tttttttttttttttttttttttttttttttttttttttttttttttttttttttt, b as uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu from zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; +SELECT ; +SELECT * FROM t FOR UPDATE +SELECT * FROM t FOR SHARE +SELECT distinct * FROM t +select distinct on (x) x from t; +select distinct on (foo(x)) x from t; +SELECT ALL * FROM t; +SELECT x FROM t WHERE x > 3; +SELECT count(*) FROM t GROUP BY x HAVING x > 111; +SELECT count(*) FROM t GROUP BY x HAVING x > 111 ORDER BY y; +SELECT count(*) FROM t GROUP BY x HAVING x > 111 ORDER BY y DESC; +SELECT count(*) FROM t GROUP BY x HAVING x > 111 ORDER BY y ASC; +SELECT x FROM t LIMIT ALL; +SELECT x FROM t LIMIT 1; +SELECT * from t offset 1; +SELECT * from t limit 2 offset 1; +SELECT * from t offset 1 limit 2; +SELECT * FROM t left outer join t1 on (x = y); +SELECT * FROM t right outer join t1 on (x = y); +SELECT * FROM t full outer join t1 on (x = y); +SELECT * FROM t left outer join t1 using (x); +SELECT * FROM t right outer join t1 using (x); +SELECT * FROM t full outer join t1 using (x); +SELECT * FROM t inner join t1 on x; +SELECT * FROM t natural left outer join t1; +SELECT * FROM t natural right outer join t1; +SELECT * FROM t natural full outer join t1; +select * from t where a IS NULL +select * from t where a IS NOT NULL +select * from t where a like 'abc'; +select * from t where a not like 'abc'; +SELECT * FROM t where a between 1 and 4; +SELECT * FROM t where a In (1,2,3,4); +SELECT * FROM t where a not In (1,2,3,4); +SELECT * FROM t WHERE EXISTS (select * from tt); +SELECT * FROM t WHERE NOT EXISTS (select * from tt); +(SELECT * FROM t1) UNION (SELECT * FROM t2); +(SELECT * FROM t1) UNION ALL (SELECT * FROM t2); +(SELECT * FROM t1) INTERSECT (SELECT * FROM t2); +(SELECT * FROM t1) INTERSECT ALL (SELECT * FROM t2); +(SELECT * FROM t1) EXCEPT (SELECT * FROM t2); +(SELECT * FROM t1) EXCEPT ALL (SELECT * FROM t2); +SELECT * INTO x FROM t; +select * from t1 where i <> ALL (select i from t2); +SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY a; +SELECT * FROM t1 UNION ALL (SELECT * FROM t2 ORDER BY a); +select max(i)::int from test +select max(i)::int from test where a = 'aaa''bbb\\ccc' +select max(i)::int from test where a = 'aaa\'bbb\\ccc' +SELECT * FROM t WHERE 1 = any(arr) +SELECT * FROM t WHERE 1 = all(arr) +SELECT * FROM t WHERE 1 IS OF (int) +SELECT * FROM t WHERE 1 IS NOT OF (int) +SELECT * FROM t WHERE a IN ('a','b',1); +SELECT * FROM t WHERE a NOT IN ('a','b',1); +SELECT * FROM t WHERE a IS DOCUMENT; +SELECT * FROM t WHERE a IS NOT DOCUMENT; +SELECT XMLCONCAT(a,b); +SELECT XMLELEMENT(NAME a); +SELECT XMLELEMENT(NAME a,b,c); +SELECT XMLFOREST(a) +SELECT XMLPARSE(DOCUMENT 1 STRIP WHITESPACE) +SELECT XMLPARSE(DOCUMENT 1 PRESERVE WHITESPACE) +SELECT day '1900-1-1' +SELECT interval '1 year' +SELECT interval '1 year' YEAR +SELECT interval '1 year' MONTH +SELECT interval '1 year' DAY +SELECT interval '1 year' HOUR +SELECT interval '1 year' MINUTE +SELECT interval '1 year' SECOND +SELECT interval '1 year' YEAR TO MONTH +SELECT interval '1 year' DAY TO HOUR +SELECT interval '1 year' DAY TO MINUTE +SELECT interval '1 year' DAY TO SECOND +SELECT interval '1 year' HOUR TO MINUTE +SELECT interval '1 year' HOUR TO SECOND diff --git a/test/parser/input/transaction.sql b/test/parser/input/transaction.sql new file mode 100644 index 0000000..5f9ce75 --- /dev/null +++ b/test/parser/input/transaction.sql @@ -0,0 +1,38 @@ +BEGIN; +BEGIN WORK; +BEGIN TRANSACTION; +BEGIN ISOLATION LEVEL READ COMMITTED; +BEGIN ISOLATION LEVEL SERIALIZABLE; +BEGIN READ WRITE; +BEGIN READ ONLY; +START TRANSACTION; +COMMIT; +COMMIT WORK; +COMMIT TRANSACTION; +END; +END WORK; +END TRANSACTION; +ROLLBACK; +ROLLBACK WORK; +ROLLBACK TRANSACTION; +ABORT; +ABORT WORK; +ABORT TRANSACTION; +SET TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED; +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE; +SET CONSTRAINTS ALL DEFERRED; +SET CONSTRAINTS ALL IMMEDIATE; +SET CONSTRAINTS x DEFERRED; +SET CONSTRAINTS x IMMEDIATE; +LOCK TABLE t1,t2; +LOCK t1,t2; +LOCK TABLE t1,t2 IN ACCESS SHARE MODE; +LOCK TABLE t1,t2 IN ROW SHARE MODE; +LOCK TABLE t1,t2 IN ROW EXCLUSIVE MODE; +LOCK TABLE t1,t2 IN SHARE UPDATE EXCLUSIVE MODE; +LOCK TABLE t1,t2 IN SHARE MODE; +LOCK TABLE t1,t2 IN SHARE ROW EXCLUSIVE MODE; +LOCK TABLE t1,t2 IN EXCLUSIVE MODE; +LOCK TABLE t1,t2 IN ACCESS EXCLUSIVE MODE; diff --git a/test/parser/input/update.sql b/test/parser/input/update.sql new file mode 100644 index 0000000..0b56105 --- /dev/null +++ b/test/parser/input/update.sql @@ -0,0 +1,11 @@ +UPDATE t set a = 1; +UPDATE t set a = 3, b = 'a', c = NULL, d = DEFAULT; +UPDATE t set a = 1 FROM x; +UPDATE t set a = 1 FROM x,y,z; +UPDATE t set a = 1 FROM x where x < 100 and y > 200; +UPDATE ONLY t set a = 1; +UPDATE foo SET a = 1 RETURNING *; +UPDATE foo SET a = 1 RETURNING a; +UPDATE foo SET a = 1 RETURNING a,b; +UPDATE foo SET a = 1 WHERE CURRENT OF $1 +UPDATE foo SET a = 1 WHERE CURRENT OF cur diff --git a/test/parser/input/var.sql b/test/parser/input/var.sql new file mode 100644 index 0000000..8c49b32 --- /dev/null +++ b/test/parser/input/var.sql @@ -0,0 +1,22 @@ +SET var TO val +SET var TO 'val' +SET var TO DEFAULT +SET var = DEFAULT +SET TIME ZONE val +SET TIME ZONE 'val' +SET TIME ZONE local +SET TIME ZONE default +SET local TIME ZONE default +SET session TIME ZONE default +SET var FROM CURRENT +SET XML OPTION DOCUMENT +SET XML OPTION CONTENT +show 'x'; +show x; +show all; +reset x; +reset all; +reset time zone; +reset transaction isolation level +reset session authorization +reset 'x'; diff --git a/test/parser/main.c b/test/parser/main.c new file mode 100644 index 0000000..2759337 --- /dev/null +++ b/test/parser/main.c @@ -0,0 +1,40 @@ +/* $Header: /cvsroot/pgpool/pgpool-II/test/parser/main.c,v 1.1 2007/10/03 04:47:18 y-asaba Exp $ */ +#include "pool.h" +#include "pool_memory.h" +#include "parsenodes.h" +#include "gramparse.h" +#include "parse.h" +#include "parser.h" + +#include +#include + +int main(int argc, char **argv) +{ + List *tree; + ListCell *l; + + if (argc != 2) + { + fprintf(stderr, "./parser-test query\n"); + exit(1); + } + + tree = raw_parser(argv[1]); + + if (tree == NULL) + { + printf("syntax error: %s\n", argv[1]); + } + else + { + foreach(l, tree) + { + Node *node = (Node *) lfirst(l); + printf("%s\n", nodeToString(node)); + } + } + + free_parser(); + return 0; +} diff --git a/test/parser/parse_schedule b/test/parser/parse_schedule new file mode 100644 index 0000000..b049715 --- /dev/null +++ b/test/parser/parse_schedule @@ -0,0 +1,13 @@ +select +insert +update +delete +misc +var +copy +privileges +transaction +cursor +prepare +create +drop diff --git a/test/parser/pool.h b/test/parser/pool.h new file mode 100644 index 0000000..edcb690 --- /dev/null +++ b/test/parser/pool.h @@ -0,0 +1,13 @@ +#ifndef POOL_H +#define POOL_H + +#include +#include + +#define pool_error printf +#define pool_debug printf +#define pool_log printf +#define child_exit exit + +#endif + diff --git a/test/parser/run-test b/test/parser/run-test new file mode 100755 index 0000000..0a5da7d --- /dev/null +++ b/test/parser/run-test @@ -0,0 +1,69 @@ +#! /usr/bin/env ruby + +# $Header: /cvsroot/pgpool/pgpool-II/test/parser/run-test,v 1.2 2007/10/03 04:52:26 y-asaba Exp $ + +# +# Usage¡§./run-test schedule +# ignore a line at the beginning of '#' +# + +INPUT_DIRECTORY="input" +EXPECTED_DIRECTORY="expected" +RESULT_DIRECTORY="result" +TEST_PROGRAM="./parser-test" +DIFF_FILE="test.diff" + +def escape_string str + str.gsub(/([\$\"\\])/) { "\\" + $1 } +end + +if ARGV.size != 1 + STDERR.puts "run-test schedule_file" + exit 1 +end + +file = ARGV.shift +if !(File.exists? file) + STDERR.puts "run-test: file does not exist: #{file}" + exit 1 +end + +if !(File.exists? RESULT_DIRECTORY) + Dir.mkdir RESULT_DIRECTORY +else + Dir["#{RESULT_DIRECTORY}/*.out"].each do |f| + File.unlink f + end +end + +File.unlink DIFF_FILE if File.exists? DIFF_FILE + +begin + IO.foreach(file) do |testcase| + testcase.chomp! + if (/^\#/ =~ testcase or testcase == "") + next + end + + print "testcase #{testcase}:\t" + begin + IO.foreach("#{INPUT_DIRECTORY}/#{testcase}.sql") do |test_sql| + test_sql.chomp! + system("#{TEST_PROGRAM} \"#{escape_string(test_sql)}\" >> #{RESULT_DIRECTORY}/#{testcase}.out\n") + end + + system("diff -c #{EXPECTED_DIRECTORY}/#{testcase}.out #{RESULT_DIRECTORY}/#{testcase}.out >> #{DIFF_FILE}") + + if ($? == 0) + print "OK\n" + else + print "FAILED\n" + end + rescue + print "FAILED\n" + end + end + +rescue + STDERR.puts "NG" +end diff --git a/version.h b/version.h new file mode 100644 index 0000000..4fa8ca7 --- /dev/null +++ b/version.h @@ -0,0 +1 @@ +#define PGPOOLVERSION "urukiboshi" diff --git a/ylwrap b/ylwrap new file mode 100755 index 0000000..102bd89 --- /dev/null +++ b/ylwrap @@ -0,0 +1,223 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. + +scriptversion=2005-05-14.22 + +# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# Written by Tom Tromey . +# +# 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, 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +case "$1" in + '') + echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 + exit 1 + ;; + --basedir) + basedir=$2 + shift 2 + ;; + -h|--h*) + cat <<\EOF +Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... + +Wrapper for lex/yacc invocations, renaming files as desired. + + INPUT is the input file + OUTPUT is one file PROG generates + DESIRED is the file we actually want instead of OUTPUT + PROGRAM is program to run + ARGS are passed to PROG + +Any number of OUTPUT,DESIRED pairs may be used. + +Report bugs to . +EOF + exit $? + ;; + -v|--v*) + echo "ylwrap $scriptversion" + exit $? + ;; +esac + + +# The input. +input="$1" +shift +case "$input" in + [\\/]* | ?:[\\/]*) + # Absolute path; do nothing. + ;; + *) + # Relative path. Make it absolute. + input="`pwd`/$input" + ;; +esac + +pairlist= +while test "$#" -ne 0; do + if test "$1" = "--"; then + shift + break + fi + pairlist="$pairlist $1" + shift +done + +# The program to run. +prog="$1" +shift +# Make any relative path in $prog absolute. +case "$prog" in + [\\/]* | ?:[\\/]*) ;; + *[\\/]*) prog="`pwd`/$prog" ;; +esac + +# FIXME: add hostname here for parallel makes that run commands on +# other machines. But that might take us over the 14-char limit. +dirname=ylwrap$$ +trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 +mkdir $dirname || exit 1 + +cd $dirname + +case $# in + 0) $prog "$input" ;; + *) $prog "$@" "$input" ;; +esac +ret=$? + +if test $ret -eq 0; then + set X $pairlist + shift + first=yes + # Since DOS filename conventions don't allow two dots, + # the DOS version of Bison writes out y_tab.c instead of y.tab.c + # and y_tab.h instead of y.tab.h. Test to see if this is the case. + y_tab_nodot="no" + if test -f y_tab.c || test -f y_tab.h; then + y_tab_nodot="yes" + fi + + # The directory holding the input. + input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` + # Quote $INPUT_DIR so we can use it in a regexp. + # FIXME: really we should care about more than `.' and `\'. + input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` + + while test "$#" -ne 0; do + from="$1" + # Handle y_tab.c and y_tab.h output by DOS + if test $y_tab_nodot = "yes"; then + if test $from = "y.tab.c"; then + from="y_tab.c" + else + if test $from = "y.tab.h"; then + from="y_tab.h" + fi + fi + fi + if test -f "$from"; then + # If $2 is an absolute path name, then just use that, + # otherwise prepend `../'. + case "$2" in + [\\/]* | ?:[\\/]*) target="$2";; + *) target="../$2";; + esac + + # We do not want to overwrite a header file if it hasn't + # changed. This avoid useless recompilations. However the + # parser itself (the first file) should always be updated, + # because it is the destination of the .y.c rule in the + # Makefile. Divert the output of all other files to a temporary + # file so we can compare them to existing versions. + if test $first = no; then + realtarget="$target" + target="tmp-`echo $target | sed s/.*[\\/]//g`" + fi + # Edit out `#line' or `#' directives. + # + # We don't want the resulting debug information to point at + # an absolute srcdir; it is better for it to just mention the + # .y file with no path. + # + # We want to use the real output file name, not yy.lex.c for + # instance. + # + # We want the include guards to be adjusted too. + FROM=`echo "$from" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + TARGET=`echo "$2" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + + sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ + -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? + + # Check whether header files must be updated. + if test $first = no; then + if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then + echo "$2" is unchanged + rm -f "$target" + else + echo updating "$2" + mv -f "$target" "$realtarget" + fi + fi + else + # A missing file is only an error for the first file. This + # is a blatant hack to let us support using "yacc -d". If -d + # is not specified, we don't want an error when the header + # file is "missing". + if test $first = yes; then + ret=1 + fi + fi + shift + shift + first=no + done +else + ret=$? +fi + +# Remove the directory. +cd .. +rm -rf $dirname + +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: -- 2.39.2