Re: [HACKERS] Re: proposal: ignore null fields in not relation type composite type based constructors
I am sory too much patches Regards Pavel 2014-09-04 7:35 GMT+02:00 Jeevan Chalke jeevan.cha...@enterprisedb.com: Hi Pavel, You have attached wrong patch. Thanks -- Jeevan B Chalke Principal Software Engineer, Product Development EnterpriseDB Corporation The Enterprise PostgreSQL Company commit eb67c8d3e5e443d9cad1ef08fe2b4747eac933d9 Author: Pavel Stehule pavel.steh...@gooddata.com Date: Sat Jun 28 17:40:47 2014 +0200 as function with default parameters diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 722640b..0d915c1 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -10294,11 +10294,12 @@ table2-mapping /row row entry - literalrow_to_json(record [, pretty_bool])/literal + literalrow_to_json(rowval record [, pretty bool [, ignore_nulls bool] ])/literal /entry entry Returns the row as a JSON object. Line feeds will be added between - level-1 elements if parameterpretty_bool/parameter is true. + level-1 elements if parameterpretty_bool/parameter is true. Ignore + NULL when parameterignore_nulls/parameter is true. /entry entryliteralrow_to_json(row(1,'foo'))/literal/entry entryliteral{f1:1,f2:foo}/literal/entry diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 1bde175..02cf965 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -867,3 +867,10 @@ RETURNS interval LANGUAGE INTERNAL STRICT IMMUTABLE AS 'make_interval'; + +CREATE OR REPLACE FUNCTION + row_to_json(rowval record, pretty boolean DEFAULT false, ignore_nulls boolean DEFAULT false) +RETURNS json +LANGUAGE INTERNAL +STRICT STABLE +AS 'row_to_json'; diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index 494a028..9f445ff 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -79,7 +79,8 @@ static void report_invalid_token(JsonLexContext *lex); static int report_json_context(JsonLexContext *lex); static char *extract_mb_char(char *s); static void composite_to_json(Datum composite, StringInfo result, - bool use_line_feeds); + bool use_line_feeds, + bool ignore_nulls); static void array_dim_to_json(StringInfo result, int dim, int ndims, int *dims, Datum *vals, bool *nulls, int *valcount, JsonTypeCategory tcategory, Oid outfuncoid, @@ -1362,7 +1363,7 @@ datum_to_json(Datum val, bool is_null, StringInfo result, array_to_json_internal(val, result, false); break; case JSONTYPE_COMPOSITE: - composite_to_json(val, result, false); + composite_to_json(val, result, false, false); break; case JSONTYPE_BOOL: outputstr = DatumGetBool(val) ? true : false; @@ -1591,7 +1592,8 @@ array_to_json_internal(Datum array, StringInfo result, bool use_line_feeds) * Turn a composite / record into JSON. */ static void -composite_to_json(Datum composite, StringInfo result, bool use_line_feeds) +composite_to_json(Datum composite, StringInfo result, bool use_line_feeds, +bool ignore_nulls) { HeapTupleHeader td; Oid tupType; @@ -1630,6 +1632,12 @@ composite_to_json(Datum composite, StringInfo result, bool use_line_feeds) if (tupdesc-attrs[i]-attisdropped) continue; + val = heap_getattr(tuple, i + 1, tupdesc, isnull); + + /* Don't serialize NULL field when we don't want it */ + if (isnull ignore_nulls) + continue; + if (needsep) appendStringInfoString(result, sep); needsep = true; @@ -1638,8 +1646,6 @@ composite_to_json(Datum composite, StringInfo result, bool use_line_feeds) escape_json(result, attname); appendStringInfoChar(result, ':'); - val = heap_getattr(tuple, i + 1, tupdesc, isnull); - if (isnull) { tcategory = JSONTYPE_NULL; @@ -1721,34 +1727,19 @@ array_to_json_pretty(PG_FUNCTION_ARGS) } /* - * SQL function row_to_json(row) + * SQL function row_to_json(rowval record, pretty bool, ignore_nulls bool) */ extern Datum row_to_json(PG_FUNCTION_ARGS) { Datum array = PG_GETARG_DATUM(0); - StringInfo result; - - result = makeStringInfo(); - - composite_to_json(array, result, false); - - PG_RETURN_TEXT_P(cstring_to_text_with_len(result-data, result-len)); -} - -/* - * SQL function row_to_json(row, prettybool) - */ -extern Datum -row_to_json_pretty(PG_FUNCTION_ARGS) -{ - Datum array = PG_GETARG_DATUM(0); bool use_line_feeds = PG_GETARG_BOOL(1); + bool ignore_nulls = PG_GETARG_BOOL(2); StringInfo result; result = makeStringInfo(); - composite_to_json(array, result, use_line_feeds); + composite_to_json(array, result, use_line_feeds, ignore_nulls); PG_RETURN_TEXT_P(cstring_to_text_with_len(result-data, result-len)); } diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 5176ed0..5aeadc3 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -4203,10 +4203,8 @@ DATA(insert
Re: [HACKERS] PQputCopyEnd doesn't adhere to its API contract
On Wed, Sep 3, 2014 at 6:25 PM, Bruce Momjian [via PostgreSQL] ml-node+s1045698n5817646...@n5.nabble.com wrote: On Fri, May 9, 2014 at 12:03:36PM -0400, Robert Haas wrote: On Thu, May 8, 2014 at 5:21 PM, Tom Lane [hidden email] http://user/SendEmail.jtp?type=nodenode=5817646i=0 wrote: Perhaps the text should be like this: The result is 1 if the termination message was sent; or in nonblocking mode, this may only indicate that the termination message was successfully queued. (In nonblocking mode, to be certain that the data has been sent, you should next wait for write-ready and call functionPQflush/, repeating until it returns zero.) Zero indicates that the function could not queue the termination message because of full buffers; this will only happen in nonblocking mode. (In this case, wait for write-ready and try the PQputCopyEnd call again.) If a hard error occurs, -1 is returned; you can use functionPQerrorMessage/function to retrieve details. That looks pretty good. However, I'm realizing this isn't the only place where we probably need to clarify the language. Just to take one example near at hand, PQputCopyData may also return 1 when it's only queued the data; it seems to try even less hard than PQputCopyEnd to ensure that the data is actually sent. Uh, where are we on this? The comment for PQsetnonblocking in 31.4 says: In the nonblocking state, calls to PQsendQuery, PQputline, PQputnbytes, and PQendcopy will not block but instead return an error if they need to be called again. This is apparently false for PQendcopy - I did not go look at the others I stand by my belief that someone who is using Non-Blocking Mode on read should understand how to proceed if they receive a 1 or 0 result from one of the put calls. A cross-reference to the relevant section of the docs may be in order if that assumption is felt to be too optimistic. While it could possibly be more prominent the last sentence in 31.4 states: After sending any command or data on a nonblocking connection, call PQflush. If it returns 1, wait for the socket to be write-ready and call it again; repeat until it returns 0. Once PQflush returns 0, wait for the socket to be read-ready and then read the response as described above. That said, I imagine a tip section for PQputCopyData may be in order if the caller can gain efficiencies by filling up the queue before going and polling with PQflush. I imagine this is the exact reason that the potential for a 0 result exists. From the comment in 31.4 each call to PQputCopyData should be followed by the call to PQflush... As is my usual I decided to use my fresh perspective to see if I could organize the material in a more structured, and in this case less repetitive, way. Sending a diff/patch and a PDF of the result of make html I did not look at the 31.9.3 - Obsolete Functions section Is there any particular rule-of-thumb for choosing 0 or zero that I should consider? I tended to pick 0 in almost all cases and even fixed a few otherwise untouched blocks of text. The adjective network in ...to read from or write to the network connection used by libpq. seems redundant... David J. P.S. I am also curious as to why the documents generated using make html do not more closely (and there is quite a gap) match the style of the online website libpq_sgml_31_9_functions_associated_with_the_copy_command.diff (14K) http://postgresql.1045698.n5.nabble.com/attachment/5817691/0/libpq_sgml_31_9_functions_associated_with_the_copy_command.diff libpq_sgml_31_9_functions_associated_with_the_copy_command.pdf (263K) http://postgresql.1045698.n5.nabble.com/attachment/5817691/1/libpq_sgml_31_9_functions_associated_with_the_copy_command.pdf -- View this message in context: http://postgresql.1045698.n5.nabble.com/PQputCopyEnd-doesn-t-adhere-to-its-API-contract-tp5803240p5817691.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
Re: [HACKERS] postgresql latency bgwriter not doing its job
On Sat, Aug 30, 2014 at 8:50 PM, Tom Lane t...@sss.pgh.pa.us wrote: Andres Freund and...@2ndquadrant.com writes: On 2014-08-27 19:23:04 +0300, Heikki Linnakangas wrote: A long time ago, Itagaki Takahiro wrote a patch sort the buffers and write them out in order (http://www.postgresql.org/message-id/flat/20070614153758.6a62.itagaki.takah...@oss.ntt.co.jp). The performance impact of that was inconclusive, but one thing that it allows nicely is to interleave the fsyncs, so that you write all the buffers for one file, then fsync it, then next file and so on. ... So, *very* clearly sorting is a benefit. pg_bench alone doesn't convince me on this. The original thread found cases where it was a loss, IIRC; you will need to test many more than one scenario to prove the point. The same objection came up last time I tried to push for sorted checkpoints. I did not find any reference to where it caused a loss, nor was I able to come up with a case where writing out in arbitrary order would be better than writing out in file sequential order. In fact if we ask for low latency this means that the OS must keep the backlog small eliminating any chance of write combining writes that arrive out of order. I have a use case where the system continuously loads data into time partitioned indexed tables, at every checkpoint all of the indexes of the latest partition need to be written out. The only way I could get the write out to happen with sequential I/O was to set checkpoint_completion_target to zero and ensure OS cache allows for enough dirty pages to absorb the whole checkpoint. The fsync that followed did obviously nasty things to latency. Whereas sorted checkpoints were able to do sequential I/O with checkpoint spreading and low latency tuned OS virtual memory settings. I can create a benchmark that shows this behavior if you need additional data points to pgbench's OLTP workload to convince you that sorting checkpoint writes is a good idea. I did just come up with a case where plain sorting might cause an issue. If the writes go to different I/O devices then naive sorting will first use one device then the other, whereas arbitrary writing will load balance between the devices. Assuming that separate tablespaces are used for separate I/O devices, it should be enough to just interleave writes of each tablespace, weighed by the amount of writes per tablespace. Regards, Ants Aasma -- Cybertec Schönig Schönig GmbH Gröhrmühlgasse 26 A-2700 Wiener Neustadt Web: http://www.postgresql-support.de -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] postgresql latency bgwriter not doing its job
On Thu, Sep 4, 2014 at 12:36 AM, Andres Freund and...@2ndquadrant.com wrote: It's imo quite clearly better to keep it allocated. For one after postmaster started the checkpointer successfully you don't need to be worried about later failures to allocate memory if you allocate it once (unless the checkpointer FATALs out which should be exceedingly rare - we're catching ERRORs). It's much much more likely to succeed initially. Secondly it's not like there's really that much time where no checkpointer isn't running. In principle you could do the sort with the full sized array and then compress it to a list of buffer IDs that need to be written out. This way most of the time you only need a small array and the large array is only needed for a fraction of a second. Regards, Ants Aasma -- Cybertec Schönig Schönig GmbH Gröhrmühlgasse 26 A-2700 Wiener Neustadt Web: http://www.postgresql-support.de -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [Fwd: Re: [HACKERS] proposal: new long psql parameter --on-error-stop]
Hi here is a second variant with support --help=variables Regards Pavel 2014-09-04 4:25 GMT+02:00 Robert Haas robertmh...@gmail.com: On Thu, Aug 28, 2014 at 11:20 AM, Andres Freund and...@2ndquadrant.com wrote: * How about making it --help=variables instead of --help-variables? -1, help is not a variable to be assigned imho I don't think variable assignment is a good mental model for long commandline arguments. And it's not like I'm the first to come up with an extensible --help. Check e.g. gcc. But anyway, I guess I've lost that argument. I think it mostly depends on how far we think we might extend it. I mean, --help-variables is fine as a parallel to --help. But if we're eventually going to have help for 12 things, --help=TOPIC is a lot better than 12 separate switches. So +0.5 for your proposal from me. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company commit cac76b6135ae9f4b3c1eab1ce6bc34b43a7506ef Author: Pavel Stehule pavel.steh...@gooddata.com Date: Wed Aug 27 22:47:07 2014 +0200 access to help_variables and usage from psql via psql command diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index db314c3..05a0f01 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -560,11 +560,18 @@ EOF varlistentry termoption-?//term termoption--help//term + termoption--help=replaceable class=parametertopic/replaceable/option/term listitem para Show help about applicationpsql/application command line arguments, and exit. /para + + para + option--help=variables/show help about applicationpsql/application variables, + and exit. + /para + /listitem /varlistentry @@ -2572,10 +2579,12 @@ testdb=gt; userinput\setenv LESS -imx4F/userinput varlistentry -termliteral\?/literal/term +termliteral\? [ options | variables ]/literal/term listitem para -Shows help information about the backslash commands. +Shows help information about the backslash commands. This command can have a +option variables or options to take help for psql configuration variables +or psql command line options. /para /listitem /varlistentry diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index e16b4d5..987a79f 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1503,7 +1503,19 @@ exec_command(const char *cmd, /* \? -- slash command help */ else if (strcmp(cmd, ?) == 0) - slashUsage(pset.popt.topt.pager); + { + char *opt0 = psql_scan_slash_option(scan_state, + OT_NORMAL, NULL, false); + + if (!opt0) + slashUsage(pset.popt.topt.pager); + else if (strcmp(opt0, variables) == 0) + help_variables(pset.popt.topt.pager); + else if (strcmp(opt0, options) == 0) + usage(pset.popt.topt.pager); + else + slashUsage(pset.popt.topt.pager); + } #if 0 diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index f8f000f..0ada015 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -46,11 +46,12 @@ #define ON(var) (var ? _(on) : _(off)) void -usage(void) +usage(unsigned short int pager) { const char *env; const char *user; char *errstr; + FILE *output; /* Find default user, in case we need it. */ user = getenv(PGUSER); @@ -64,77 +65,82 @@ usage(void) } } - printf(_(psql is the PostgreSQL interactive terminal.\n\n)); - printf(_(Usage:\n)); - printf(_( psql [OPTION]... [DBNAME [USERNAME]]\n\n)); + output = PageOutput(59, pager); + + fprintf(output, _(psql is the PostgreSQL interactive terminal.\n\n)); + fprintf(output, _(Usage:\n)); + fprintf(output, _( psql [OPTION]... [DBNAME [USERNAME]]\n\n)); - printf(_(General options:\n)); + fprintf(output, _(General options:\n)); /* Display default database */ env = getenv(PGDATABASE); if (!env) env = user; - printf(_( -c, --command=COMMANDrun only single command (SQL or internal) and exit\n)); - printf(_( -d, --dbname=DBNAME database name to connect to (default: \%s\)\n), env); - printf(_( -f, --file=FILENAME execute commands from file, then exit\n)); - printf(_( -l, --list list available databases, then exit\n)); - printf(_( -v, --set=, --variable=NAME=VALUE\n - set psql variable NAME to VALUE\n)); - printf(_( -V, --versionoutput version information, then exit\n)); - printf(_( -X, --no-psqlrc do not read startup file (~/.psqlrc)\n)); - printf(_( -1 (\one\), --single-transaction\n + fprintf(output, _( -c, --command=COMMANDrun only single command (SQL or internal) and exit\n)); + fprintf(output, _( -d, --dbname=DBNAME database name to connect to (default: \%s\)\n), env); + fprintf(output, _( -f, --file=FILENAME execute commands from file, then exit\n)); + fprintf(output, _(
Re: [HACKERS] implement subject alternative names support for SSL connections
On Wed, Sep 3, 2014 at 11:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: * It's ugly that the caller does the malloc and memcpy, and the certificate_name_entry_validate_match function then modifies its name argument. Move the malloc+memcpy inside the function. For the case of CN the caller has to do the malloc anyway, since X509_NAME_get_text_by_NID expects the already allocated buffer. This means that 'movable' malloc + memcpy occurs only once, and while it would still make sense to move it into the function, it would also mean we would do an unnecessary malloc for the case of CN. * The error message in certificate_name_entry_validate_match says SSL certificate's common name contains embedded null even though it's also used for SANs. Will fix, thank you. The tricky part is the error message if no match was found: initially, it only listed a single common name, but now tracking all DNS names just for the sake of the error message makes the code more bloated, so I'm wondering if simply stating that there was no match, as implemented in the attached patch, would be good enough? Hmm. It would still be nice to say something about the certificate that was received. How about: server certificate with common name %s does not match host name %s We cannot guarantee at this point that the common name is present in the certificate. And if it is not, which name should we pick instead? One way to solve this is to take the first non-NULL name, but it if there is no common name, but then the wording of the error message would depend on the availability of CN. Another is to show all available names, but I do not like collecting them just for the sake of displaying in the error message. And last one is to just show the error without mentioning names, that's what I've chosen to be the most consistent. Regards, -- Alexey Klyukin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On Wed, Sep 3, 2014 at 11:19 PM, Hannu Krosing ha...@2ndquadrant.com wrote: SELECT[1] - select exactly one row, anything else raises error SELECT[0:1] - select zero or one rows, anything else raises error SELECT[1:] - select one or more rows plain SELECT is equivalent to SELECT[0:] same syntax could be used for enforcing sane affected row counts for INSERT and DELETE +1 for a new fresh creative idea! My mind was stuck in a looking for keywords state. The only suggestion I think is slightly better is the STRICT UPDATE, but only if I'm right assuming the one row use-case is much more common than the zero or one rows and one or more rows use-cases. If all use-cases are equally important to support in a nice way, then the suggested syntax is brilliant, as it supports all of them. Bonus points for the extremely condensed syntax. 2. Substitute for EXECUTE with string manipulation using backticks `` for value/command substitution in SQL as an alternative to EXECUTE string +1 for being backwards compatible, but I have no strong opinion. 3. A way to tell pl/pggsql not to cache plans fro normal queries --- OR we could do it in SQL-ish way using like this: SELECT ... USING FRESH PLAN; +1 for clean syntax -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 9:37 GMT+02:00 Joel Jacobson j...@trustly.com: On Wed, Sep 3, 2014 at 11:19 PM, Hannu Krosing ha...@2ndquadrant.com wrote: SELECT[1] - select exactly one row, anything else raises error SELECT[0:1] - select zero or one rows, anything else raises error SELECT[1:] - select one or more rows plain SELECT is equivalent to SELECT[0:] same syntax could be used for enforcing sane affected row counts for INSERT and DELETE +1 for a new fresh creative idea! My mind was stuck in a looking for keywords state. The only suggestion I think is slightly better is the STRICT UPDATE, but only if I'm right assuming the one row use-case is much more common than the zero or one rows and one or more rows use-cases. If all use-cases are equally important to support in a nice way, then the suggested syntax is brilliant, as it supports all of them. Bonus points for the extremely condensed syntax. 2. Substitute for EXECUTE with string manipulation using backticks `` for value/command substitution in SQL as an alternative to EXECUTE string +1 for being backwards compatible, but I have no strong opinion. 3. A way to tell pl/pggsql not to cache plans fro normal queries --- OR we could do it in SQL-ish way using like this: SELECT ... USING FRESH PLAN; +1 for clean syntax we have totally different opinion what is good Regards Pavel
Re: [HACKERS] PL/pgSQL 1.2
On Thu, Sep 4, 2014 at 9:39 AM, Pavel Stehule pavel.steh...@gmail.com wrote: we have totally different opinion what is good Can you elaborate on that? Your ASSERT CHECK ROWCOUNT = 1; is lengthly, which is why I don't like it. Imagine if having to type my $var === 'foo'; instead of my $var = 'foo'; on every single line of could where you want to assign a variable, that would just be ridiculous. If you have a typical CRUD application and decide to do *all* data operations via PL functions, which is a design pattern advocated by many*, then you will end up with a lot of very simple short PL functions, to do things like update_worker_status(), set_notification_response(), etc, in which you always pass something which is a primary key in some table, and want to update exactly one row. Having to type 27 extra characters for every single line of code, instead of the suggested 3 extra characters, is a big difference, for anyone who designs a CRUD application which relies on the usage of PL functions. For me, it would be useful to understand if you are developing CRUD applications, or if your main usage for PL/pgSQL functions are other things? If the latter, then maybe that could explain why you don't feel strongly about simplifying and condensing the syntax for the most common use-case of them all. *) but there are probably equally who prefer to handle business logics outside the database -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] implement subject alternative names support for SSL connections
On 09/04/2014 10:33 AM, Alexey Klyukin wrote: On Wed, Sep 3, 2014 at 11:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: * It's ugly that the caller does the malloc and memcpy, and the certificate_name_entry_validate_match function then modifies its name argument. Move the malloc+memcpy inside the function. For the case of CN the caller has to do the malloc anyway, since X509_NAME_get_text_by_NID expects the already allocated buffer. This means that 'movable' malloc + memcpy occurs only once, and while it would still make sense to move it into the function, it would also mean we would do an unnecessary malloc for the case of CN. Hmm. Perhaps we should use X509_NAME_get_index_by_NID + X509_NAME_get_entry instead of X509_NAME_get_text_by_NID. You could then pass the ASN1_STRING object to the certificate_name_entry_validate_match() function, and have it do the ASN1_STRING_length() and ASN1_STRING_data() calls too. The tricky part is the error message if no match was found: initially, it only listed a single common name, but now tracking all DNS names just for the sake of the error message makes the code more bloated, so I'm wondering if simply stating that there was no match, as implemented in the attached patch, would be good enough? Hmm. It would still be nice to say something about the certificate that was received. How about: server certificate with common name %s does not match host name %s We cannot guarantee at this point that the common name is present in the certificate. And if it is not, which name should we pick instead? One way to solve this is to take the first non-NULL name, but it if there is no common name, but then the wording of the error message would depend on the availability of CN. Another is to show all available names, but I do not like collecting them just for the sake of displaying in the error message. And last one is to just show the error without mentioning names, that's what I've chosen to be the most consistent. I think we should: 1. Check if there's a common name, and if so, print that 2. Check if there is exactly one SAN, and if so, print that 3. Just print an error without mentioning names. There's a lot of value in printing the name if possible, so I'd really like to keep that. But I agree that printing all the names if there are several would get complicated and the error message could become very long. Yeah, the error message might need to be different for cases 1 and 2. Or maybe phrase it server certificate's name \%s\ does not match host name \%s\, which would be reasonable for both 1. and 2. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 9/4/14 2:10 AM, Hannu Krosing wrote: On 09/04/2014 12:17 AM, Marko Tiikkaja wrote: I'm not sure how much I like that syntax in cases like: WITH t AS ( -- multi-line query here ) SELECT[0:] foo, bar INTO _bat, _man FROM foo JOIN .. JOIN .. WHERE .. -- etc. It seems quite well hidden compared to a single keyword at the beginning of the query. What do you have in mind ? I'm just comparing it to the STRICT UPDATE ..; and ONE ROW UPDATE ..; syntaxes proposed earlier. Is your wiki page already available somewhere ? I'm working on getting it up ASAP; hopefully it will be today around the UTC noon. .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 10:06 GMT+02:00 Joel Jacobson j...@trustly.com: On Thu, Sep 4, 2014 at 9:39 AM, Pavel Stehule pavel.steh...@gmail.com wrote: we have totally different opinion what is good Can you elaborate on that? I would to elaborate on enhancing plpgsql - but my primary target is readability without necessity of special special statements, types. I am strong against to create some shortcuts for relative too special use case. Your ASSERT CHECK ROWCOUNT = 1; is lengthly, which is why I don't like it. Imagine if having to type my $var === 'foo'; instead of my $var = 'foo'; on every single line of could where you want to assign a variable, that would just be ridiculous. If you have a typical CRUD application and decide to do *all* data operations via PL functions, which is a design pattern advocated by many*, then you will end up with a lot of very simple short PL functions, to do things like update_worker_status(), set_notification_response(), etc, in which you always pass something which is a primary key in some table, and want to update exactly one row. Having to type 27 extra characters for every single line of code, instead of the suggested 3 extra characters, is a big difference, for anyone who designs a CRUD application which relies on the usage of PL functions. Is not better to design special PL for this usage? I understand to your motivation, but it is not acceptable for me in plpgsql. Ten years ago, we had to solve similar problem - and we designed metalanguage that was translated to plpgsql. For me, it would be useful to understand if you are developing CRUD applications, or if your main usage for PL/pgSQL functions are other things? I am strong in opinion so PLpgSQL is targeted primary for implementation business logic in server side. CRUD is only one from possible use cases - and without any special importance to others. If the latter, then maybe that could explain why you don't feel strongly about simplifying and condensing the syntax for the most common use-case of them all. I don't agree so what you propose, it is common use case. And I don't think so it can be used in synergy with current design *) but there are probably equally who prefer to handle business logics outside the database It is maybe main difference between me and you. Usually I don't write CRUD applications, and I am not sure if plpgsql is good for CRUD. Mainly I would not to optimize plpgsql primary for CRUD.
Re: [HACKERS] PL/pgSQL 1.2
On 9/4/14 10:42 AM, Pavel Stehule wrote: 2014-09-04 10:06 GMT+02:00 Joel Jacobson j...@trustly.com: *) but there are probably equally who prefer to handle business logics outside the database It is maybe main difference between me and you. Usually I don't write CRUD applications, and I am not sure if plpgsql is good for CRUD. Mainly I would not to optimize plpgsql primary for CRUD. I don't think providing syntax to support the CRUD-like use case would be optimizing it primarily for CRUD. Changing how UPDATE and DELETE work by default would be, but that's not being suggested here (anymore). .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On Thu, Sep 4, 2014 at 10:42 AM, Pavel Stehule pavel.steh...@gmail.com wrote: I am strong in opinion so PLpgSQL is targeted primary for implementation business logic in server side. CRUD is only one from possible use cases - and without any special importance to others. Just curious, what kind of business logic do you write, where one row is not more special to you than two rows or five rows? Think about for a second what PL functions are able to return. Compare, RETURNS RECORD vs RETURNS SETOF RECORD When you return from a function, you get exactly 1 row, unless you explicitly use the SETOF RECORD syntax, where 0...n rows are possible. To add to that, we have the STRICT keyword, which also recognize the fact 1 row is special. So, we already *have* special handling for the 1 row case in many areas. I cannot see how you can fail to agree it would be a good thing to make it simple also for UPDATE/DELETE/INSERT. On Thu, Sep 4, 2014 at 10:42 AM, Pavel Stehule pavel.steh...@gmail.com wrote: 2014-09-04 10:06 GMT+02:00 Joel Jacobson j...@trustly.com: On Thu, Sep 4, 2014 at 9:39 AM, Pavel Stehule pavel.steh...@gmail.com wrote: we have totally different opinion what is good Can you elaborate on that? I would to elaborate on enhancing plpgsql - but my primary target is readability without necessity of special special statements, types. I am strong against to create some shortcuts for relative too special use case. Your ASSERT CHECK ROWCOUNT = 1; is lengthly, which is why I don't like it. Imagine if having to type my $var === 'foo'; instead of my $var = 'foo'; on every single line of could where you want to assign a variable, that would just be ridiculous. If you have a typical CRUD application and decide to do *all* data operations via PL functions, which is a design pattern advocated by many*, then you will end up with a lot of very simple short PL functions, to do things like update_worker_status(), set_notification_response(), etc, in which you always pass something which is a primary key in some table, and want to update exactly one row. Having to type 27 extra characters for every single line of code, instead of the suggested 3 extra characters, is a big difference, for anyone who designs a CRUD application which relies on the usage of PL functions. Is not better to design special PL for this usage? I understand to your motivation, but it is not acceptable for me in plpgsql. Ten years ago, we had to solve similar problem - and we designed metalanguage that was translated to plpgsql. For me, it would be useful to understand if you are developing CRUD applications, or if your main usage for PL/pgSQL functions are other things? I am strong in opinion so PLpgSQL is targeted primary for implementation business logic in server side. CRUD is only one from possible use cases - and without any special importance to others. If the latter, then maybe that could explain why you don't feel strongly about simplifying and condensing the syntax for the most common use-case of them all. I don't agree so what you propose, it is common use case. And I don't think so it can be used in synergy with current design *) but there are probably equally who prefer to handle business logics outside the database It is maybe main difference between me and you. Usually I don't write CRUD applications, and I am not sure if plpgsql is good for CRUD. Mainly I would not to optimize plpgsql primary for CRUD. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 10:53 GMT+02:00 Marko Tiikkaja ma...@joh.to: On 9/4/14 10:42 AM, Pavel Stehule wrote: 2014-09-04 10:06 GMT+02:00 Joel Jacobson j...@trustly.com: *) but there are probably equally who prefer to handle business logics outside the database It is maybe main difference between me and you. Usually I don't write CRUD applications, and I am not sure if plpgsql is good for CRUD. Mainly I would not to optimize plpgsql primary for CRUD. I don't think providing syntax to support the CRUD-like use case would be optimizing it primarily for CRUD. Changing how UPDATE and DELETE work by default would be, but that's not being suggested here (anymore). I am strong in opinion so safe stored procedures should be verbose. It is in contradiction to Joel direction. I wrote a proposal, how to do more friendly but still enough verbose Pavel .marko
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 10:57 GMT+02:00 Joel Jacobson j...@trustly.com: On Thu, Sep 4, 2014 at 10:42 AM, Pavel Stehule pavel.steh...@gmail.com wrote: I am strong in opinion so PLpgSQL is targeted primary for implementation business logic in server side. CRUD is only one from possible use cases - and without any special importance to others. Just curious, what kind of business logic do you write, where one row is not more special to you than two rows or five rows? Think about for a second what PL functions are able to return. Compare, RETURNS RECORD vs RETURNS SETOF RECORD it is different semantic - returns composite or set of composites --- it is not row or rows Actually BL is usually processed oriented, so PL functions coverages changes in data, and for queries you use SELECT Returning SET from function is less often - and usually it is not in preferred patterns because you can very simple block a optimizer. When you return from a function, you get exactly 1 row, unless you explicitly use the SETOF RECORD syntax, where 0...n rows are possible. To add to that, we have the STRICT keyword, which also recognize the fact 1 row is special. So, we already *have* special handling for the 1 row case in many areas. I cannot see how you can fail to agree it would be a good thing to make it simple also for UPDATE/DELETE/INSERT. On Thu, Sep 4, 2014 at 10:42 AM, Pavel Stehule pavel.steh...@gmail.com wrote: 2014-09-04 10:06 GMT+02:00 Joel Jacobson j...@trustly.com: On Thu, Sep 4, 2014 at 9:39 AM, Pavel Stehule pavel.steh...@gmail.com wrote: we have totally different opinion what is good Can you elaborate on that? I would to elaborate on enhancing plpgsql - but my primary target is readability without necessity of special special statements, types. I am strong against to create some shortcuts for relative too special use case. Your ASSERT CHECK ROWCOUNT = 1; is lengthly, which is why I don't like it. Imagine if having to type my $var === 'foo'; instead of my $var = 'foo'; on every single line of could where you want to assign a variable, that would just be ridiculous. If you have a typical CRUD application and decide to do *all* data operations via PL functions, which is a design pattern advocated by many*, then you will end up with a lot of very simple short PL functions, to do things like update_worker_status(), set_notification_response(), etc, in which you always pass something which is a primary key in some table, and want to update exactly one row. Having to type 27 extra characters for every single line of code, instead of the suggested 3 extra characters, is a big difference, for anyone who designs a CRUD application which relies on the usage of PL functions. Is not better to design special PL for this usage? I understand to your motivation, but it is not acceptable for me in plpgsql. Ten years ago, we had to solve similar problem - and we designed metalanguage that was translated to plpgsql. For me, it would be useful to understand if you are developing CRUD applications, or if your main usage for PL/pgSQL functions are other things? I am strong in opinion so PLpgSQL is targeted primary for implementation business logic in server side. CRUD is only one from possible use cases - and without any special importance to others. If the latter, then maybe that could explain why you don't feel strongly about simplifying and condensing the syntax for the most common use-case of them all. I don't agree so what you propose, it is common use case. And I don't think so it can be used in synergy with current design *) but there are probably equally who prefer to handle business logics outside the database It is maybe main difference between me and you. Usually I don't write CRUD applications, and I am not sure if plpgsql is good for CRUD. Mainly I would not to optimize plpgsql primary for CRUD.
Re: [HACKERS] PL/pgSQL 1.2
On Thu, Sep 4, 2014 at 11:07 AM, Pavel Stehule pavel.steh...@gmail.com wrote: it is different semantic - returns composite or set of composites --- it is not row or rows The point was, RETURNS returns 1 while RETURNS SETOF returns 0 .. n. Actually BL is usually processed oriented, so PL functions coverages changes in data, and for queries you use SELECT OK, so you SELECT directly from tables? And in the PLs you change a lot of rows in the same txn? Returning SET from function is less often - and usually it is not in preferred patterns because you can very simple block a optimizer. Not if you do all access, also SELECT via PLs, then you might want to returns lists of things based on some input. But that's a different topic. What I wanted to examplify is the fact we *already* have a lot of syntax which handles the 1 row case in a special way. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 11:22 GMT+02:00 Joel Jacobson j...@trustly.com: On Thu, Sep 4, 2014 at 11:07 AM, Pavel Stehule pavel.steh...@gmail.com wrote: it is different semantic - returns composite or set of composites --- it is not row or rows The point was, RETURNS returns 1 while RETURNS SETOF returns 0 .. n. no RETURNS return VALUE (it is not a row) .. and in combination with SELECT - value will be a row. RETURNS SETOF returns rows Set Returning Functions is interesting concept, but with some issues too - when you use it in target part instead FROM part. Actually BL is usually processed oriented, so PL functions coverages changes in data, and for queries you use SELECT OK, so you SELECT directly from tables? And in the PLs you change a lot of rows in the same txn? depends - if you be more strict, then direct access to tables is prohibited and only access to views is enables. There is simple rules: reading - selects to tables or views, writing PL -- data are changes inside some process and any process should be covered by one or more PL hard to say, how often you are change only one row maybe 50/50% -- when you need fix some stored data. Insert or delete will be different Returning SET from function is less often - and usually it is not in preferred patterns because you can very simple block a optimizer. Not if you do all access, also SELECT via PLs, then you might want to returns lists of things based on some input. But that's a different topic. What I wanted to examplify is the fact we *already* have a lot of syntax which handles the 1 row case in a special way. I know what is CRUD, and I looked to your functions from github and I understand to your motivation. Just have different opinion about benefits of some your proposal, because I use plpgsql little bit different. Using PL only for CRUD is stopping in 1/10 way :). Pavel
Re: [HACKERS] Scaling shared buffer eviction
On Wed, Sep 3, 2014 at 8:03 PM, Robert Haas robertmh...@gmail.com wrote: On Wed, Sep 3, 2014 at 7:27 AM, Amit Kapila amit.kapil...@gmail.com wrote: +while (tmp_num_to_free 0) I am not sure it's a good idea for this value to be fixed at loop start and then just decremented. It is based on the idea what bgwriter does for num_to_scan and calling it once has advantage that we need to take freelist_lck just once. Right, we shouldn't call it every loop iteration. However, consider this scenario: there are no remaining buffers on the list and the high watermark is 2000. We add 2000 buffers to the list. But by the time we get done, other backends have already done 500 more allocations, so now there are only 1500 buffers on the list. If this should occur, we should add an additional 500 buffers to the list before we consider sleeping. We want bgreclaimer to be able to run continuously if the demand for buffers is high enough. Its not difficult to handle such cases, but it can have downside also for the cases where demand from backends is not high. Consider in above case if instead of 500 more allocations, it just does 5 more allocations, then bgreclaimer will again have to go through the list and move 5 buffers and same can happen again by the time it moves 5 buffers. Another point to keep in mind here is that in this loop we are reducing the usage_count of buffers as well incase we don't find buffer with usage_count=0. OTOH if we let bgreclaimer to go for sleep after it moves initially identified buffers, then the backend which first finds that the buffers in freelist falls below low water mark can wake bgreclaimer. In freelist.c, it seems like a poor idea to have two spinlocks as consecutive structure members; they'll be in the same cache line, leading to false sharing. If we merge them into a single spinlock, does that hurt performance? I have kept them separate so that backends searching for a buffer in freelist doesn't contend with bgreclaimer (while doing clock sweep) or clock sweep being done by other backends. I think it will be bit tricky to devise a test where this can hurt, however it doesn't seem too bad to have two separate locks in this case. It's not. But if they are in the same cache line, they will behave almost like one lock, because the CPU will lock the entire cache line for each atomic op. See Tom's comments upthread. I think to avoid having them in same cache line, we might need to add some padding (at least 72 bytes) as the structure size including both the spin locks is 56 bytes on PPC64 m/c and cache line size is 128 bytes. I have taken performance data as well by keeping them further apart as suggested by you upthread and by introducing padding, but the difference in performance is less than 1.5% (on 64 and 128 client count) which also might be due to variation of data across runs. So now to proceed we have below options: a. use two spinlocks as in patch, but keep them as far apart as possible. This might not have an advantage as compare to what is used currently in patch, but in future we can adding padding to take the advantage if possible (currently on PPC64, it doesn't show any noticeable advantage, however on some other m/c, it might show the advantage). b. use only one spinlock, this can have disadvantage in certain cases as mentioned upthread, however those might not be usual cases, so for now we can consider them as lower priority and can choose this option. Another point in this regard is that I have to make use of volatile pointer to prevent code rearrangement in this case. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com
Re: [HACKERS] PL/pgSQL 1.2
Everyone, I've started a wiki page with the list of the things I could think of at this very moment. I probably got the most annoying ones in there, but I also might have forgotten about some things. I invite discussion of every suggestion on -HACKERS. https://wiki.postgresql.org/wiki/Improving_PL/PgSQL_(September_2014) I'm sure other people's lists would look different; perhaps they should be added to the same page? Should we divide it based on who's suggesting the change to keep a better track? Anyway, you can start shooting now that we have at least one list of concrete proposals. .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 13:37 GMT+02:00 Marko Tiikkaja ma...@joh.to: Everyone, I've started a wiki page with the list of the things I could think of at this very moment. I probably got the most annoying ones in there, but I also might have forgotten about some things. I invite discussion of every suggestion on -HACKERS. https://wiki.postgresql.org/wiki/Improving_PL/PgSQL_(September_2014) I'm sure other people's lists would look different; perhaps they should be added to the same page? Should we divide it based on who's suggesting the change to keep a better track? Anyway, you can start shooting now that we have at least one list of concrete proposals. where I can wrote comments? Usually I wrote them but I have to repeat it. I am sorry, It is difficult - your usage of plpgsql is sometimes less, some times more against best practices :( PL functions should not be only envelope to SQL statement Pavel .marko
Re: [HACKERS] PL/pgSQL 1.2
On 9/4/14 1:47 PM, Pavel Stehule wrote: 2014-09-04 13:37 GMT+02:00 Marko Tiikkaja ma...@joh.to: I've started a wiki page with the list of the things I could think of at this very moment. I probably got the most annoying ones in there, but I also might have forgotten about some things. I invite discussion of every suggestion on -HACKERS. where I can wrote comments? I guess comments could be added as a subsection if you feel -HACKERS doesn't work. I am sorry, It is difficult - your usage of plpgsql is sometimes less, some times more against best practices :( Best practices according to whom? And which parts, exactly? There's quite a lot of stuff in there, both explicitly stated and implicitly assumed. PL functions should not be only envelope to SQL statement I disagree, to some extent. Our external applications interface with the database only by calling functions (which are often written in PL/PgSQL). If that function has no more work to do than to run a single query, then yes, the function will just serve as an envelope to a single query. But that also allows the function to be changed in the future without having to change the application. Similarly to how you would expose an API when communicating with others instead of giving them a postgres user account and saying update these tables and after a month saying oh, you need to remember to INSERT into this table as well or we won't have logs of what you did. .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Scaling shared buffer eviction
On Wed, Sep 3, 2014 at 9:45 AM, Amit Kapila amit.kapil...@gmail.com wrote: Performance Data: --- Configuration and Db Details IBM POWER-7 16 cores, 64 hardware threads RAM = 64GB Database Locale =C checkpoint_segments=256 checkpoint_timeout=15min scale factor = 3000 Client Count = number of concurrent sessions and threads (ex. -c 8 -j 8) Duration of each individual run = 5mins All the data is in tps and taken using pgbench read-only load Common configuration remains same as above. Shared_Buffers = 500MB Client Count/Patch_Ver 8 16 32 64 128 HEAD 56248 100112 121341 81128 56552 Patch 59389 112483 157034 185740 166725 .. Observations - 1. Performance improvement is upto 2~3 times for higher client counts (64, 128). 2. For lower client count (8), we can see 2~5 % performance improvement. 3. Overall, this improves the read scalability. 4. For lower number of shared buffers, we see that there is a minor dip in tps even after patch (it might be that we can improve it by tuning higher water mark for the number of buffers on freelist, I will try this by varying high water mark). I have taken performance data by varying high and low mater marks for lower value of shared buffers which is as below: Shared_buffers = 500MB Scale_factor = 3000 HM - High water mark, 0.5 means 0.5% of total shared buffers LM - Low water mark, 20 means 20% of HM. Client Count/Patch_Ver (Data in tps) 128 HM=0.5;LM=20 166725 HM=1;LM=20 166556 HM=2;LM=30 166463 HM=5;LM=30 166107 HM=10;LM=30 167231 Observation a. There is hardly any difference by varying High and Low water marks as compared to default values currently used in patch. b. I think this minor dip as compare to 64 client count is because one this m/c has 64 hardware threads due which scaling beyond 64 client count is difficult and second at relatively lower buffer count (500MB), there is still minor contention around Buf Mapping locks. In general, I think with patch the scaling is much better (2 times) than HEAD, even when shared buffers are less and client count is high, so this is not an issue. With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 13:54 GMT+02:00 Marko Tiikkaja ma...@joh.to: On 9/4/14 1:47 PM, Pavel Stehule wrote: 2014-09-04 13:37 GMT+02:00 Marko Tiikkaja ma...@joh.to: I've started a wiki page with the list of the things I could think of at this very moment. I probably got the most annoying ones in there, but I also might have forgotten about some things. I invite discussion of every suggestion on -HACKERS. where I can wrote comments? I guess comments could be added as a subsection if you feel -HACKERS doesn't work. ok I am sorry, It is difficult - your usage of plpgsql is sometimes less, some times more against best practices :( Best practices according to whom? And which parts, exactly? There's quite a lot of stuff in there, both explicitly stated and implicitly assumed. PL functions should not be only envelope to SQL statement I disagree, to some extent. Our external applications interface with the database only by calling functions (which are often written in PL/PgSQL). If that function has no more work to do than to run a single query, then yes, the function will just serve as an envelope to a single query. But that also allows the function to be changed in the future without having to change the application. Similarly to how you would expose an API when communicating with others instead of giving them a postgres user account and saying update these tables and after a month saying oh, you need to remember to INSERT into this table as well or we won't have logs of what you did. for example best practices for PL/SQL by Steven Feuerstein We can talk about it - it subjective and I know so there are not only one style. For example, you can use a ALIAS to parameters if you have a problem with parameter variables postgres=# create or replace function foo(out a int) as $$ declare _x alias for a; begin _x := 10; end $$ language plpgsql; CREATE FUNCTION postgres=# select foo(); foo - 10 (1 row) or if you can be more secure use a block label postgres=# create or replace function foo(out a int) as $$ main declare _x alias for a; begin main._x := 10; end $$ language plpgsql; CREATE FUNCTION postgres=# select foo(); foo - 10 (1 row) The language has these possibilities. Why to add new redundant? Pavel .marko
Re: [HACKERS] PL/pgSQL 1.2
On Thu, Sep 4, 2014 at 4:06 AM, Joel Jacobson j...@trustly.com wrote: Your ASSERT CHECK ROWCOUNT = 1; is lengthly, which is why I don't like it. Imagine if having to type my $var === 'foo'; instead of my $var = 'foo'; on every single line of could where you want to assign a variable, that would just be ridiculous. This is really the core of the problem. PL/pgsql is an incredibly verbose language, and things that ought to be expressable in a small number of characters often take a large number of characters. The reason this problem is hard to solve is that PL/pgsql is based on SQL, and SQL is inherently pretty verbose. When we try to extend PL/pgsql, we can either pick syntax that looks like the existing language (which sucks because it's verbose) or we can pick syntax that is compact (which sucks because it looks nothing like the rest of the language). This is a deep and fundamental conflict that is not going away. So I'm with the crowd of people who says there's really nothing that can be done to improve PL/pgsql much. Yeah, we could make certain cases a little better at the expense of certain other cases (which is how this thread got started), but it's not really clear that we'd end up ahead at all (since a lot of people objected to the proposed changes) and if we did we wouldn't end up very far ahead (since the original proposal consisted of three minor items which are not going to radically transform anyone's experience). Even Oracle, who has a vastly larger RD budget than the PostgreSQL community, frankly hasn't done all that much with it. They have some nice conveniences which we lack, but it's still a clunky language. So, I think the right solution here is to work on improving the user experience people have with other procedural languages. Perl, Python, and Javascript are all notable for being terse, sometimes to excess. I remember trying to use PL/perl many years ago and giving up on it because of various problems, like not being able to get require to work, and not being able to create helper functions that could be called directly from Perl without going back through the SQL layer. But some of those kinds of things may have been fixed between then and now, and whichever ones haven't probably can be if people are willing to put in some work. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Scaling shared buffer eviction
On Thu, Sep 4, 2014 at 7:25 AM, Amit Kapila amit.kapil...@gmail.com wrote: Its not difficult to handle such cases, but it can have downside also for the cases where demand from backends is not high. Consider in above case if instead of 500 more allocations, it just does 5 more allocations, then bgreclaimer will again have to go through the list and move 5 buffers and same can happen again by the time it moves 5 buffers. That's exactly the scenario in which we *want* the looping behavior. If that's happening, then it means it's taking us exactly as long to find 5 buffers as it takes the rest of the system to use 5 buffers. We need to run continuously to keep up. It's not. But if they are in the same cache line, they will behave almost like one lock, because the CPU will lock the entire cache line for each atomic op. See Tom's comments upthread. I think to avoid having them in same cache line, we might need to add some padding (at least 72 bytes) as the structure size including both the spin locks is 56 bytes on PPC64 m/c and cache line size is 128 bytes. I have taken performance data as well by keeping them further apart as suggested by you upthread and by introducing padding, but the difference in performance is less than 1.5% (on 64 and 128 client count) which also might be due to variation of data across runs. So now to proceed we have below options: a. use two spinlocks as in patch, but keep them as far apart as possible. This might not have an advantage as compare to what is used currently in patch, but in future we can adding padding to take the advantage if possible (currently on PPC64, it doesn't show any noticeable advantage, however on some other m/c, it might show the advantage). b. use only one spinlock, this can have disadvantage in certain cases as mentioned upthread, however those might not be usual cases, so for now we can consider them as lower priority and can choose this option. I guess I don't care that much. I only mentioned it because Tom brought it up; I don't really see a big problem with the way you're doing it. Another point in this regard is that I have to make use of volatile pointer to prevent code rearrangement in this case. Yep. Or we need to get off our duff and fix it so that's not necessary. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Spinlocks and compiler/memory barriers
On Tue, Aug 5, 2014 at 11:55 AM, Robert Haas robertmh...@gmail.com wrote: On Sun, Jul 6, 2014 at 3:12 PM, Andres Freund and...@2ndquadrant.com wrote: If you want to do that, it's fine with me. What I would do is: - Back-patch the addition of the sparcv8+ stuff all the way. If anyone's running anything older, let them complain... - Remove the special case for MIPS without gcc intrinsics only in master, leaving the back-branches broken. If anyone cares, let them complain... - Nothing else. I've gone ahead and done the second of these things. Thanks. Andres, do you want to go take a stab at fixing the SPARC stuff? Will do, will probably take me till thursday to come up with the brain cycles. Ping? This has been pending for almost two months now and, at your request, my patch to make spinlocks act as compiler barriers is waiting behind it. Can we please get this moving again soon, or can I commit that patch and you can fix this when you get around to it? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Spinlocks and compiler/memory barriers
On September 4, 2014 2:18:37 PM CEST, Robert Haas robertmh...@gmail.com wrote: On Tue, Aug 5, 2014 at 11:55 AM, Robert Haas robertmh...@gmail.com wrote: On Sun, Jul 6, 2014 at 3:12 PM, Andres Freund and...@2ndquadrant.com wrote: If you want to do that, it's fine with me. What I would do is: - Back-patch the addition of the sparcv8+ stuff all the way. If anyone's running anything older, let them complain... - Remove the special case for MIPS without gcc intrinsics only in master, leaving the back-branches broken. If anyone cares, let them complain... - Nothing else. I've gone ahead and done the second of these things. Thanks. Andres, do you want to go take a stab at fixing the SPARC stuff? Will do, will probably take me till thursday to come up with the brain cycles. Ping? This has been pending for almost two months now and, at your request, my patch to make spinlocks act as compiler barriers is waiting behind it. Can we please get this moving again soon, or can I commit that patch and you can fix this when you get around to it? Yes. I plan to push the patch this weekend. Sorry for the delay. Andres -- Please excuse brevity and formatting - I am writing this on my mobile phone. Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 9/4/14 2:04 PM, Pavel Stehule wrote: for example best practices for PL/SQL by Steven Feuerstein I'll spend some time with that book to have a better idea on where you're coming from. Also, *please* don't try and extrapolate what I do based on the code examples on the wiki page; they're all crap just to point out the issues. We can talk about it - it subjective and I know so there are not only one style. The language has these possibilities. Why to add new redundant? Adding a new alias for every single OUT parameter for every single function seems like a waste of time. It also doesn't improve readability in the way that OUT.foo := 1; does (though I guess you could add an out_ prefix to all of them). .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Join push-down support for foreign tables
On Wed, Sep 3, 2014 at 5:16 AM, Shigeru Hanada shigeru.han...@gmail.com wrote: In 2011 I proposed join push-down support for foreign tables, which would improve performance of queries which contain join between foreign tables in one server, but it has not finished before time-up. This performance improvement would widen application range of foreign tables, so I'd like to tackle the work again. The descriptions below are based on previous discussions and additional studies. Hanada-san, it is fantastic to see you working on this again. I think your proposal sounds promising and it is along the lines of what I have considered in the past. (1) Separate cost estimation phases? For existing join paths, planner estimates their costs in two phaeses. In the first phase initial_cost_foo(), here foo is one of nestloop/mergejoin/hashjoin, produces lower-bound estimates for elimination. The second phase is done for only promising paths which passed add_path_precheck(), by final_cost_foo() for cost and result size. I'm not sure that we need to follow this manner, since FDWs would be able to estimate final cost/size with their own methods. The main problem I see here is that accurate costing may require a round-trip to the remote server. If there is only one path that is probably OK; the cost of asking the question will usually be more than paid for by hearing that the pushed-down join clobbers the other possible methods of executing the query. But if there are many paths, for example because there are multiple sets of useful pathkeys, it might start to get a bit expensive. Probably both the initial cost and final cost calculations should be delegated to the FDW, but maybe within postgres_fdw, the initial cost should do only the work that can be done without contacting the remote server; then, let the final cost step do that if appropriate. But I'm not entirely sure what is best here. (2) How to reflect cost of transfer Cost of transfer is dominant in foreign table operations, including foreign scans. It would be nice to have some mechanism to reflect actual time of transfer to the cost estimation. An idea is to have a FDW option which represents cost factor of transfer, say transfer_cost. That would be reasonable. I assume users would normally wish to specify this per-server, and the default should be something reasonable for a LAN. (4) criteria for push-down It is assumed that FDWs can push joins down to remote when all foreign tables are in same server. IMO a SERVER objects represents a logical data source. For instance database for postgres_fdw and other connection-based FDWs, and disk volumes (or directory?) for file_fdw. Is this reasonable assumption? I think it's probably good to give an FDW the option of producing a ForeignJoinPath for any join against a ForeignPath *or ForeignJoinPath* for the same FDW. It's perhaps unlikely that an FDW can perform a join efficiently between two data sources with different server definitions, but why not give it the option? It should be pretty fast for the FDW to realize, oh, the server OIDs don't match - and at that point it can exit without doing anything further if that seems desirable. And there might be some kinds of data sources where cross-server joins actually can be executed quickly (e.g. when the underlying data is just in two files in different places on the local machine). (5) Terminology I used foreign join as a process which joins foreign tables on *remote* side, but is this enough intuitive? Another idea is using remote join, is this more appropriate for this kind of process? I hesitate to use remote join because it implies client-server FDWs, but foreign join is not limited to such FDWs, e.g. file_fdw can have extra file which is already joined files accessed via foreign tables. Foreign join is perfect. As I alluded to above, it's pretty important to make sure that this works with large join trees; that is, if I join four foreign tables, I don't want it to push down a join between two of the tables and a join between the other two tables and then join the results of those joins locally. Instead, I want to push the entire join tree to the foreign server and execute the whole thing there. Some care may be needed in designing the hooks to make sure this works as desired. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 4 sep 2014, at 11:42, Pavel Stehule pavel.steh...@gmail.com wrote: 2014-09-04 11:22 GMT+02:00 Joel Jacobson j...@trustly.com: The point was, RETURNS returns 1 while RETURNS SETOF returns 0 .. n. no RETURNS return VALUE (it is not a row) .. and in combination with SELECT - value will be a row. RETURNS SETOF returns rows I intentionally excluded the data type of what is returned. 1 VALUE vs 0...n VALUES Do you still fail to see the point 1 VALUE is special in the context of what a function returns?
Re: [HACKERS] xslt_process deprecated?
On Wed, Sep 3, 2014 at 6:23 AM, Mark ma...@alienmuppet.co.uk wrote: I'd like to use the xslt_process function but it is in part of the documentation that is deprecated. I don't want to use something that is going to disappear and if there is a better alternative I'd like to use it, however I cannot find an equivalent in the documentation. I could well be looking in the wrong place, apologies if I've just been too blind to see it. Somebody may eventually come up with a better alternative, but I don't think anyone has as of yet. http://www.postgresql.org/message-id/201102182259.p1imxcf11...@momjian.us -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 14:37 GMT+02:00 Joel Jacobson j...@trustly.com: On 4 sep 2014, at 11:42, Pavel Stehule pavel.steh...@gmail.com wrote: 2014-09-04 11:22 GMT+02:00 Joel Jacobson j...@trustly.com: The point was, RETURNS returns 1 while RETURNS SETOF returns 0 .. n. no RETURNS return VALUE (it is not a row) .. and in combination with SELECT - value will be a row. RETURNS SETOF returns rows I intentionally excluded the data type of what is returned. 1 VALUE vs 0...n VALUES Do you still fail to see the point 1 VALUE is special in the context of what a function returns? sorry, I don't understand .. for me SRF functions are absolutly different monsters than scalar, array or composite function - so its impossible to compare it. Pavel
Re: [HACKERS] Escaping from blocked send() reprised.
On Tue, Sep 2, 2014 at 3:01 PM, Andres Freund and...@2ndquadrant.com wrote: I'm slightly worried about the added overhead due to the latch code. In my implementation I only use latches after a nonblocking read, but still. Every WaitLatchOrSocket() does a drainSelfPipe(). I wonder if that can be made problematic. I think that's not the word you're looking for. Or if it is, then - it's already problematic. At some point I hacked up a very crude prototype that made LWLocks use latches to sleep instead of semaphores. It was slow. AIUI, the only reason why we need the self-pipe thing is because on some platforms signals don't interrupt system calls. But my impression was that those platforms were somewhat obscure. Could we have a separate latch implementation for platforms where we know that system calls will get interrupted by signals? Alternatively, should we consider reimplementing latches using semaphores? I assume having the signal handler up the semaphore would allow the attempt to down the semaphore to succeed on return from the handler, so it would accomplish the same thing as the self-pipe trick. Basically, it doesn't feel like a good thing that we've got two sets of primitives for making a backend wait that (1) don't really know about each other and (2) use different operating system primitives. Presumably one of the two systems is better; let's figure out which one it is, use that one all the time, and get rid of the other one. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Escaping from blocked send() reprised.
On 09/04/2014 03:49 PM, Robert Haas wrote: On Tue, Sep 2, 2014 at 3:01 PM, Andres Freund and...@2ndquadrant.com wrote: I'm slightly worried about the added overhead due to the latch code. In my implementation I only use latches after a nonblocking read, but still. Every WaitLatchOrSocket() does a drainSelfPipe(). I wonder if that can be made problematic. I think that's not the word you're looking for. Or if it is, then - it's already problematic. At some point I hacked up a very crude prototype that made LWLocks use latches to sleep instead of semaphores. It was slow. Hmm. Perhaps we should call drainSelfPipe() only after poll/select returns saying that there is something in the self-pipe. That would be a win assuming it's more common for the self-pipe to be empty. AIUI, the only reason why we need the self-pipe thing is because on some platforms signals don't interrupt system calls. That's not the only reason. It also eliminates the race condition that someone might set the latch after we've checked that it's not set, but before calling poll/select. The same reason that ppoll and pselect exist. But my impression was that those platforms were somewhat obscure. Could we have a separate latch implementation for platforms where we know that system calls will get interrupted by signals? ... and have ppoll or pselect. Yeah, seems reasonable, assuming that ppoll/pselect is faster. Alternatively, should we consider reimplementing latches using semaphores? I assume having the signal handler up the semaphore would allow the attempt to down the semaphore to succeed on return from the handler, so it would accomplish the same thing as the self-pipe trick. I don't think there's a function to wait for a file descriptor or semaphore at the same time. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] Re: [HACKERS] RE: 答复: [HACKERS] why after increase the hash table partitions, TPMC decrease
On Tue, Sep 2, 2014 at 11:02 PM, Xiaoyulei xiaoyu...@huawei.com wrote: benchmarSQL has about half reads. So I think it should be effective. I don't think BufFreelistLock take much time, it just get a buffer from list. It should be very fast. You're wrong. That list is usually empty right now; so it does a linear scan of the buffer pool looking for a good eviction candidate. The test server has 2 CPUs and 12 cores in each CPU. 24 processor totally. CPU Idle time is over 50%. IO only 10%(data is in SSD) I perf one process of pg. The hot spot is hash search. Attachment is perf data file. I think you need to pass -g to perf so that you get a call-graph profile. Then you should be able to expand the entry for hash_search_with_hash_value() and see what's calling it. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
On 09/01/2014 04:04 AM, Joel Jacobson wrote: + Make UPDATE/INSERT/DELETE throw error if they didnt' modify exactly 1 row, as that's the most common use-case, and provide alternative syntax to modify multiple or zero rows. What? No. The whole point of SQL is that it's set-based and can modify multiple rows at once. Hobbling it specifically for functions seems fundamentally flawed. Especially for what we purport to be a core PostgreSQL language. + Change all warnings into errors I... what? I could see coming up with a better exception handling mechanism for escalating messages. But you're talking about taking a core element of PostgreSQL (warnings) and simply ripping them out so plpgsql2 loses even that small functionality. I'm sure you've put a lot of thought into this, but you're not the only person using plpgsql or any, however ambitious, potential replacement. -- Shaun Thomas OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 stho...@optionshouse.com __ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 09/04/2014 01:14 AM, Pavel Stehule wrote: 2014-09-03 23:19 GMT+02:00 Hannu Krosing ha...@2ndquadrant.com A more SQL-ish way of doing the same could probably be called COMMAND CONSTRAINTS and look something like this SELECT ... CHECK (ROWCOUNT BETWEEN 0 AND 1); It is very near to my proposed ASSERT Only if the ASSERT syntax would become part of the original statement, it is supposed to check. In Hannu's command constraint example above, the statement that causes the error, and thus will be logged and become identified by the error message, is the actual SELECT (or other DML statement). I think I like the COMMAND CONSTRAINT the best so far. Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] missing tab-completion for relation options
On Thu, Sep 4, 2014 at 1:53 PM, Fujii Masao masao.fu...@gmail.com wrote: Attached patch adds the missing tab-completion for the relation options like autovacuum_multixact_freeze_max_age. That's a nice catch. Multixact parameters are present since 9.3. user_catalog_table since 9.4. Regards, -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 15:24 GMT+02:00 Jan Wieck j...@wi3ck.info: On 09/04/2014 01:14 AM, Pavel Stehule wrote: 2014-09-03 23:19 GMT+02:00 Hannu Krosing ha...@2ndquadrant.com A more SQL-ish way of doing the same could probably be called COMMAND CONSTRAINTS and look something like this SELECT ... CHECK (ROWCOUNT BETWEEN 0 AND 1); It is very near to my proposed ASSERT Only if the ASSERT syntax would become part of the original statement, it is supposed to check. In Hannu's command constraint example above, the statement that causes the error, and thus will be logged and become identified by the error message, is the actual SELECT (or other DML statement). this is valid argument. On second hand, I proposed a ASSERT that was not based on expressions only. There is not a technical issue to write assert with knowledge of related statement. I think I like the COMMAND CONSTRAINT the best so far. I not, because when it will not be part of SQL, than parser in plpgsql will be more complex. You have to inject SELECT, UPDATE, INSERT, DELETE Pavel Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info
Re: [HACKERS] Escaping from blocked send() reprised.
On Thu, Sep 4, 2014 at 9:05 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: Hmm. Perhaps we should call drainSelfPipe() only after poll/select returns saying that there is something in the self-pipe. That would be a win assuming it's more common for the self-pipe to be empty. Couldn't hurt. But my impression was that those platforms were somewhat obscure. Could we have a separate latch implementation for platforms where we know that system calls will get interrupted by signals? ... and have ppoll or pselect. Yeah, seems reasonable, assuming that ppoll/pselect is faster. Hrm. So we'd have to block SIGUSR1, check the flag, then use pselect() to temporarily unblock SIGUSR1 and wait, then on return again unblock SIGUSR1? Doesn't seem very appealing. I think changing the signal mask is fast on Linux, but quite slow on at least some other UNIX-like platforms. And I've heard that pselect() isn't always truly atomic, so we might run into platform-specific bugs, too. I wonder if there's a better way e.g. using memory barriers. WaitLatch: check is_set. if yes then done. otherwise, set signal_me. memory barrier. recheck is_set. if not set then wait using poll/select. memory barrier. clear signal_me. SetLatch: check is_set. if yes then done. otherwise, set is_set. memory barrier. check signal_me. if set, then send SIGUSR1. Alternatively, should we consider reimplementing latches using semaphores? I assume having the signal handler up the semaphore would allow the attempt to down the semaphore to succeed on return from the handler, so it would accomplish the same thing as the self-pipe trick. I don't think there's a function to wait for a file descriptor or semaphore at the same time. Oh, good point. So that's out, then. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 09/04/2014 09:31 AM, Pavel Stehule wrote: 2014-09-04 15:24 GMT+02:00 Jan Wieck j...@wi3ck.info I think I like the COMMAND CONSTRAINT the best so far. I not, because when it will not be part of SQL, than parser in plpgsql will be more complex. You have to inject SELECT, UPDATE, INSERT, DELETE Making the COMMAND CONSTRAINT part of the core SQL parser was how I understood Hannu's idea. It would be horrible to tuck that feature away inside of a PL, rather than making it available to all PLs as well as applications, that use SQL directly (I think there still are two or three applications that do). Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 15:38 GMT+02:00 Jan Wieck j...@wi3ck.info: On 09/04/2014 09:31 AM, Pavel Stehule wrote: 2014-09-04 15:24 GMT+02:00 Jan Wieck j...@wi3ck.info I think I like the COMMAND CONSTRAINT the best so far. I not, because when it will not be part of SQL, than parser in plpgsql will be more complex. You have to inject SELECT, UPDATE, INSERT, DELETE Making the COMMAND CONSTRAINT part of the core SQL parser was how I understood Hannu's idea. It would be horrible to tuck that feature away inside of a PL, rather than making it available to all PLs as well as applications, that use SQL directly (I think there still are two or three applications that do). So I am happy so we have agreement, so implementation on PL level can be terrible. Pavel Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info
Re: [HACKERS] psql \watch versus \timing
On Thu, Sep 4, 2014 at 1:44 PM, Fujii Masao masao.fu...@gmail.com wrote: On Thu, Aug 28, 2014 at 8:46 PM, Fujii Masao masao.fu...@gmail.com wrote: Good catch. So I will remove start_xact code later. Attached patch removes start_xact from PSQLexec. Nothing negative to say here :) Patch simply removes the second argument of PSQLexec that was set to the same value everywhere, aka false as noticed by Heikki. Comments and code blocks related to this parameter are removed, and the code compiles, passing check-world as well (just kicked the tests in case). Regards, -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Escaping from blocked send() reprised.
On 09/04/2014 04:37 PM, Robert Haas wrote: Hrm. So we'd have to block SIGUSR1, check the flag, then use pselect() to temporarily unblock SIGUSR1 and wait, then on return again unblock SIGUSR1? Doesn't seem very appealing. I think changing the signal mask is fast on Linux, but quite slow on at least some other UNIX-like platforms. And I've heard that pselect() isn't always truly atomic, so we might run into platform-specific bugs, too. I wonder if there's a better way e.g. using memory barriers. WaitLatch: check is_set. if yes then done. otherwise, set signal_me. memory barrier. recheck is_set. if not set then wait using poll/select. memory barrier. clear signal_me. SetLatch: check is_set. if yes then done. otherwise, set is_set. memory barrier. check signal_me. if set, then send SIGUSR1. Doesn't work. No matter what you do, the process running WaitLatch might receive the signal immediately before it calls poll/select. The signal handler will run, and the poll/select call will then go to sleep. There is no way to do this without support from the kernel, that is why ppoll/pselect exist. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Patch for psql History Display on MacOSX
On Wed, Sep 3, 2014 at 12:35 AM, Noah Misch n...@leadboat.com wrote: On Tue, Sep 02, 2014 at 01:56:34AM -0400, Tom Lane wrote: Noah Misch n...@leadboat.com writes: On Mon, Sep 01, 2014 at 10:22:57PM -0400, Tom Lane wrote: Also, as best I can tell, .psql_history files from older libedit versions are not forward-compatible to current libedit versions because of the failure of the decode_history() loop to reach all lines of the file when using current libedit. That is also a back-patchable bug fix IMO. (Closer investigation suggests this is a bug or definitional change in libedit's history_set_pos, not so much in next_history vs previous_history. But whatever it is, it behooves us to work around it.) I haven't studied this part of the topic other than to read what you have written. All other things being equal, I agree. If fixing this will make psql-9.3.6 w/ libedit-20141001 write history files that confuse psql-9.3.5 w/ libedit-20141001, that changes the calculus. Will it? I'm not sure exactly when things changed, but I have verified that the existing loops in decode/encode_history visit all lines of the history when using OS X Tiger's libedit library. On OS X Mavericks, the loops visit only the oldest history entry, as Stepan reported. This means that there may be libedit-style ~/.psql_history files out there in which ^A has been substituted for ^J (in lines after the oldest), which will not be correctly reloaded by psql versions using newer libedit. It's certainly arguable whether this is an issue warranting a back-patch, since we've not heard field complaints about it AFAIR. But I think we ought to do so. I think psql N produces files that psql N+1 can't read is worse than the reverse case, and that's exactly what we're debating here. I tried your patches against libedit-28. Wherever a command contains a newline, unpatched psql writes the three bytes \^A to the history file, and patched psql writes the four bytes \012. Unpatched psql correctly reads either form of the history file. Patched psql misinterprets a history file created by unpatched psql, placing 0x01 bytes in the recalled command where it should have newlines. That's a worrisome compatibility break. Worrisome seems like a strong word, but certainly irritating. FWIW, my Mac has psql linked to /usr/lib/libedit.3.dylib, is running 10.8.5, and has history file lines that look like this: select\0401\040union\040select\0401; (You may wonder whether I actually get paid to craft such exciting SQL commands. Turns out I do.) One point to note is that not back-patching this doesn't really fix anything. Will a user be annoyed when .psql_history fails to reload properly on a new minor release, but utterly indifferent to whether it reloads in a new major release? What if they run multiple major releases of PostgreSQL on the same machine, using the psql executable for each version when talking to that version? (Yeah, I know it's backward compatible, but not everyone may realize that, or care.) Given that, if we're going to do it this way at all, I favor back-patching: at least then the newest releases of all supported branches will be compatible with each other. But I'm still fuzzy on why we need to give up the ability to read the old format in the first place. Can't we just fix that and be done with this? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Escaping from blocked send() reprised.
On Thu, Sep 4, 2014 at 9:53 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: On 09/04/2014 04:37 PM, Robert Haas wrote: Hrm. So we'd have to block SIGUSR1, check the flag, then use pselect() to temporarily unblock SIGUSR1 and wait, then on return again unblock SIGUSR1? Doesn't seem very appealing. I think changing the signal mask is fast on Linux, but quite slow on at least some other UNIX-like platforms. And I've heard that pselect() isn't always truly atomic, so we might run into platform-specific bugs, too. I wonder if there's a better way e.g. using memory barriers. WaitLatch: check is_set. if yes then done. otherwise, set signal_me. memory barrier. recheck is_set. if not set then wait using poll/select. memory barrier. clear signal_me. SetLatch: check is_set. if yes then done. otherwise, set is_set. memory barrier. check signal_me. if set, then send SIGUSR1. Doesn't work. No matter what you do, the process running WaitLatch might receive the signal immediately before it calls poll/select. The signal handler will run, and the poll/select call will then go to sleep. There is no way to do this without support from the kernel, that is why ppoll/pselect exist. Eesh, I was confused there: ignore me. I was trying to optimize away the signal handling but assuming we still had the self-pipe byte. But of course in that case we don't need to change anything at all. I'm going to go get some more caffeine. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 09/03/2014 04:19 PM, Hannu Krosing wrote: 1. Conditions for number of rows returned by SELECT or touched by UPDATE or DELETE Now that I think upon this... don't we already have it? SELECT ... LIMIT 1 That already solves the purported problem of multiple results in SELECT INTO as well. Could we possibly extend that to UPDATE and DELETE syntax too? -- Shaun Thomas OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 stho...@optionshouse.com __ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 9/4/14 4:09 PM, Shaun Thomas wrote: On 09/03/2014 04:19 PM, Hannu Krosing wrote: 1. Conditions for number of rows returned by SELECT or touched by UPDATE or DELETE Now that I think upon this... don't we already have it? SELECT ... LIMIT 1 No, that just hides any bugs. We want the opposite: any bugs or problems should be obvious. If the query returns or touches more than one row, that should raise an error, not just give you a random one and call it a day. That already solves the purported problem of multiple results in SELECT INTO as well. Could we possibly extend that to UPDATE and DELETE syntax too? Again, this is a different problem, but LIMIT syntax for UPDATE and DELETE has been proposed, see: http://www.postgresql.org/message-id/CADB9FDf-Vh6RnKAMZ4Rrg_YP9p3THdPbji8qe4qkxRuiOwm=m...@mail.gmail.com .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Scaling shared buffer eviction
Robert Haas robertmh...@gmail.com wrote: On Thu, Sep 4, 2014 at 7:25 AM, Amit Kapila amit.kapil...@gmail.com wrote: Its not difficult to handle such cases, but it can have downside also for the cases where demand from backends is not high. Consider in above case if instead of 500 more allocations, it just does 5 more allocations, then bgreclaimer will again have to go through the list and move 5 buffers and same can happen again by the time it moves 5 buffers. That's exactly the scenario in which we *want* the looping behavior. If that's happening, then it means it's taking us exactly as long to find 5 buffers as it takes the rest of the system to use 5 buffers. We need to run continuously to keep up. That's what I was thinking, as long as there isn't a lot of overhead to starting and finishing a cycle. If there is, my inclination would be to try to fix that rather than to sleep and hope things don't get out of hand before it wakes up again. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Better support of exported snapshots with pg_dump
On Wed, Sep 3, 2014 at 11:57 PM, Robert Haas robertmh...@gmail.com wrote: I didn't find that option to be terribly important then, but I don't see how we can possibly get by without it now, unless our goal is to make logical decoding as hard to use as we possibly can. Yes. With 9.4 it is possible to take a consistent database snapshot when creating a slot but it is tricky because of how ephemeral exported snapshots are: - When using CREATE_REPLICATION_SLOT, an exported snapshot lives only for the time replication connection is done. - pg_export_snapshot result only lives for the duration of the transaction where function is called - pg_create_logical_replication_slot cannot export a snapshot So now (if I am correct), the only way to get a consistent dump from database is to maintain open a replication connection after opening a replication slot on it. Still it is really application-dependent, assuming as well that schema is not modified as mentioned in this thread. Any ways to facilitate the user experience on this side would be a great step for things like online upgrades. Perhaps we could get pg_dump or a wrapper on top of pg_dump creating a logical replication slot, then taking a consistent image of the database it is based on while replication connection is open. Tom's got a good point about the order of locking vs. snapshot taking, but I think the way to address that is by adding some capability to temporarily lock out all DDL on non-temporary objects across the entire system, rather than by trying to make pg_dump (or the walsender creating the replication slot) lock every table. Even if we could get that to work, it still leaves the very-much-related problem that dumps of databases containing many tables can easily exhaust the lock table. Yes this is an idea to dig. Having system-wide DDL locking is something that has been discussed at some point in XC development for the addition of new nodes (needed to ensure that schema was consistent during migration of data) if I recall correctly. Now looking quickly at the XC code git-grepping is showing a method based on pg_try_advisory_lock_shared and a global boolean variable set in PostgresMain, coupled with a check in ProcessUtility preventing a certain category of DDL from running if a lock is taken. The good point is that there is already some work done to detect what are the utility statements that could be allowed even if lock is hold (EXECUTE, VACUUM, CLUSTER, etc.). Now, wouldn't a variable in shared memory controlled by some system function a better option? There are as well some utility code paths that we wouldn't want to block so we would end up with a switch on all the DDL Stmt nodes or a large portion of them. Thoughts? Regards, -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 09/04/2014 02:40 PM, Pavel Stehule wrote: 2014-09-04 14:37 GMT+02:00 Joel Jacobson j...@trustly.com mailto:j...@trustly.com: On 4 sep 2014, at 11:42, Pavel Stehule pavel.steh...@gmail.com mailto:pavel.steh...@gmail.com wrote: 2014-09-04 11:22 GMT+02:00 Joel Jacobson j...@trustly.com mailto:j...@trustly.com: The point was, RETURNS returns 1 while RETURNS SETOF returns 0 .. n. no RETURNS return VALUE (it is not a row) .. and in combination with SELECT - value will be a row. RETURNS SETOF returns rows I intentionally excluded the data type of what is returned. 1 VALUE vs 0...n VALUES Do you still fail to see the point 1 VALUE is special in the context of what a function returns? sorry, I don't understand .. for me SRF functions are absolutly different monsters than scalar, array or composite function - so its impossible to compare it. When looking from the other end of the problem, we are using SELECT/INSERT/UPDATE/DELETE *SET statements* in pl/pgsql when we really want scalars. My understanding is that one main drivers of starting this thread was wanting also guaranteed SCALAR versions of these. And wanting them in a way that is easy to use. Cheers -- Hannu Krosing PostgreSQL Consultant Performance, Scalability and High Availability 2ndQuadrant Nordic OÜ
Re: [HACKERS] Patch for psql History Display on MacOSX
Noah Misch n...@leadboat.com writes: I tried your patches against libedit-28. Wherever a command contains a newline, unpatched psql writes the three bytes \^A to the history file, and patched psql writes the four bytes \012. Unpatched psql correctly reads either form of the history file. Patched psql misinterprets a history file created by unpatched psql, placing 0x01 bytes in the recalled command where it should have newlines. That's a worrisome compatibility break. I think you got the test cases backwards, or maybe neglected the aspect about how unpatched psql will only translate ^J to ^A in the oldest (or maybe the newest? too pressed for time to recheck right now) history entry. The issue is that a patched psql, or a psql with a sufficient old libedit, will apply ^J - ^A to all entries when saving, and the reverse when loading. Without the patch, only the oldest entry gets transformed. Failure to reverse the encoding in all lines is what creates a user-visible problem. If we do not fix this, that's what we risk. We do not escape a problem by refusing to fix it. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Join push-down support for foreign tables
On Thu, Sep 4, 2014 at 08:37:08AM -0400, Robert Haas wrote: The main problem I see here is that accurate costing may require a round-trip to the remote server. If there is only one path that is probably OK; the cost of asking the question will usually be more than paid for by hearing that the pushed-down join clobbers the other possible methods of executing the query. But if there are many paths, for example because there are multiple sets of useful pathkeys, it might start to get a bit expensive. Probably both the initial cost and final cost calculations should be delegated to the FDW, but maybe within postgres_fdw, the initial cost should do only the work that can be done without contacting the remote server; then, let the final cost step do that if appropriate. But I'm not entirely sure what is best here. I am thinking eventually we will need to cache the foreign server statistics on the local server. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] INSERT ... ON CONFLICT {UPDATE | IGNORE}
On Wed, Sep 3, 2014 at 2:13 PM, Peter Geoghegan p...@heroku.com wrote: On Wed, Sep 3, 2014 at 9:51 AM, Robert Haas robertmh...@gmail.com wrote: Essentially, the implementation has all stages of query processing During the execution of the parent ModifyTable, a special auxiliary subquery (the UPDATE ModifyTable) is considered as a special case. This is not a subplan of the ModifyTable node in the conventional sense, and so does not appear within EXPLAIN output. ...that sounds wonky. Which part? It certainly wouldn't be helpful if the (say) auxiliary plan's sequential scan appeared within EXPLAIN output. That's just an implementation detail. Note that the structure of the plan is highly restricted, since it needs to be driven by the insert (or, rather, the insert's conflicts, including conflicts not visible to the command's MVCC snapshot). There won't be any interesting variation in the plan. Although, that said, the implementation should probably display any Filter: ... conditions implied by the special UPDATE qual. I think there shouldn't be any plan nodes in the system that don't get displayed by explain. If you're using a plan node for something, and think it shouldn't be displayed by explain, then either (1) you are wrong or (2) you are abusing the plan node. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
On 4 sep 2014, at 15:09, Shaun Thomas stho...@optionshouse.com wrote: On 09/01/2014 04:04 AM, Joel Jacobson wrote: + Make UPDATE/INSERT/DELETE throw error if they didnt' modify exactly 1 row, as that's the most common use-case, and provide alternative syntax to modify multiple or zero rows. What? No. The whole point of SQL is that it's set-based and can modify multiple rows at once. Hobbling it specifically for functions seems fundamentally flawed. Especially for what we purport to be a core PostgreSQL language. I've dropped that suggestion and is instead in favour of a keyword like STRICT, ONE ROW, SINGLETON or [1] like suggested by others. Any keyword or syntax will do fine, but I would prefer STRICT. + Change all warnings into errors I... what? I could see coming up with a better exception handling mechanism for escalating messages. But you're talking about taking a core element of PostgreSQL (warnings) and simply ripping them out so plpgsql2 loses even that small functionality. You misunderstood, I meant plpgsql warnings, that you currently can turn into errors by setting things in the config file. Such as shadowing of variables. I'm sure you've put a lot of thought into this, but you're not the only person using plpgsql or any, however ambitious, potential replacement. -- Shaun Thomas OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 stho...@optionshouse.com __ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Scaling shared buffer eviction
Robert Haas wrote: On Wed, Sep 3, 2014 at 7:27 AM, Amit Kapila amit.kapil...@gmail.com wrote: +Background Reclaimer's Processing +- I suggest titling this section Background Reclaim. I don't mind changing it, but currently used title is based on similar title Background Writer's Processing. It is used in previous paragraph. Is there a reason to title this differently? Oh, I didn't see that. Seems like weird phrasing to me, but I guess it's probably better to keep it consistent. ... or you can also change the other one. -- Álvaro Herrerahttp://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 4 sep 2014, at 15:32, Pavel Stehule pavel.steh...@gmail.com wrote: 2014-09-04 15:24 GMT+02:00 Jan Wieck j...@wi3ck.info: On 09/04/2014 01:14 AM, Pavel Stehule wrote: 2014-09-03 23:19 GMT+02:00 Hannu Krosing ha...@2ndquadrant.com A more SQL-ish way of doing the same could probably be called COMMAND CONSTRAINTS and look something like this SELECT ... CHECK (ROWCOUNT BETWEEN 0 AND 1); It is very near to my proposed ASSERT Only if the ASSERT syntax would become part of the original statement, it is supposed to check. In Hannu's command constraint example above, the statement that causes the error, and thus will be logged and become identified by the error message, is the actual SELECT (or other DML statement). this is valid argument. On second hand, I proposed a ASSERT that was not based on expressions only. There is not a technical issue to write assert with knowledge of related statement. I think I like the COMMAND CONSTRAINT the best so far. I not, because when it will not be part of SQL, than parser in plpgsql will be more complex. You have to inject SELECT, UPDATE, INSERT, DELETE This is what I suspected. You are against the best syntax because they are more complex to implement. I think that's coming into the discussion from the wrong direction. First agree on the best syntax, then worry about the implementation. I also understand the syntax changes will mean a lot of trouble for your plpgsql_check_function() project, but that cannot hold us back, we must aim for the best possible syntax with plpgsql2. Your work with plpgsql_check_function() btw saved me hundreds of hours of work, when we upgraded from 8.4 a few years ago, many thanks Pavel! Pavel Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info
Re: [HACKERS] Join push-down support for foreign tables
On Thursday, September 4, 2014, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 08:37:08AM -0400, Robert Haas wrote: The main problem I see here is that accurate costing may require a round-trip to the remote server. If there is only one path that is probably OK; the cost of asking the question will usually be more than paid for by hearing that the pushed-down join clobbers the other possible methods of executing the query. But if there are many paths, for example because there are multiple sets of useful pathkeys, it might start to get a bit expensive. Probably both the initial cost and final cost calculations should be delegated to the FDW, but maybe within postgres_fdw, the initial cost should do only the work that can be done without contacting the remote server; then, let the final cost step do that if appropriate. But I'm not entirely sure what is best here. I am thinking eventually we will need to cache the foreign server statistics on the local server. Wouldn't that lead to issues where the statistics get outdated and we have to anyways query the foreign server before planning any joins? Or are you thinking of dropping the foreign table statistics once the foreign join is complete? Regards, Atri -- Regards, Atri *l'apprenant*
Re: [HACKERS] PL/pgSQL 1.2
On 4 sep 2014, at 16:45, Hannu Krosing ha...@2ndquadrant.com wrote: When looking from the other end of the problem, we are using SELECT/INSERT/UPDATE/DELETE *SET statements* in pl/pgsql when we really want scalars. My understanding is that one main drivers of starting this thread was wanting also guaranteed SCALAR versions of these. And wanting them in a way that is easy to use. +1 Thank you! I have been trying to explain this in multiple cryptic ways but failed. You just nailed it! That's *exactly* what I mean! Thanks for clarifying! Cheers -- Hannu Krosing PostgreSQL Consultant Performance, Scalability and High Availability 2ndQuadrant Nordic OÜ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 17:16 GMT+02:00 Joel Jacobson j...@trustly.com: On 4 sep 2014, at 16:45, Hannu Krosing ha...@2ndquadrant.com wrote: When looking from the other end of the problem, we are using SELECT/INSERT/UPDATE/DELETE *SET statements* in pl/pgsql when we really want scalars. My understanding is that one main drivers of starting this thread was wanting also guaranteed SCALAR versions of these. And wanting them in a way that is easy to use. +1 Thank you! I have been trying to explain this in multiple cryptic ways but failed. You just nailed it! That's *exactly* what I mean! You just need a ISAM API for Postgres, That is all. Pavel Thanks for clarifying! Cheers -- Hannu Krosing PostgreSQL Consultant Performance, Scalability and High Availability 2ndQuadrant Nordic OÜ
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 17:10 GMT+02:00 Joel Jacobson j...@trustly.com: On 4 sep 2014, at 15:32, Pavel Stehule pavel.steh...@gmail.com wrote: 2014-09-04 15:24 GMT+02:00 Jan Wieck j...@wi3ck.info: On 09/04/2014 01:14 AM, Pavel Stehule wrote: 2014-09-03 23:19 GMT+02:00 Hannu Krosing ha...@2ndquadrant.com A more SQL-ish way of doing the same could probably be called COMMAND CONSTRAINTS and look something like this SELECT ... CHECK (ROWCOUNT BETWEEN 0 AND 1); It is very near to my proposed ASSERT Only if the ASSERT syntax would become part of the original statement, it is supposed to check. In Hannu's command constraint example above, the statement that causes the error, and thus will be logged and become identified by the error message, is the actual SELECT (or other DML statement). this is valid argument. On second hand, I proposed a ASSERT that was not based on expressions only. There is not a technical issue to write assert with knowledge of related statement. I think I like the COMMAND CONSTRAINT the best so far. I not, because when it will not be part of SQL, than parser in plpgsql will be more complex. You have to inject SELECT, UPDATE, INSERT, DELETE This is what I suspected. You are against the best syntax because they are more complex to implement. I think that's coming into the discussion from the wrong direction. First agree on the best syntax, then worry about the implementation. Nobody say here, so it is best syntax. It is request of proprietary enhancing of SQL and lot of people say strongly no. But you don't listen. I also understand the syntax changes will mean a lot of trouble for your plpgsql_check_function() project, but that cannot hold us back, we must aim for the best possible syntax with plpgsql2. Your work with plpgsql_check_function() btw saved me hundreds of hours of work, when we upgraded from 8.4 a few years ago, many thanks Pavel! I have no problem with plpgsql_check_function management. I remember well how issues is related to support plpgsql specific STRICT or INTO clauses. Pavel Pavel Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info
Re: [HACKERS] PL/pgSQL 1.2
On 4 sep 2014, at 17:18, Pavel Stehule pavel.steh...@gmail.com wrote: You just need a ISAM API for Postgres, That is all. Now you are being ironic, and I would prefer to keep the discussion on a serious level. You know that's not applicable in my case, you know what I do for work and what kind of system we already have. I *love* plpgsql and our development method. I just want it to get slightly more convenient and secure. When you suggest ISAM, that's like saying demolish your house and build a new one when all I want is to make small but important changes to what I already do as a professional on a daily basis. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On 09/04/2014 11:16 AM, Joel Jacobson wrote: On 4 sep 2014, at 16:45, Hannu Krosing ha...@2ndquadrant.com wrote: When looking from the other end of the problem, we are using SELECT/INSERT/UPDATE/DELETE *SET statements* in pl/pgsql when we really want scalars. My understanding is that one main drivers of starting this thread was wanting also guaranteed SCALAR versions of these. And wanting them in a way that is easy to use. +1 Thank you! I have been trying to explain this in multiple cryptic ways but failed. You just nailed it! That's *exactly* what I mean! I believe we all agree that the availability of most of the proposed functionality is desirable. I think the main difference between your point of view and that of a few others (me included) is that you prefer a language that is easy and fast to type, with as few key strokes as possible, while we prefer a language that is similar to SQL, which is rather verbose to the reader. At least when the discussion is about the default procedural language installed with the core database system. Such a language should be as similar as possible to SQL. Which is the reason why I believe that the CHECK clause belongs into the main parser, not into the PL. Regards, Jan -- Jan Wieck Senior Software Engineer http://slony.info -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] .ready files appearing on slaves
Hi hackers, Since few months, we occasionally see .ready files appearing on some slave instances from various context. The two I have in mind are under 9.2.x. I tried to investigate a bit. These .ready files are created when a WAL file from pg_xlog has no corresponding file in pg_xlog/archive_status. I could easily experience this by deleting such a file: it is created again at the next restartpoint or checkpoint received from the master. Looking at the WAL in pg_xlog folder corresponding to these .ready files, they are all much older than the current WAL cycle in both mtime and name logic sequence. As instance on one of these box we have currently 6 of those ghost WALs: 00021E5300FF 00021F1800FF 0002204700FF 000220BF00FF 0002214000FF 0002237000FF 0002255D00A8 0002255D00A9 [...normal WAL sequence...] 0002255E009D And on another box: 0001040E00FF 0001041400DA 0001046E00FF 0001047000FF 00010485000F 000104850010 [...normal WAL sequence...] 000104850052 So it seems for some reasons, these old WALs were forgotten by the restartpoint mechanism when they should have been recylced/deleted. For one of these servers, I could correlate this with some brutal disconnection of the streaming replication appearing in its logs. But there was no known SR disconnection on the second one. Any idea about this weird behaviour? What can we do to help you investigate further? Regards, -- Jehan-Guillaume de Rorthais Dalibo http://www.dalibo.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On Thu, Sep 4, 2014 at 11:32 AM, Joel Jacobson j...@trustly.com wrote: On 4 sep 2014, at 17:18, Pavel Stehule pavel.steh...@gmail.com wrote: You just need a ISAM API for Postgres, That is all. Now you are being ironic, and I would prefer to keep the discussion on a serious level. You know that's not applicable in my case, you know what I do for work and what kind of system we already have. I *love* plpgsql and our development method. I just want it to get slightly more convenient and secure. When you suggest ISAM, that's like saying demolish your house and build a new one when all I want is to make small but important changes to what I already do as a professional on a daily basis. Go right ahead: this is an open source project, after all, and with an extremely permissive license to boot. You can modify your copy of PL/pgsql, or clone it and make PL/joelsql and then change whatever you like. Optionally, you could then publish that on PGXN for others to use and contribute to. On the other hand, if what you want is for other people to make changes to the official versions of PostgreSQL that are supported and maintained by the community, then that's a different thing altogether. It entails two challenges: first, to persuade the community that those changes will be good for everyone, not just you; and second, convincing them that they (rather than you) should be the ones to do the work. So far I'd say you're losing the first argument, and I expect you'll lose the second one, too (barring a financial transaction, of course). I'm not trying to brush you off here - I understand your concerns, and they're not stupid. But, like most of the people who have commented, I don't agree that your proposals would be an improvement for the majority of people. There are several ways to deal with that, but if your goal is to get those changes made in the PostgreSQL community then you have to acknowledge the competing concerns to be just as valid as your own and come up with a proposal everyone can live with. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
On 09/04/2014 02:48 AM, Robert Haas wrote: To take another example, I've been complaining about the fact that PostgreSQL 8.3+ requires far more typecasts in stored procedures than any other database I'm aware of for years, probably since before I joined EnterpriseDB. +10 This still drives me nuts, and it's a serious problem for ORM users too. The idea that we won't accept a 'text' typed input for an 'xml' or 'json' field is IMO absurdly and needlessly pedantic. I've not yet seen an argument for what problems this solves. I know why the changes in 8.3 were made, and they're clearly beneficial overall, but we need to start putting some more implicit casts from text to text-like types in, especially where there's no SQL-standard type that users of JDBC etc can easily use in mappings. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Join push-down support for foreign tables
On Thu, Sep 4, 2014 at 08:41:43PM +0530, Atri Sharma wrote: On Thursday, September 4, 2014, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 08:37:08AM -0400, Robert Haas wrote: The main problem I see here is that accurate costing may require a round-trip to the remote server. If there is only one path that is probably OK; the cost of asking the question will usually be more than paid for by hearing that the pushed-down join clobbers the other possible methods of executing the query. But if there are many paths, for example because there are multiple sets of useful pathkeys, it might start to get a bit expensive. Probably both the initial cost and final cost calculations should be delegated to the FDW, but maybe within postgres_fdw, the initial cost should do only the work that can be done without contacting the remote server; then, let the final cost step do that if appropriate. But I'm not entirely sure what is best here. I am thinking eventually we will need to cache the foreign server statistics on the local server. Wouldn't that lead to issues where the statistics get outdated and we have to anyways query the foreign server before planning any joins? Or are you thinking of dropping the foreign table statistics once the foreign join is complete? I am thinking we would eventually have to cache the statistics, then get some kind of invalidation message from the foreign server. I am also thinking that cache would have to be global across all backends, I guess similar to our invalidation cache. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Join push-down support for foreign tables
On Thu, Sep 4, 2014 at 9:26 PM, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 08:41:43PM +0530, Atri Sharma wrote: On Thursday, September 4, 2014, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 08:37:08AM -0400, Robert Haas wrote: The main problem I see here is that accurate costing may require a round-trip to the remote server. If there is only one path that is probably OK; the cost of asking the question will usually be more than paid for by hearing that the pushed-down join clobbers the other possible methods of executing the query. But if there are many paths, for example because there are multiple sets of useful pathkeys, it might start to get a bit expensive. Probably both the initial cost and final cost calculations should be delegated to the FDW, but maybe within postgres_fdw, the initial cost should do only the work that can be done without contacting the remote server; then, let the final cost step do that if appropriate. But I'm not entirely sure what is best here. I am thinking eventually we will need to cache the foreign server statistics on the local server. Wouldn't that lead to issues where the statistics get outdated and we have to anyways query the foreign server before planning any joins? Or are you thinking of dropping the foreign table statistics once the foreign join is complete? I am thinking we would eventually have to cache the statistics, then get some kind of invalidation message from the foreign server. I am also thinking that cache would have to be global across all backends, I guess similar to our invalidation cache. That could lead to some bloat in storing statistics since we may have a lot of tables for a lot of foreign servers. Also, will we have VACUUM look at ANALYZING the foreign tables? Also, how will we decide that the statistics are invalid? Will we have the FDW query the foreign server and do some sort of comparison between the statistics the foreign server has and the statistics we locally have? I am trying to understand how the idea of invalidation message from foreign server will work. Regards, Atri
Re: [HACKERS] PL/pgSQL 1.2
Pavel Stehule pavel.steh...@gmail.com wrote: You just need a ISAM API for Postgres, That is all. Joel sure hasn't *shown* us anything to suggest that wouldn't answer his needs better than any PL, or explained why that wouldn't be a better solution for him. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
On 9/4/14 5:54 PM, Craig Ringer wrote: On 09/04/2014 02:48 AM, Robert Haas wrote: To take another example, I've been complaining about the fact that PostgreSQL 8.3+ requires far more typecasts in stored procedures than any other database I'm aware of for years, probably since before I joined EnterpriseDB. +10 This still drives me nuts, and it's a serious problem for ORM users too. The idea that we won't accept a 'text' typed input for an 'xml' or 'json' field is IMO absurdly and needlessly pedantic. I've not yet seen an argument for what problems this solves. In what context? Are we talking about parameters which have been cast to text, or what? I don't remember ever having an issue with this, though I remember the lack of implicit cast from text to json (or the other way round) making a bug more obvious a couple of times. .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
On 09/04/2014 06:48 AM, Joshua D. Drake wrote: On 09/03/2014 11:48 AM, Robert Haas wrote: Anyway, to get back around to the topic of PL/SQL compatibility specifically, if you care about that issue, pick one thing that exists in PL/SQL but not in PL/pgsql and try to do something about it. Maybe it'll be something that EnterpiseDB has already done something about, in which case, if your patch gets committed, Advanced Server will lose a bit of distinction as compared with PostgreSQL. Or maybe it'll be something that EnterpriseDB hasn't done anything about, and then everybody comes out strictly ahead. What I think you shouldn't do (although you're free to ignore me) is continue thinking of Oracle compatibility as one monolithic thing, because it isn't, or to pursue of a course of trying to get the PostgreSQL community to slavishly follow Oracle, because I think you'll fail, and even if you succeed I don't think the results will actually be positive for PostgreSQL. Well put Robert. Indeed, especially with reference to the size and scope of Oracle. Its XML library alone is huge. At best it's reasonable to hope for compatibility with a limited subset of PL/SQL - and really, we're a good way there already, with most of what's missing being down to missing core server features or things PostgreSQL just does differently. True Oracle compatibility (for procedures) pretty much requires an embedded JVM with a rich class library. Since PL/Java seems to be dying a slow death by neglect and disinterest I don't think it's likely anyone would be tackling compatibility with the embedded JVM features anytime soon. There are a few things I would like to see, like secure session variables in PL/PgSQL. Mostly, though, I think talk of Oracle compatibility seems to be something that comes up before the speaker has really understood what that would mean, and the sheer scope of the endeavour. It's not going from 50% compatible to 80% compatible, it's going from 5% compatible to 7% compatible. The most used 5% maybe, but still... -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Join push-down support for foreign tables
On Thu, Sep 4, 2014 at 09:31:20PM +0530, Atri Sharma wrote: I am thinking we would eventually have to cache the statistics, then get some kind of invalidation message from the foreign server. I am also thinking that cache would have to be global across all backends, I guess similar to our invalidation cache. That could lead to some bloat in storing statistics since we may have a lot of tables for a lot of foreign servers. Also, will we have VACUUM look at ANALYZING the foreign tables? Also, how will we decide that the statistics are invalid? Will we have the FDW query the foreign server and do some sort of comparison between the statistics the foreign server has and the statistics we locally have? I am trying to understand how the idea of invalidation message from foreign server will work. Well, ANALYZING is running on the foreign server, and somehow it would be nice if it would send a message to us about its new statistics, or we can do it like http does and it gives us a last-refresh statistics date when we connect. I am not sure how it will work --- I am just suspecting that we might get to a point where the statistics lookup overhead on the foreign server might become a bottleneck. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
Hi Craig 2014-09-04 17:54 GMT+02:00 Craig Ringer cr...@2ndquadrant.com: On 09/04/2014 02:48 AM, Robert Haas wrote: To take another example, I've been complaining about the fact that PostgreSQL 8.3+ requires far more typecasts in stored procedures than any other database I'm aware of for years, probably since before I joined EnterpriseDB. +10 This still drives me nuts, and it's a serious problem for ORM users too. The idea that we won't accept a 'text' typed input for an 'xml' or 'json' field is IMO absurdly and needlessly pedantic. I've not yet seen an argument for what problems this solves. I know why the changes in 8.3 were made, and they're clearly beneficial overall, but we need to start putting some more implicit casts from text to text-like types in, especially where there's no SQL-standard type that users of JDBC etc can easily use in mappings. I don't see a problem in additional casts. But some missing casts are well - I found lot performance issues based on using wrong data types - integers, dates in text column. Pavel -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] pgcrypto: PGP signatures
Marko, et al, This is a review of the pgcrypto PGP signatures patch: http://www.postgresql.org/message-id/53edbcf0.9070...@joh.to There hasn't been any discussion, at least that I've been able to find. Contents Purpose == This patch add functions to create, verify and extract infromation from OpenPGP signatures. Previously pgcrypto only peformed PGP encrypt/decrypt, not sign/verify. This is a painful limitation since a very common use-case for OpenPGP is the signature-part, where two parties want to verify messages originate from each other, and not only encrypt the messages. Included in the patch are updated regression test cases and documentation. Initial Run === The patch applies cleanly to HEAD after changing a single line in the patch: ! Giving this function a secret key will produce an error. --- ! Giving this function a secret key will produce a error. This grammar fix was already fixed in 05258761bf12a64befc9caec1947b254cdeb74c5, and therefore caused the conflict. The 144 regression tests all pass successfully against the new patch. Conclusion == Since I'm using these functions in the BankAPI project, https://github.com/trustly/bankapi, I have tested them by actually using them in production, in addition to the provided regression tests, which is a good sign they are working not just in theory. +1 for committer review after the changes suggested by Jeff Janes and Thomas Munro. On Fri, Aug 15, 2014 at 9:55 AM, Marko Tiikkaja ma...@joh.to wrote: Hi, On 8/7/14 12:15 PM, I wrote: Here's v2 of the patch. I've changed the info-extracting code to not look for signatures beyond the data, which also meant that it had to parse one-pass signatures (which it didn't do before). This matches the behaviour of the main decryption code. Here's the latest version where I've added the option to extract the creation time from the signatures. .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Join push-down support for foreign tables
On Thu, Sep 4, 2014 at 9:33 PM, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 09:31:20PM +0530, Atri Sharma wrote: I am thinking we would eventually have to cache the statistics, then get some kind of invalidation message from the foreign server. I am also thinking that cache would have to be global across all backends, I guess similar to our invalidation cache. That could lead to some bloat in storing statistics since we may have a lot of tables for a lot of foreign servers. Also, will we have VACUUM look at ANALYZING the foreign tables? Also, how will we decide that the statistics are invalid? Will we have the FDW query the foreign server and do some sort of comparison between the statistics the foreign server has and the statistics we locally have? I am trying to understand how the idea of invalidation message from foreign server will work. Well, ANALYZING is running on the foreign server, and somehow it would be nice if it would send a message to us about its new statistics, or we can do it like http does and it gives us a last-refresh statistics date when we connect. Not sure how that would work without changing the way ANALYZE works on the foreign server. http idea could work,though. I am not sure how it will work --- I am just suspecting that we might get to a point where the statistics lookup overhead on the foreign server might become a bottleneck. Totally agree, but doing the planning only locally opens the questions I mentioned above, and also deprives the foreign server database to do any optimizations that it may want to do (assuming that the foreign database and postgres query planner do not generate identical plans). This is only my thought though, we could also be planning better than the foreign server database, so the optimization part I raised is debatable. Regards, Atri -- Regards, Atri *l'apprenant*
Re: [HACKERS] B-Tree support function number 3 (strxfrm() optimization)
On Tue, Sep 2, 2014 at 10:27 PM, Peter Geoghegan p...@heroku.com wrote: * Still doesn't address the open question of whether or not we should optimistically always try memcmp() == 0 on tiebreak. I still lean towards yes. Let m be the cost of a memcmp() that fails near the end of the strings; and let s be the cost of a strcoll that does likewise. Clearly s m. But approximately what is s/m on platforms where you can test? Say, with 100 byte string, in a few different locales. If for example s/m 100 then it's a no-brainer, because in the worst case we're adding 1% overhead, and in the best case we're saving 99%. OTOH, if s/m 2 then I almost certainly wouldn't do it, because in the worst case we're adding 50% overhead, and in the best case we're saving 50%. That seems like it's doubling down on the abbreviated key stuff to work mostly all the time, and I'm not prepared to make that bet. There is of course a lot of daylight between a 2-to-1 ratio and a 100-to-1 ratio and I expect the real value is somewhere in the middle (probably closer to 2); I haven't at this time made up my mind what value would make this worthwhile, but I'd like to know what the real numbers are. * Leaves open the question of what to do when we can't use the abbreviated keys optimization just because a datum tuplesort is preferred when sorting single-attribute tuples (recall that datum case tuplesorts cannot use abbreviated keys). We want to avail of tuplesort datum sorting where we can, except when abbreviated keys are available, which presumably tips the balance in favor of heap tuple sorting even when sorting on only one attribute, simply because then we can then use abbreviated keys. I'm thinking in particular of nodeAgg.c, which is an important case. I favor leaving this issue to a future patch. The last thing this patch needs is more changes that someone might potentially dislike. Let's focus on getting the core thing working, and then you can enhance it once we all agree that it is. On the substance of this issue, I suspect that for pass-by-value data types it can hardly be wrong to use the datum tuplesort approach; but it's possible we will want to disable it for pass-by-reference data types when the abbreviated-key infrastructure is available. That will lose if it turns out that the abbreviated keys aren't capturing enough of the entropy, but maybe we'll decide that's OK. Or maybe not. But I don't think it's imperative that this patch make a change in that area, and indeed, in the interest of keeping separate changes isolated, I think it's better if it doesn't. There are still FIXME/TODO comments for each of these two points. Further, this revised/rebased patch set: * Incorporates your feedback on stylistic issues, with changes confined to their own commit (on top of earlier commits that are almost, but not quite, the same as the prior revision that your remarks apply to). * No longer does anything special within reversedirection_heap(), since that is unnecessary, as it's only used by bounded sorts, which aren't a useful target for abbreviated keys. This is noted. There is no convenient point to add a defensive assertion against this, so I haven't. * Updates comments in master in a broken-out way, reflecting opclass contract with sortsupport as established by 1d41739e5a04b0e93304d24d864b6bfa3efc45f2, that is convenient to apply to and commit in the master branch immediately. Thanks, committed that one. The remaining patches can be squashed into a single one, as none of them can be applied without the others. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] B-Tree support function number 3 (strxfrm() optimization)
On Wed, Sep 3, 2014 at 5:44 PM, Peter Geoghegan p...@heroku.com wrote: On Wed, Sep 3, 2014 at 2:18 PM, Robert Haas robertmh...@gmail.com wrote: My suggestion is to remove the special cases for Darwin and 32-bit systems and see how it goes. I guess it should still be a configure option, then. Or maybe there should just be a USE_ABBREV_KEYS macro within pg_config_manual.h. Are you suggesting that the patch be committed with the optimization enabled on all platforms by default, with the option to revisit disabling it if and when there is user push-back? I don't think that's unreasonable, given the precautions now taken, but I'm just not sure that's what you mean. That's what I mean. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
2014-09-04 18:02 GMT+02:00 Kevin Grittner kgri...@ymail.com: Pavel Stehule pavel.steh...@gmail.com wrote: You just need a ISAM API for Postgres, That is all. Joel sure hasn't *shown* us anything to suggest that wouldn't answer his needs better than any PL, or explained why that wouldn't be a better solution for him. I understand what Joel does. And there is a space for improvement of plpgsql - on syntax level, on internal level. But we can start with some less controversial. And some controversial points we can coverage by extensions. It is in conformance with Postgres community politics - where is not agreement, use extensions. We have to be able to write these extensions. Extensibility of plpgsql is on the begin. But for some special use cases, these extensions can be perfect. From this long discuss I am thinking so there is perfect agreement on plpgsql asserts. We needed. And now we know where assertations can be used. There is agreement on using binary casting instead IO casting every where where it is possible. And I am not against to ensuring consistent behave of assigning, returning from fce for composite types. There is small differences between rows, records, .. But should not be too hurry. There are only few people who would to changes in this area. Almost users are happy. Personally I would to see a discussion about enhancing SPI much more -- because it is base of all PL and some performance limits and some internal complexity of plpgsql (and plpgsql_check too) is based on missing some interface between SPI and PL. Regards Pavel -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: [HACKERS] PQputCopyEnd doesn't adhere to its API contract
On Wed, Sep 3, 2014 at 6:24 PM, Bruce Momjian br...@momjian.us wrote: On Fri, May 9, 2014 at 12:03:36PM -0400, Robert Haas wrote: On Thu, May 8, 2014 at 5:21 PM, Tom Lane t...@sss.pgh.pa.us wrote: Perhaps the text should be like this: The result is 1 if the termination message was sent; or in nonblocking mode, this may only indicate that the termination message was successfully queued. (In nonblocking mode, to be certain that the data has been sent, you should next wait for write-ready and call functionPQflush/, repeating until it returns zero.) Zero indicates that the function could not queue the termination message because of full buffers; this will only happen in nonblocking mode. (In this case, wait for write-ready and try the PQputCopyEnd call again.) If a hard error occurs, -1 is returned; you can use functionPQerrorMessage/function to retrieve details. That looks pretty good. However, I'm realizing this isn't the only place where we probably need to clarify the language. Just to take one example near at hand, PQputCopyData may also return 1 when it's only queued the data; it seems to try even less hard than PQputCopyEnd to ensure that the data is actually sent. Uh, where are we on this? I think someone needs to take Tom's proposed language and make it into a patch. And figure out which other functions in the documentation need similar updates. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PQputCopyEnd doesn't adhere to its API contract
On Thu, Sep 4, 2014 at 12:52:14PM -0400, Robert Haas wrote: On Wed, Sep 3, 2014 at 6:24 PM, Bruce Momjian br...@momjian.us wrote: On Fri, May 9, 2014 at 12:03:36PM -0400, Robert Haas wrote: On Thu, May 8, 2014 at 5:21 PM, Tom Lane t...@sss.pgh.pa.us wrote: Perhaps the text should be like this: The result is 1 if the termination message was sent; or in nonblocking mode, this may only indicate that the termination message was successfully queued. (In nonblocking mode, to be certain that the data has been sent, you should next wait for write-ready and call functionPQflush/, repeating until it returns zero.) Zero indicates that the function could not queue the termination message because of full buffers; this will only happen in nonblocking mode. (In this case, wait for write-ready and try the PQputCopyEnd call again.) If a hard error occurs, -1 is returned; you can use functionPQerrorMessage/function to retrieve details. That looks pretty good. However, I'm realizing this isn't the only place where we probably need to clarify the language. Just to take one example near at hand, PQputCopyData may also return 1 when it's only queued the data; it seems to try even less hard than PQputCopyEnd to ensure that the data is actually sent. Uh, where are we on this? I think someone needs to take Tom's proposed language and make it into a patch. And figure out which other functions in the documentation need similar updates. OK, did David G Johnston email comments from today help here? -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PQputCopyEnd doesn't adhere to its API contract
On Thu, Sep 4, 2014 at 12:53 PM, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 12:52:14PM -0400, Robert Haas wrote: On Wed, Sep 3, 2014 at 6:24 PM, Bruce Momjian br...@momjian.us wrote: On Fri, May 9, 2014 at 12:03:36PM -0400, Robert Haas wrote: On Thu, May 8, 2014 at 5:21 PM, Tom Lane t...@sss.pgh.pa.us wrote: Perhaps the text should be like this: The result is 1 if the termination message was sent; or in nonblocking mode, this may only indicate that the termination message was successfully queued. (In nonblocking mode, to be certain that the data has been sent, you should next wait for write-ready and call functionPQflush/, repeating until it returns zero.) Zero indicates that the function could not queue the termination message because of full buffers; this will only happen in nonblocking mode. (In this case, wait for write-ready and try the PQputCopyEnd call again.) If a hard error occurs, -1 is returned; you can use functionPQerrorMessage/function to retrieve details. That looks pretty good. However, I'm realizing this isn't the only place where we probably need to clarify the language. Just to take one example near at hand, PQputCopyData may also return 1 when it's only queued the data; it seems to try even less hard than PQputCopyEnd to ensure that the data is actually sent. Uh, where are we on this? I think someone needs to take Tom's proposed language and make it into a patch. And figure out which other functions in the documentation need similar updates. OK, did David G Johnston email comments from today help here? I didn't look at them in detail, but they don't seem to match the style of our documentation generally. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] postgresql latency bgwriter not doing its job
On Thu, Sep 4, 2014 at 3:09 AM, Ants Aasma a...@cybertec.at wrote: On Thu, Sep 4, 2014 at 12:36 AM, Andres Freund and...@2ndquadrant.com wrote: It's imo quite clearly better to keep it allocated. For one after postmaster started the checkpointer successfully you don't need to be worried about later failures to allocate memory if you allocate it once (unless the checkpointer FATALs out which should be exceedingly rare - we're catching ERRORs). It's much much more likely to succeed initially. Secondly it's not like there's really that much time where no checkpointer isn't running. In principle you could do the sort with the full sized array and then compress it to a list of buffer IDs that need to be written out. This way most of the time you only need a small array and the large array is only needed for a fraction of a second. It's not the size of the array that's the problem; it's the size of the detonation when the allocation fails. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 1.2
On Thu, Sep 4, 2014 at 5:51 PM, Robert Haas robertmh...@gmail.com wrote: When you suggest ISAM, that's like saying demolish your house and build a new one when all I want is to make small but important changes to what I already do as a professional on a daily basis. Go right ahead: this is an open source project, after all, and with an extremely permissive license to boot. You can modify your copy of PL/pgsql, or clone it and make PL/joelsql and then change whatever you like. Optionally, you could then publish that on PGXN for others to use and contribute to. On the other hand, if what you want is for other people to make changes to the official versions of PostgreSQL that are supported and maintained by the community, then that's a different thing altogether. It entails two challenges: first, to persuade the community that those changes will be good for everyone, not just you; and second, convincing them that they (rather than you) should be the ones to do the work. So far I'd say you're losing the first argument, and I expect you'll lose the second one, too (barring a financial transaction, of course). I'm not trying to brush you off here - I understand your concerns, and they're not stupid. But, like most of the people who have commented, I don't agree that your proposals would be an improvement for the majority of people. There are several ways to deal with that, but if your goal is to get those changes made in the PostgreSQL community then you have to acknowledge the competing concerns to be just as valid as your own and come up with a proposal everyone can live with. If my company would write code in PL/joelsql, I think I would have a hard time through any technical due diligence in the future. :-) The main reason why I'm so eager of finding a support from you, the majority of other readers on this list, is of course because I think we as a group can come up with a much better solution to the problem than what I could on my own. And for me it's better if we can agree on *something* which improves my and others life to *some* extent, rather than to just sitting here silent waiting another 16 years for PL/pgSQL 2 to develop itself. I can certainly live with a more SQLish syntax than the one I had in mind. I'm less concerned about the verbosity of the language, if I wanted a condensed language I should have opted for some other language in the first place, so that's not my problem. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PQputCopyEnd doesn't adhere to its API contract
On Thu, Sep 4, 2014 at 1:00 PM, Robert Haas [via PostgreSQL] ml-node+s1045698n581780...@n5.nabble.com wrote: On Thu, Sep 4, 2014 at 12:53 PM, Bruce Momjian [hidden email] http://user/SendEmail.jtp?type=nodenode=5817809i=0 wrote: On Thu, Sep 4, 2014 at 12:52:14PM -0400, Robert Haas wrote: On Wed, Sep 3, 2014 at 6:24 PM, Bruce Momjian [hidden email] http://user/SendEmail.jtp?type=nodenode=5817809i=1 wrote: On Fri, May 9, 2014 at 12:03:36PM -0400, Robert Haas wrote: On Thu, May 8, 2014 at 5:21 PM, Tom Lane [hidden email] http://user/SendEmail.jtp?type=nodenode=5817809i=2 wrote: Perhaps the text should be like this: The result is 1 if the termination message was sent; or in nonblocking mode, this may only indicate that the termination message was successfully queued. (In nonblocking mode, to be certain that the data has been sent, you should next wait for write-ready and call functionPQflush/, repeating until it returns zero.) Zero indicates that the function could not queue the termination message because of full buffers; this will only happen in nonblocking mode. (In this case, wait for write-ready and try the PQputCopyEnd call again.) If a hard error occurs, -1 is returned; you can use functionPQerrorMessage/function to retrieve details. That looks pretty good. However, I'm realizing this isn't the only place where we probably need to clarify the language. Just to take one example near at hand, PQputCopyData may also return 1 when it's only queued the data; it seems to try even less hard than PQputCopyEnd to ensure that the data is actually sent. Uh, where are we on this? I think someone needs to take Tom's proposed language and make it into a patch. And figure out which other functions in the documentation need similar updates. OK, did David G Johnston email comments from today help here? I didn't look at them in detail, but they don't seem to match the style of our documentation generally. Specific observations would help though that is partly the idea - I've been more focused on clarity and organization even if it requires deviating from the current general documentation style. If this is not acceptable I'm happy to incorporate the ideas of others to try and get the best of both worlds. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/PQputCopyEnd-doesn-t-adhere-to-its-API-contract-tp5803240p5817812.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
Re: [HACKERS] Display of timestamp in pg_dump custom format
On Wed, Sep 3, 2014 at 08:33:31PM -0400, Bruce Momjian wrote: I can't seem to find a way to get the timezone offset via C; see: http://stackoverflow.com/questions/635780/why-does-glibc-timezone-global-not-agree-with-system-time-on-dst On Linux, do 'man timezone' for details. 'timezone' has the non-DST offset from GMT, and 'daylight' is a boolean which indicates DST, but not how much time is different for DST, and I am not sure it is always an hour. In fact 'daylight' is documented as saying whether there is every a daylight savings time, not that DST is active. Uh, not sure what I was thinking --- strftime() is the way to go. Here is the new output: ; ; Archive created at 2014-09-04 13:00:15 -0400 --- ; dbname: test ; TOC Entries: 8 ; Compression: -1 ; Dump Version: 1.12-0 ; Format: CUSTOM ; Integer: 4 bytes ; Offset: 8 bytes ; Dumped from database version: 9.5devel ; Dumped by pg_dump version: 9.5devel I found two other places in our dump code that use strftime with a similar format, but they had problems with the timezone string on Windows, so I switched those over to use a numeric timezone offset as well. Patch attached. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c new file mode 100644 index 0018720..ded9135 *** a/src/bin/pg_dump/pg_backup_archiver.c --- b/src/bin/pg_dump/pg_backup_archiver.c *** PrintTOCSummary(Archive *AHX, RestoreOpt *** 964,975 teSection curSection; OutputContext sav; const char *fmtName; sav = SaveOutput(AH); if (ropt-filename) SetOutput(AH, ropt-filename, 0 /* no compression */ ); ! ahprintf(AH, ;\n; Archive created at %s, ctime(AH-createDate)); ahprintf(AH, ; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n, AH-archdbname, AH-tocCount, AH-compression); --- 964,978 teSection curSection; OutputContext sav; const char *fmtName; + struct tm *tm = localtime(AH-createDate); + char stamp_str[64]; sav = SaveOutput(AH); if (ropt-filename) SetOutput(AH, ropt-filename, 0 /* no compression */ ); ! strftime(stamp_str, sizeof(stamp_str), %Y-%m-%d %H:%M:%S %z, tm); ! ahprintf(AH, ;\n; Archive created at %s\n, stamp_str); ahprintf(AH, ; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n, AH-archdbname, AH-tocCount, AH-compression); *** checkSeek(FILE *fp) *** 3455,3475 static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim) { ! char buf[256]; ! /* ! * We don't print the timezone on Win32, because the names are long and ! * localized, which means they may contain characters in various random ! * encodings; this has been seen to cause encoding errors when reading the ! * dump script. ! */ ! if (strftime(buf, sizeof(buf), ! #ifndef WIN32 ! %Y-%m-%d %H:%M:%S %Z, ! #else ! %Y-%m-%d %H:%M:%S, ! #endif ! localtime(tim)) != 0) ahprintf(AH, -- %s %s\n\n, msg, buf); } --- 3458,3466 static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim) { ! char buf[64]; ! if (strftime(buf, sizeof(buf), %Y-%m-%d %H:%M:%S %z, localtime(tim)) != 0) ahprintf(AH, -- %s %s\n\n, msg, buf); } diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c new file mode 100644 index 4050091..b2b3e6f *** a/src/bin/pg_dump/pg_dumpall.c --- b/src/bin/pg_dump/pg_dumpall.c *** executeCommand(PGconn *conn, const char *** 2039,2060 static void dumpTimestamp(char *msg) { ! char buf[256]; time_t now = time(NULL); ! /* ! * We don't print the timezone on Win32, because the names are long and ! * localized, which means they may contain characters in various random ! * encodings; this has been seen to cause encoding errors when reading the ! * dump script. ! */ ! if (strftime(buf, sizeof(buf), ! #ifndef WIN32 ! %Y-%m-%d %H:%M:%S %Z, ! #else ! %Y-%m-%d %H:%M:%S, ! #endif ! localtime(now)) != 0) fprintf(OPF, -- %s %s\n\n, msg, buf); } --- 2039,2048 static void dumpTimestamp(char *msg) { ! char buf[64]; time_t now = time(NULL); ! if (strftime(buf, sizeof(buf), %Y-%m-%d %H:%M:%S %z, localtime(now)) != 0) fprintf(OPF, -- %s %s\n\n, msg, buf); } -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Pg_upgrade and toast tables bug discovered
The 9.3.5 release notes contain... - Fix pg_upgrade for cases where the new server creates a TOAST table but the old version did not (Bruce Momjian) This rare situation would manifest as relation OID mismatch errors. ...which I thought was this bug, hence my confusion. If anyone else is experiencing this bug, they may erroneously be led to believe that 9.3.5 contains the fix. I will attempt to build 9.3 stable head and retry my upgrade. On Wed, Sep 3, 2014 at 6:03 PM, Bruce Momjian br...@momjian.us wrote: On Wed, Sep 3, 2014 at 05:12:30PM -0600, Noah Yetter wrote: I'm not sure it's fixed. I am attempting a pg_upgrade from 9.2.8 to 9.3.5 and it dies like so: (...many relations restoring successfully snipped...) pg_restore: creating SEQUENCE address_address_id_seq pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 1410; 1259 17670 SEQUENCE address_address_id_seq javaprod pg_restore: [archiver (db)] could not execute query: ERROR: could not create file base/16414/17670: File exists Inspecting a copy of the source cluster, OID 17670 does indeed correspond to address_address_id_seq, but inspecting the partially-upgraded cluster that OID is taken by pg_toast_202359_index. Again conferring with a copy of the source (9.2.8) cluster, the relation corresponding to filenode 202359 does not have a toast table. (I know pg-hackers isn't the right place to discuss admin issues, but this thread is the only evidence of this bug I can find. If anyone can suggest a workaround I would be infinitely grateful.) Actually, there was a pg_upgrade fix _after_ the release of 9.3.5 which explains this failure: commit 4c6780fd17aa43ed6362aa682499cc2f9712cc8b Author: Bruce Momjian br...@momjian.us Date: Thu Aug 7 14:56:13 2014 -0400 pg_upgrade: prevent oid conflicts with new-cluster TOAST tables Previously, TOAST tables only required in the new cluster could cause oid conflicts if they were auto-numbered and a later conflicting oid had to be assigned. Backpatch through 9.3 Any chance you can download the 9.3.X source tree and try that? You need an entire install, not just a new pg_upgrade binary. I am disapointed I could not fix this before 9.3.5 was released. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
Re: [HACKERS] pgcrypto: PGP armor headers
Marko, et al, This is a review of the pgcrypto PGP Armor Headers patch: http://www.postgresql.org/message-id/53edcae8.20...@joh.to Contents Purpose == This patch add functions to create and extract OpenPGP Armor Headers. from OpenPGP messages. Included in the patch are updated regression test cases and documentation. Initial Run === The patch applies cleanly to HEAD. The 144 regression tests all pass successfully against the new patch. Conclusion == Since I'm using these functions in the BankAPI project, https://github.com/trustly/bankapi, I have tested them by actually using them in production, in addition to the provided regression tests, which is a good sign they are working not just in theory. +1 for committer review. On Fri, Aug 15, 2014 at 10:55 AM, Marko Tiikkaja ma...@joh.to wrote: Hi, On 8/8/14 3:18 PM, I wrote: Currently there's no way to generate or extract armor headers from the PGP armored format in pgcrypto. I've written a patch to add the support. Latest version of the patch here, having fixed some small coding issues. .marko -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] B-Tree support function number 3 (strxfrm() optimization)
On Thu, Sep 4, 2014 at 9:19 AM, Robert Haas robertmh...@gmail.com wrote: On Tue, Sep 2, 2014 at 10:27 PM, Peter Geoghegan p...@heroku.com wrote: * Still doesn't address the open question of whether or not we should optimistically always try memcmp() == 0 on tiebreak. I still lean towards yes. Let m be the cost of a memcmp() that fails near the end of the strings; and let s be the cost of a strcoll that does likewise. Clearly s m. But approximately what is s/m on platforms where you can test? Say, with 100 byte string, in a few different locales. Just to be clear: I imagine you're more or less sold on the idea of testing equality in the event of a tie-break, where the leading 8 primary weight bytes are already known to be equal (and the full text string lengths also match); the theory of operation behind testing how good a proxy for full key cardinality abbreviated key cardinality is is very much predicated on that. We can still win big with very low cardinality sets this way, which are an important case. What I consider an open question is whether or not we should do that on the first call when there is no abbreviated comparison, such as on the second or subsequent attribute in a multi-column sort, in the hope that equality will just happen to be indicated. If for example s/m 100 then it's a no-brainer, because in the worst case we're adding 1% overhead, and in the best case we're saving 99%. OTOH, if s/m 2 then I almost certainly wouldn't do it, because in the worst case we're adding 50% overhead, and in the best case we're saving 50%. That seems like it's doubling down on the abbreviated key stuff to work mostly all the time, and I'm not prepared to make that bet. There is of course a lot of daylight between a 2-to-1 ratio and a 100-to-1 ratio and I expect the real value is somewhere in the middle (probably closer to 2); I haven't at this time made up my mind what value would make this worthwhile, but I'd like to know what the real numbers are. Well, we can only lose when the strings happen to be the same size. So that's something. But I'm willing to consider the possibility that the memcmp() is virtually free. I would only proceed with this extra optimization if that is actually the case. Modern CPUs are odd things. Branch prediction/instruction pipelining, and the fact that we're frequently stalled on cache misses might combine to make it effectively the case that the opportunistic memcmp() is free. I could be wrong about that, and I'm certainly wrong if you test large enough strings with differences only towards the very end, but it seems reasonable to speculate that it would work well with appropriate precautions (in particular, don't do it when the strings are huge). Let me try and come up with some numbers for a really unsympathetic case, since you've already seen sympathetic numbers. I think the sympathetic country/province/city sort test case [1] is actually fairly representative; sort keys *are* frequently correlated like that, implying that there are lots of savings to be had by being memcmp() == 0 optimistic when resolving comparisons using the second or subsequent attribute. * Leaves open the question of what to do when we can't use the abbreviated keys optimization just because a datum tuplesort is preferred when sorting single-attribute tuples (recall that datum case tuplesorts cannot use abbreviated keys). We want to avail of tuplesort datum sorting where we can, except when abbreviated keys are available, which presumably tips the balance in favor of heap tuple sorting even when sorting on only one attribute, simply because then we can then use abbreviated keys. I'm thinking in particular of nodeAgg.c, which is an important case. I favor leaving this issue to a future patch. The last thing this patch needs is more changes that someone might potentially dislike. Let's focus on getting the core thing working, and then you can enhance it once we all agree that it is. Makes sense. I think we should make a separate pass to enable sort support for B-Tree sorting - that's probably the most compelling case, after all. That's certainly the thing that I've heard complaints about. There could be as many as 2-3 follow-up commits. On the substance of this issue, I suspect that for pass-by-value data types it can hardly be wrong to use the datum tuplesort approach; but it's possible we will want to disable it for pass-by-reference data types when the abbreviated-key infrastructure is available. That will lose if it turns out that the abbreviated keys aren't capturing enough of the entropy, but maybe we'll decide that's OK. Or maybe not. But I don't think it's imperative that this patch make a change in that area, and indeed, in the interest of keeping separate changes isolated, I think it's better if it doesn't. Right. I had presumed that we'd want to figure that out each time. I wasn't sure how best to go about doing that, which is why it's
Re: [HACKERS] PL/pgSQL 2
On 09/04/2014 09:02 AM, Craig Ringer wrote: There are a few things I would like to see, like secure session variables in PL/PgSQL. Mostly, though, I think talk of Oracle compatibility seems to be something that comes up before the speaker has really understood what that would mean, and the sheer scope of the endeavour. It's not going from 50% compatible to 80% compatible, it's going from 5% compatible to 7% compatible. The most used 5% maybe, but still... However, there are users who want certain features from PL/SQL not for compatibility but because they're useful. For example: * A package concept for encapsulation of multiple procedures, session variables, etc. * The ability to compile functions/procedures for faster execution. * Autonomous transactions We'd also like to borrow stuff from other DBMSes, such as multisets. All of the above are worth implementing, even if it means implementing them with different syntax (and mechanics) than PL/SQL. Sadly, what's prevented us from having packages already has been the insistence of potential feature sponsors that they work *exactly* like PL/SQL's packages, which is incompatible with Postgres namespacing. Also, we'd want any package concept to be usable with external PLs as well as PL/pgSQL, which necessitates other Oracle-incompatible changes. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Pg_upgrade and toast tables bug discovered
On Thu, Sep 4, 2014 at 11:37:27AM -0600, Noah Yetter wrote: The 9.3.5 release notes contain... • Fix pg_upgrade for cases where the new server creates a TOAST table but the old version did not (Bruce Momjian) This rare situation would manifest as relation OID mismatch errors. ...which I thought was this bug, hence my confusion. If anyone else is experiencing this bug, they may erroneously be led to believe that 9.3.5 contains the fix. I will attempt to build 9.3 stable head and retry my upgrade. Yes, please let us know. The post-9.3.5 fix is for the reverse case, where the new cluster needs a TOAST table that the old cluster didn't. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
2014-09-04 20:31 GMT+02:00 Josh Berkus j...@agliodbs.com: On 09/04/2014 09:02 AM, Craig Ringer wrote: There are a few things I would like to see, like secure session variables in PL/PgSQL. Mostly, though, I think talk of Oracle compatibility seems to be something that comes up before the speaker has really understood what that would mean, and the sheer scope of the endeavour. It's not going from 50% compatible to 80% compatible, it's going from 5% compatible to 7% compatible. The most used 5% maybe, but still... However, there are users who want certain features from PL/SQL not for compatibility but because they're useful. For example: * A package concept for encapsulation of multiple procedures, session variables, etc. * The ability to compile functions/procedures for faster execution. This point is more complex, because bottleneck is not in plpgsql - it is terrible fast against noncompiled pcode interpreted PL/SQL and it is comparable with PL/SQL - due different design. A expression evaluation is slower, partially due using a SQL expression interpret, partially due our arrays and strings are immutable, and any composition are slow. Cost of hidden IO cast is negative too. If we can change it, then we can increase a sped. Almost all from these bottlenecks are out of plpgsql engine. So compilation of plpgsql is myth and it doesn't help and it doesn't need it. It doesn't help with speed. Pavel * Autonomous transactions We'd also like to borrow stuff from other DBMSes, such as multisets. All of the above are worth implementing, even if it means implementing them with different syntax (and mechanics) than PL/SQL. Sadly, what's prevented us from having packages already has been the insistence of potential feature sponsors that they work *exactly* like PL/SQL's packages, which is incompatible with Postgres namespacing. Also, we'd want any package concept to be usable with external PLs as well as PL/pgSQL, which necessitates other Oracle-incompatible changes. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] INSERT ... ON CONFLICT {UPDATE | IGNORE}
On Thu, Sep 4, 2014 at 8:03 AM, Robert Haas robertmh...@gmail.com wrote: I think there shouldn't be any plan nodes in the system that don't get displayed by explain. If you're using a plan node for something, and think it shouldn't be displayed by explain, then either (1) you are wrong or (2) you are abusing the plan node. Maybe. I admit that I'm not entirely confident that the representation of the auxiliary state during planning and execution is ideal. However, it sure is convenient to be able to separately plan the auxiliary query as a subquery, and not have to specially fish it out of the subplan list later. Maybe we should add a mechanism that essentially generates an equivalent, single ModifyTable plan. Or maybe that would be adding a lot of code for no tangible benefit. I don't see much point in making one ModifyTable node pull up from the other for the benefit of this feature (which is another thing entirely to having there be a single ModifyTable plan). For now, I'm glad to have something that will allow us to drive discussion of the feature to the next level. I don't have a good enough understanding of the optimizer to be able to say with confidence what we should do, or to be able to see the big picture of making any particular trade-off. It's not an immediate concern, though. -- Peter Geoghegan -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Pg_upgrade and toast tables bug discovered
On Thu, Sep 4, 2014 at 2:39 PM, Bruce Momjian [via PostgreSQL] ml-node+s1045698n5817828...@n5.nabble.com wrote: On Thu, Sep 4, 2014 at 11:37:27AM -0600, Noah Yetter wrote: The 9.3.5 release notes contain... • Fix pg_upgrade for cases where the new server creates a TOAST table but the old version did not (Bruce Momjian) This rare situation would manifest as relation OID mismatch errors. ...which I thought was this bug, hence my confusion. If anyone else is experiencing this bug, they may erroneously be led to believe that 9.3.5 contains the fix. I will attempt to build 9.3 stable head and retry my upgrade. Yes, please let us know. The post-9.3.5 fix is for the reverse case, where the new cluster needs a TOAST table that the old cluster didn't. hmmm...the 9.3.5 doc and what you just wrote (and the Aug 7 Patch Commit) are saying the same thing...both patches claim to fix oid conflicts when only the new server requires the TOAST table. I'm not sure, though, whether anything useful can be done except field questions until 9.3.6 is released. We cannot fix the 9.3.5 doc at this point and once 9.3.6 comes out the distinction will be irrelevant... David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Pg-upgrade-and-toast-tables-bug-discovered-tp5810447p5817830.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
Re: [HACKERS] Pg_upgrade and toast tables bug discovered
Isn't that exactly what the release note says? where the new server creates a TOAST table but the old version did not vs. where the new cluster needs a TOAST table that the old cluster didn't At any rate, I've additionally observed that the relation which is blowing up pg_upgrade is a VIEW in the source cluster but gets created as a TABLE in the upgraded cluster, which may better explain why it had no toast table before and now it does. Is this some kind of expected behavior for views? On Thu, Sep 4, 2014 at 12:39 PM, Bruce Momjian br...@momjian.us wrote: On Thu, Sep 4, 2014 at 11:37:27AM -0600, Noah Yetter wrote: The 9.3.5 release notes contain... • Fix pg_upgrade for cases where the new server creates a TOAST table but the old version did not (Bruce Momjian) This rare situation would manifest as relation OID mismatch errors. ...which I thought was this bug, hence my confusion. If anyone else is experiencing this bug, they may erroneously be led to believe that 9.3.5 contains the fix. I will attempt to build 9.3 stable head and retry my upgrade. Yes, please let us know. The post-9.3.5 fix is for the reverse case, where the new cluster needs a TOAST table that the old cluster didn't. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
Re: [HACKERS] Built-in binning functions
Hi I did a review of last patch 1. There is no problem with patching 2. compilation and doc compilation without warnings and issues. 3. code is clean, respects Postgres coding rules and is well documented - it is slightly modified Tom's version with float8 optimization 4. The name with_bucket is probably one with wide agreement 5. There are a basic set of tests for muttable or fixed sized types I found only one issue - float8 path has no own test in regress tests. When this issue will be fixed, I will mark this patch as ready for commit Regards Pavel 2014-09-01 21:29 GMT+02:00 Petr Jelinek p...@2ndquadrant.com: On 01/09/14 01:42, Tom Lane wrote: BTW, was there a reason for not noticing the case of exact match in the search loop, and falling out early? As it stands the code will reliably choose the leftmost match if there are multiple equal items in the search array, but do we care about such cases? I am not sure if we care, probably not. Anyway I attached patch that I am happy with. I am not yet sure what to do with naming. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training Services
Re: [HACKERS] Pg_upgrade and toast tables bug discovered
On Thu, Sep 4, 2014 at 01:14:01PM -0600, Noah Yetter wrote: Isn't that exactly what the release note says? where the new server creates a TOAST table but the old version did not vs. where the new cluster needs a TOAST table that the old cluster didn't Sorry, yes, I got confused. We have always handled cases where the old cluster needed a TOAST table and the new cluster didn't. The 9.3.5 fix is to prevent a certain failure for a new-only TOAST table: commit 3088cc37044a303fc50857d8d9e7e44b5c250642 Author: Bruce Momjian br...@momjian.us Date: Mon Jul 7 13:24:08 2014 -0400 pg_upgrade: allow upgrades for new-only TOAST tables Previously, when calculations on the need for toast tables changed, pg_upgrade could not handle cases where the new cluster needed a TOAST table and the old cluster did not. (It already handled the opposite case.) This fixes the OID mismatch error typically generated in this case. Backpatch through 9.2 The post-9.3.5 fix is for OID conflict that _can_ happen from a new-only TOAST tables: commit 4c6780fd17aa43ed6362aa682499cc2f9712cc8b Author: Bruce Momjian br...@momjian.us Date: Thu Aug 7 14:56:13 2014 -0400 pg_upgrade: prevent oid conflicts with new-cluster TOAST tables Previously, TOAST tables only required in the new cluster could cause oid conflicts if they were auto-numbered and a later conflicting oid had to be assigned. Backpatch through 9.3 At any rate, I've additionally observed that the relation which is blowing up pg_upgrade is a VIEW in the source cluster but gets created as a TABLE in the upgraded cluster, which may better explain why it had no toast table before and now it does. Is this some kind of expected behavior for views? Uh, it certainly should not be creating a table instead of a view, though it will get a pg_class entry. -- Bruce Momjian br...@momjian.ushttp://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] Commitfest status
* Heikki Linnakangas (hlinnakan...@vmware.com) wrote: 5. Better syntax for REINDEX 6. pgcrypto: support PGP signatures 7. pgcrypto: PGP armour headers [...] I think the latter 3 patches are missing a reviewer because no-one is interested in them. There was some discussion on the REINDEX syntax, and whether we want the patch at all. The pgcrypto patches have received zero comments. I'm certainly interested in the pgcrypto patches and can look at REINDEX this weekend. If you think that a feature is worthwhile, please sign up as a reviewer. If these patches don't have a reviewer assigned by the end of the week, I'm going to mark them as Rejected on the grounds that no-one cares about them. Looks like Joel has picked up the pgcrypto ones (though I'd still be interested to help as a committer) and I'll get with Vik about the REINDEX patch. Thanks! Stephen signature.asc Description: Digital signature
Re: [HACKERS] Pg_upgrade and toast tables bug discovered
On Thu, Sep 4, 2014 at 3:35 PM, Bruce Momjian br...@momjian.us wrote: At any rate, I've additionally observed that the relation which is blowing up pg_upgrade is a VIEW in the source cluster but gets created as a TABLE in the upgraded cluster, which may better explain why it had no toast table before and now it does. Is this some kind of expected behavior for views? Uh, it certainly should not be creating a table instead of a view, though it will get a pg_class entry. Actually, there's a way this can happen. If you create two (or more) views with circular dependencies between them, then pg_dump will emit commands to create one of them as a table first, then create the others as views, then convert the first table to a view by adding a _SELECT rule to it. If pg_upgrade's logic can't cope with that, that's a bug in pg_upgrade, because there's no other way to restore views with circular dependency chains. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] PL/pgSQL 2
* Robert Haas (robertmh...@gmail.com) wrote: Second, if you did manage to develop something which was significantly more compatible with Oracle than PostgreSQL or PL/pgsql is today, you'd probably find that the community wouldn't accept it. Agreed. Moving PostgreSQL forward is what the community is interested in- not duplicating what another database product has for the strict goal of easing migrations from those databases (be it Oracle or MSSQL or MySQL). To take another example, I've been complaining about the fact that PostgreSQL 8.3+ requires far more typecasts in stored procedures than any other database I'm aware of for years, probably since before I joined EnterpriseDB. And I still think we're kidding ourselves to think that we've got that right when nobody else is doing something similar. I don't think the community should reverse that decision to benefit EnterpriseDB, or to be compatible with Oracle: I think the community should reverse that decision because it's stupid, and the precedent of other systems demonstrates that it is possible to do better. Oracle's handling of reserved words also seems to be considerably less irritating than ours, and I'd propose that we improve that in PostgreSQL too, if I knew how to do it. Unfortunately, I suspect that requires jettisoning bison and rolling our own parser generator, and it's hard to argue that would be a good investment of effort for the benefit we'd get. Also agreed on this, though any serious discussion on this would deserve its own thread. Thanks! Stephen signature.asc Description: Digital signature